Jump to content
Search Community

timeline.play() does not work for the second time.

Zehra Taqvi test
Moderator Tag

Recommended Posts

Hello, I have a site where I keep track of the variable "pos" and play different timelines depending on the value of "pos". In the image below, zeroToOne is a timeline and so is oneToTwo.
1.PNG.3a9705dd6f32383350eec1d60da996c5.PNG

 

 

My timeline declaration: 
2.PNG.bfdfc4c17ee5579f481ed54e3d050962.PNG

 

I am able to run the timeline when the value of pos is 1 for the first time but not again. 

I do get the console.log proving that the value is 1 but the timeline does not play.

Can someone please help.

Link to comment
Share on other sites

Hi Zehra,

 

We would love to help but, having two screenshots of tiny sections of you code does not help us to help you. The only thing I can glean from your screenshots is that if you already have played the animation once you need to rewind it back to its start before you can play it again or you need to put a zero in your play command - zeroToOne.play(0) - in order for it to play from the start on further calls.

 

GSAP "just works"™️ so, it's likely that there is an error on your logic somewhere and for us to be able to identify, we would need to see the context in which this code is running. Having said that, we cannot debug your entire codebase to try and figure out. The best thing to do is to create a minimal example that mimics what you are trying to do and also shows the error you are encountering. You can use any online code editor of your choice, does not need to be CodePen, just somewhere we can see the context and are able to make changes if necessary.

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