I have an svg with d3 transition & scale on. I want to duplicate everything on it to a canvas with mouse events turned on. Doing it for the performance optimisation everything is going fine except the fact that when width and height of kineticsjs canvas is not 100%, mouse events get broken.
I found out that changing canvases CSS attrs such as position, top, left do not breaks mouse events, but only width and height other than 100% does. Is there a way to say kineticjs to recalculate a coordinates of objects on it without redrawing?
Just to clarify: I don't want to redraw the canvas when scaling, otherwise there will not be any performance boost at all, so setScale() solution won't work
Solved by patching kineticjs:
After 9581 line I added:
setStageScale: function(value) {
this.stageScale = value;
},
And in method _setPointerPosition I changed last statement to this:
if (x !== null && y !== null) {
var canvasScale = this.stageScale || 1;
this.pointerPos = {
x: x / canvasScale,
y: y / canvasScale
};
}
Now I just have to .setStageScale(scale) to notify kineticjs that my canvas is scaled