Jump to content
Search Community

callback a curently running timeline before its end

the_bowwer test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I'm assuming that you're tracking the number in the container, so when that number gets to 100 you can remove the call instance by using the removeCallback() method. All you have to do is add a label to the call instance in order to make it easier to remove, like this:

var tl = new TimelineMax();
tl.to(_$topP, 1, { top:11 })  
  .to(_$topP, 1, { top:52 }, "topDown")// add 2 tweens at topDown label
  .to(_$botP, 1, { top:-10 }, "topDown")
  .to(_$botP, 1, { top:-52 }, "bottomUp")// add 2 tweens at bottomUp label
  .to(_$topP, 1, { top:11 }, "bottomUp")
  //next call tl.play("topDown")
  .call(tl.play, ["topDown"], tl,"callBack");

Then you check for the number in the container and execute the removeCallback() method:

if(number === 100)
{
  tl.removeCallback(tl.play, "callBack");
}

Like that the next timeline cycle will be the last one because the call to make it play again will be gone.

 

Rodrigo.

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...