Jump to content


jump to end of timelinelite?

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

Is there a shorthand to jump to the end of a timelinelite instance (and fire all of its onComplete listeners)?  The best I can think to do is do the math noting that starts and the full durations of the timelinelite's timelines and seek to that time.  But I imagine there is an easier way.

Link to comment
Share on other sites

This seems to work... anything wrong with this approach?

myTween.seek( '-=0', false );
Link to comment
Share on other sites

Instead of doing the math you can get the timeline's duration with the duration() or totalDuration() methods.
The duration method gets or set the duration of a timeline that doesn't include repeats or repeat delays, while totalDuration does consider those. Like that the engine does all the math for you.

var tl = new TimelineMax()

  .to(element, time, {vars})
  .to(element, time, {vars})
  //and so on

lineDuration = tl.duration();

lineTotalDuration = tl.totalDuration();

Now in order to jump to a specific time and execute callbacks seek is the best way to go, just include a boolean after the time parameter to indicate if you want to suppress the callbacks or not.

//the second parameter is suppress events
//by default is true, so no callbacks are executed
//in this case by setting it to false, callbacks are executed
tl.seek(lineDuration, false);

tl.seek(lineTotalDuration, false);


  • Like 1
Link to comment
Share on other sites

Bah!!! I totally forgot that you can use progress as well. You avoid the extra code of getting the timeline's duration/totalDuration.

var tl = new TimelineLite();

tl.progress(1, false);

I've never saw the relative negative value, perhaps Jack or Carl could explain that. What I knew about is reverse(0) which reverses the instance from the end.



  • Like 2
Link to comment
Share on other sites

Yep, any of the following should do:

tl.progress(1, false);
tl.seek(tl.duration(), false);
tl.time(tl.duration(), false);
tl.totalProgress(1, false);
tl.totalTime(tl.totalDuration(), false);


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