Jump to content

G. Scott

Pausing timeline but NOT tween

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 a situation where a slideshow is dissolving between images. I am using TimelineMax and allowing the slideshow to loop endlessly. I need to give the user the ability to pause and restart the slideshow... easy enough using pause(). However I would like to make sure that if an image has already started tweening (dissolving into the next image), that the tween doesn't pause part way through... resulting in two semi-transparent images on top of each other. Is there a way to pause the timeline but allow any existing tweens to complete first?

Link to comment
Share on other sites

Not exactly.


You can place labels in your timeline after these cross-fades complete.

//transition in slide2
tl.to(img1, 1, {opacity:0}, "slide2")
tl.to(img2, 1, {opacity:1},  "slide2")

//transition in slide3
tl.to(img2, 1, {opacity:0}, "slide3")
tl.to(img3, 1, {opacity:1},  "slide3")

Then when the user wants to pause the timeline, instead of calling pause() you can use TimelineMax's getLabelAfter() to figure out what the next label is and then either

//jump to the next label and pause


// smoothly tween to the next label

Check the TimelineMax docs for more info on getLabelAfter(): http://api.greensock.com/js/

  • Like 4
Link to comment
Share on other sites

Carl, I was very curious about the same question. Thanks for the explanation! :)

  • Like 1
Link to comment
Share on other sites

You are both very welcome.

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.