SkidX / tweene

JavaScript Animation Proxy
http://tweene.com
Artistic License 2.0
353 stars 29 forks source link

Callback not pausing animation #12

Closed electronicdreamer closed 9 years ago

electronicdreamer commented 9 years ago

Hello,

I'm trying to animate several objects with tweene. I want the animation to pause each time one tween finishes so I tried adding a callback after each .to() call.

But it does nothing. Is it supposed to work that way? Example Thanks

SkidX commented 9 years ago

Hi, No, it's not supposed to work that way, it's a bug, thanks for reporting it. It is happening because the callback is inside the same loop that will trigger the next tweens. so until I'm able to fix it, I can suggest you a temporary workaround, with a small negative offset for the callback, like this: timeline.add(pause, '-=1ms'); It should achieve the same visual result. I'll let you know as soon as it is fixed, thanks again for the report.

electronicdreamer commented 9 years ago

Hello again,

That temp fix seems to work in the case of a .to() call but not a .fromTo(), I updated the example.

If there's no workaround for that one, I'll wait for the fix. Thanks!

SkidX commented 9 years ago

Hi, sorry for the delay, I was very busy at work. In order to achieve what you need in a coherent way across the different drivers, I added a new method addPause() if you don't specify an offset as first param, it is added at the end of the current timeline. You can also bind a callback call to the pause. Some examples:

// no offset, no callback, just pause at the current final position
line.addPause();

// add a pause to specific position
line.addPause('0.8s');

// pause + callback
line.addPause('+=300ms', function() {});

Let me know if you have any issue or question about it.

electronicdreamer commented 9 years ago

Finally had time to work on the project and test this.

Thanks!