svgdotjs / svg.draw.js

An extension of svg.js which allows to draw elements with mouse
MIT License
239 stars 57 forks source link

draw element and then zoom can't in right position #44

Open SunnyXJ opened 5 years ago

SunnyXJ commented 5 years ago

now I use svg.draw.js and svg.panzoom.js draw something, but I found when i draw and zoom the position isn't right. I add mousewheel fun and resolve this problem ,code like that: if(e.type=='mousewheel'){ this.m=this.el.node.getScreenCTM().inverse(); }

SunnyXJ commented 5 years ago

`calc:function (e) { var arr = this.el.array().valueOf(); arr.pop();

        if (e) {
            if(e.type=='mousewheel'){  // get new m for transformPoint
                this.m=this.el.node.getScreenCTM().inverse();
            }
            var p = this.transformPoint(e.clientX, e.clientY);
            arr.push(this.snapToGrid([p.x, p.y]));
        }

        this.el.plot(arr);
        this.drawCircles();
    },`
bnjm commented 5 years ago

@SunnyXJ Your fix works, however, I can't reproduce the issue anymore when using the latest source from this repository.

It seems like the published npm version (2.0.4) is out of date and needs a bump.