Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Design by The Rues LLC

TimelineMax Pause then Play fires function twice

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,
Frank

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

  • Like 1
Link to post
Share on other sites

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 post
Share on other sites

Carl - 

 

Thanks, and thanks for the compliment. This will work perfectly, as it prevents any significant additional workarounds. I always like it when there's a way to do it without a "hack". Haha.

 

Thanks,

Frank

Link to post
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.

×