KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

4.5.0 broke my code

Open lfmunoz4 opened this issue 13 years ago • 3 comments

I used to have code that looked like this, but it doesn't work anymore:

this.shape.attrs.x = this.shape.attrs.x + offset.x; this.shape.attrs.y = this.shape.attrs.y + offset.y;

If I change it to this it works

this.shape.setX(this.shape.attrs.x + offset.x); this.shape.setY(this.shape.attrs.y + offset.y);

Shouldn't these two behave exactly the same?

lfmunoz4 avatar May 09 '13 18:05 lfmunoz4

ah, you should never have been setting attrs directly to the attrs object. It prevents a lot of things from happening, that need to happen, under the covers. I'm surprised that your app was working before!

In short, you just need to go through and use setter methods.

ericdrowell avatar May 09 '13 19:05 ericdrowell

for example, when setting x and y, some optimizations are made to improve draw performance by handling matrix caching. This can only happen if you use the setX() method.

ericdrowell avatar May 09 '13 19:05 ericdrowell

Alright thank you

lfmunoz4 avatar May 09 '13 19:05 lfmunoz4