Reputation: 1
var that = this;
var mouseEvents = this.mouseEvents();
this.timeAxis.on('mouseover', mouseEvents.timeAxisOver);
this.timeAxis.on('mouseout', mouseEvents.timeAxisOut);
this.canvas.on('mouse:over', mouseEvents.canvasOver);
this.canvas.on('mouse:out', mouseEvents.canvasOut);
this.canvas.on('mouse:down', mouseEvents.canvasDown);
this.startPoint.on('mousedown', function(e) {
var originPos = new Array();
that.canvas.getObjects().map(function(obj, i) {
originPos.push({
x: obj.left,
y: obj.top
});
});
this.originPos = originPos;
this.pos = that.canvas.getPointer(e.e);
});
this.startPoint.on('moving', function(e) {
var currPos = that.canvas.getPointer(e.e),
originPos = this.originPos,
moveX = currPos.x - this.pos.x,
moveY = currPos.y - this.pos.y;
that.canvas.forEachObject(function(obj, i) {
obj.set({
left: originPos[i].x + moveX,
top: originPos[i].y + moveY
})
});
that.canvas.renderAll();
});
Here is jsFiddle
I am a new to fabric.js and now I have a problem.I am trying to find some solution but it isn't working. When I move the object by set method, the object moved but it's event doesn't follow, see in the code. The event target just stay in the previous position even if I rebind the event.so the problem is How can I make the event follow the object when I set the new position.
Upvotes: 0
Views: 2395