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 752 forks source link

Changing Layers and Tween #936

Closed bernardofd closed 10 years ago

bernardofd commented 10 years ago

Hi;

I'm writing a application using KineticJS that I'm trying to optimize for Android (WebView). My application can have several objects (Images, Texts, Polygons, etc.) that could have tweens associated with them.

In my research, I've read in this SO topic that one thing I could try is move all objects which are subjected to Tween animations to another layer, so only this layer would be affected by the redraws.

The thing is, when I did that, the Tweens didn't execute at all. I've isolated this behavior on this JSFiddle, using version 5.1.0. When you play the Tween without moving the object to another layer, everything works fine. But when you move the object to another layer before playing the tween, it is not executed. At the end, when you move the object back to the original layer, it shows up on the position it should be.

Is this behavior correct? Or am I assuming something wrong?

Best Regards

lavrton commented 10 years ago

You have to move node to tween layer BEFORE creating Tween instance. http://jsfiddle.net/CLBkm/2/

bernardofd commented 10 years ago

THANK YOU! It is SO SIMPLE! :)

I even had to dig into the source code and I couldn't find the reason why it wouldn't work. You're a life saver, Mr. @lavrton! :)