Jump to content
Search Community

Last function in timeline is not executed when reversing

blende64 test
Moderator Tag

Go to solution Solved by Carl,

Recommended Posts

Hi

 

In the linked CodePen a timeline is defined which moves the square to the right and at the end outputs the value of reversed() in the console. The timeline is paused by default and plays either forward or backward when the button is clicked. If the timeline is played backwards, the output in the console is missing. It is as if the function is not being executed. If another to tween is added after the function, "reversed:" true is displayed in the console as expected when reversing.

 

Is this a bug or am I doing something wrong?

 

Many thanks and kind regards

See the Pen yLRePOw by blatthirsch (@blatthirsch) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the great demo!

 

I believe at one point the decision was made that if the playhead was sitting at a time where there was a callback that already fired and playback resumed then the callback wouldn't run again. It's one of those situations where you could argue both behaviors (fire again or don't) but there needed to be a consistent way for it to be handled.

 

When the playhead lands on a callback and plays or reverses you can optionally set suppressEvents:false so that callbacks will fire (default is true).

See the reverse() docs

 

Since the playhead is already at the end of the animation in your example suppressEvents doesn't really apply (the playhead isn't landing there).

 

The cleanest solution would be to force the playhead to instantly move to the end of the timeline from somewhere else and  reverse with suppressEvents:false like so

 

 

    tl.time(0).reverse(tl.duration(), false);


 

See the Pen abRdEMK?editors=0011 by snorkltv (@snorkltv) on CodePen

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...