Jump to content
Search Community

Navigating between labels

marko 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



as well as playing back an animated visualisation I want to users to be able to jump from point to point.


If I set labels in the animation they point to the start of an animation sequence not its end point.


While I can use getLabelAfter() etc + an offset that seems a kludge


Is there a means to go to a label play back that sequence & stop?


I've got a simple codepen derived demo at:






Link to comment
Share on other sites

Hello marko,


Have you looked into the seek() method:



//jumps to exactly 2 seconds
//jumps to exactly 2 seconds but doesn't 
// suppress events during the initial move:
myAnimation.seek(2, false);
//jumps to the "myLabel" label

Taken from TimelineMax DOCS:


Jumps to a specific time (or label) without affecting whether or not the instance is paused or reversed.


If there are any events/callbacks inbetween where the playhead was and the new time, they will not be triggered because by default suppressEvents (the 2nd parameter) is true. Think of it like picking the needle up on a record player and moving it to a new position before placing it back on the record. If, however, you do not want the events/callbacks suppressed during that initial move, simply set the suppressEvents parameter to false.



  • position:* — The position to go to, described in any of the following ways: a numeric value indicates an absolute position, like 3 would be exactly 3 seconds from the beginning of the timeline. A string value can be either a label (i.e. "myLabel") or a relative value using the "+=" or "-=" prefixes like "-=2" (2 seconds before the end of the timeline) or a combination like "myLabel+=2" to indicate 2 seconds after "myLabel".    
  • suppressEvents:Boolean (default = true) — If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter.


  * — self (makes chaining easier)


Does that help?

Link to comment
Share on other sites



thanks for getting back


doesn't solve problem that labels are at start of sequences


gotoAndStop + an offset works for now, I just hoped for a more elegant solution


I guess at some point I can look at having child timelines - but I'm still figuring basic stuff at the moment



Link to comment
Share on other sites

You can use TimelineMax's tweenFromTo() to tween from one label to another label




timeline.tweenFromTo("march", "feb");


or you can use tweenTo("feb") or tweenTo(tl.getLabelAfter()) ... lots of possibilities.


Also you could look into using addPause() throughout your timeline

tl.to(someMarchThing, 1, {left:200})
tl.to(someFebThing, 1, {left:200})

if you do tl.play("march") the timeline will start playing at the march label and then stop where the addPause() was inserted.




Thanks for the demo, but its best to link to the demo on CodePen so that we can see what's happening and offer better solutions.

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