ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 753 forks source link

Kinetic.Node.prototype.setAbsolutePosition and position events #1044

Open AimForNaN opened 9 years ago

AimForNaN commented 9 years ago

Currently at (near): https://github.com/ericdrowell/KineticJS/blob/master/kinetic.js#L3051

Having setPosition called before _setTransform causes events to fire with objects that have inaccurate information. By reversing the order, we can have accurate information without any noticeably undesirable side effect (as far I can tell, at least).

In other words, this

this.setPosition({x:pos.x, y:pos.y});
this._setTransform(origTrans);

Should be

this._setTransform(origTrans);
this.setPosition({x:pos.x, y:pos.y});

This is important, in my case, because I am listening for xChange and yChange events, and when receiving this information, I also try to obtain other information (i.e. rotation), and things like rotation report with a value of 0, even though that is not true. But by having the order of execution changed, things like rotation report with an accurate value on xChange and yChange events (and who knows what other areas should be modified to reflect this kind of order of execution).