Jump to content
Search Community

Jumping to a label within a timeline

teamcolab 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

Hey everyone!

 

I am building one long animation, and as I am working on it, I don't want to have to rewatch the entire animation up to the point I am working on/debugging. What is the best way to accomplish that?

 

I've tried searching, but everything I've come across doesn't seem to work. I've tried seeking to a label, seeking to a time value, playing from the label, and all seem to just be ignored. I can play and resume just fine, but the skipping is not working.

  • Like 1
Link to comment
Share on other sites

Hello teamcolab, and Welcome to the GreenSock Forum!

 

You can use the GSAP seek() method

 

http://greensock.com/docs/#/HTML5/GSAP/TimelineMax/seek/

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

seek()

 

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

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

Hope this helps! :)

  • Like 6
Link to comment
Share on other sites

Hi teamcolab  :),

 

In addition to Jonathan's great advice, you can also add a label during the testing process (just move it where you need it as you're designing), pause the timeline and play() from that point. The code would look like this:

tl = new TimelineMax({paused:true});

tl.to(element,2, {x:400})
  .to(element,2, {x:400})
  .add("testingLabel")
  .to(element ,2, {x:400});

tl.play("testingLabel") 

Here's a really simple CodePen to show it in action:

See the Pen GoPNwP by PointC (@PointC) on CodePen

 

Happy tweening.

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