Jump to content
Search Community

TimelineMax Pause then Play fires function twice

Design by The Rues LLC test
Moderator Tag

Go to solution Solved by Carl,

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 am using TimelineMax to create a sort of comic that the user can step through.

At the end of each sequence of animations, I have a label to indicate the completion of a scene, a pause, and a triggerEvent function that lets my application know that we now need user interaction to continue (typically, to display a next button).
Unfortunately, when the user clicks the "next" button to continue (which simply calls the play() method of the timeline), the triggerEvent function fires again, because the playhead was paused at that same frame.
There are a number of solutions I am considering so that the triggerEvent function doesn't fire on play, but I wanted to first find out from folks here if there is another way I should be approaching this that is more obvious (as is frequently the case).
Thanks in Advance,

See the Pen cJbFy by frankrue (@frankrue) on CodePen

  • Like 1
Link to comment
Share on other sites

  • Solution

Hi and welcome to the GreenSock forums.


Thanks so much for the demo. It was perfect. Wish everyone made their issues so clear. Great job.


You can get around the issue of the callback firing both when paused and played if you add the callback to the addPause() like so

tl.addPause("+=0", triggerEvent, ["scene1Done"]);

Demo: http://codepen.io/GreenSock/pen/aGlAs


Is that a suitable solution?

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