Jump to content


Jump to specific label without showing all animation

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

I have an animation with 10 chapter with label each one, when finish all the animation y have button to jump in each chapter with "seek()", for example i jump from chapter 1 to 5 with seek('chapter_5'), but when i do it, the animation jump to chapter 5 but show also the chapter 1, chapter 2 3 and 4, So, how can i jump?? to chapter 5 and show only the chapter 5 ?

var tl_EscenasControl = new TimelineMax({});


i have button to jump in each chapter

buton4.click... tl_EscenasControl.seek('escena_4')

it jump to chapter 4 but also show the chapter  2 and  3


how can just jump to 4 ?? and dont show the 2 and 3


Link to comment
Share on other sites



That's an odd behaviour, it should be working, are you using the latest version of the engine?.


Try getLabelsArray() and see what you get, like this:

var timelineLabels = tl_EscenasControl.getLabelsArray();


That should return an array of the timeline labels and their respective times in the timeline.


Also consider that seek doesn't change the playing state of the timeline, meaning that if the timeline is paused, after you use the seek() method it will remain paused.


You can see a little sample here:

See the Pen omvJI by rhernando (@rhernando) on CodePen


It would help a lot if you could set a live sample, jfiddle or codepen with the isolated issue to get a better idea of what might be happening.


Hope this helps,



  • Like 1
Link to comment
Share on other sites

  • 3 months later...

I'm actually trying to do exactly the opposite of this. I have a timeline, and I want to be able to play it from wherever it is to a specific label. I want seek() to play all the animation in between.


Is this possible?

Link to comment
Share on other sites



I can suggest you two options.


First you could use the seek method like you say. If you check the codepen seek takes the playhead to the indicated label, but keep in mind that it doesn't change the play state of the timeline, what it means is that if the timeline is paused or stopped it'll remain paused and if the timeline is playing it'll keep playing.


The second alternative is the tweenTo() method, that tweens the timeline from wherever the playhead is at that moment to the indicated position (could be time or label). You should keep in mind that after the timeline reaches the label or time you indicated it'll paused:

var tl = new TimelineMax();

.to(element, time, {vars})
.to(element2, time, {vars}, 'label2')
.to(element3, time, {vars}, 'label3')

//the following will tween the timeline to label2 and it'll pause

If you want even more control you can use the tweenFromTo method that takes the timeline from a start position to a end position independent of the timeline's current position and play direction. It also set the timeline to paused when is completed:

//this will take the timeline from label3 to label2

You can read more about it in the docs:






Link to comment
Share on other sites

Ok, I had found tweenTo() and was trying to use it, but for some reason it wasn't working.


I'm doing this for an iPad specific site, if that has any bearing on it. I'll play around with it, and if I'm still stuck, I'll see if I can get a codepen of my issue. Thanks for the help!

Link to comment
Share on other sites

tweenTo seems to do what I want it to, but it's having some performance issues. I have  a timeline with several labels throughout. On an iPad, I have attached a swipe event to advance to the next label (or previous depending on swipe direction).


From the initial state to the first label, tweenTo does great. It animates smoothly and looks good. When I swipe again to the next label, it happens much slower. When I swipe to the third, it happens MUUUUUCH slower, to the point where it's barely even happening.


I'm not sure why this is happening.


Even if I replace tweenTo() with seek(), it seems to take a while for it to happen. I'm not sure if it's from my swipe code or the timeline code. Below is how I'm detecting swipe.

$('#animated_content').bind('touchstart touchend touchmove', function(e){
      if(e.type === 'touchstart') {
        startX = e.pageX;
      }else if(e.type === 'touchmove'){
        endX = e.pageX;
      }else if(startX != -1 && endX != -1){//make sure the moved at all
        swipeDir = (startX > endX) ? 'left' : 'right';
        startX = endX = -1; //reset for next touches


I implemented some buttons to link directly to the labels and it's still slow, so I don't think it's the swipe detection. It's iOS 6.1

Link to comment
Share on other sites



Any chance you could change the bind method to single events methods?.


It appears that every time a touch event happens, the event handler gets binded again. For example the first time you make a touch event, the handler gets executed once, that's expected. On the second touch event the handler gets executed twice, then three times, and so on. In order to confirm this get an onComplete call on the timeline, to execute a function that returns the labels array with their respective times:




Also it would be very helpful if you could supply a codepen or fiddle with the isolated issue in order to see how the timeline is being populated.




Link to comment
Share on other sites

Got it. I don't think the touch event was being rebinded. I had some console.log()s in there that would fire whenever a swipe was detected, and it was only firing once.


The issue, it turns out, was my use of .staggerTo() with an array of images. I'm guessing (and will be doing some more work to figure out) that there just isn't enough memory to zip through 100 images to create an animation. It works great on desktop, but the poor iPad can't handle it.


I'm going to see if removing the image after it is shown speeds it up at all, or just cutting the frame rate down. 




Also, Rodrigo, I don't know if you work for Greensock or just have a great understanding of it, but I wanted to say thank you. Your various forum posts have helped me a ton on this project. It's my first time using Greensock, and knowing that there is a community with members like you in it makes me much more likely to use it again.

  • Like 2
Link to comment
Share on other sites

Yeah, if you look around in the forums Carl and Jack has said in several posts regarding images that the amount, size and animation type can create a huge workload for the browser (chrome in particular and I don't know if this extends to other webkit browsers safari OS and iOS, and android also on that list) and consuming lots of CPU cycles which, as you reported, might not be a big issue in a modern desktop/laptop but in a device with a smaller cpu and gpu can make the animation slower.


You're welcome, glad to help.



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