Jump to content
GreenSock

payne199

Timeline not taking the time to loop through every element

Recommended Posts

I am displaying a simple timeline in which a question is presented, followed by the answer, followed by both the question and answer text disappearing. The idea is to loop through a series of questions and answers in this way. I am throwing the function an array of arrays and using a forEach loop to run through each individual array to make this happen. I see in the console that the loop is looping as desired, but only the final array is animating on the screen, rather than taking the time to run each array. What am I missing? 

See the Pen dydxKvw by don199 (@don199) on CodePen

Link to comment
Share on other sites

Hey there!

 

Are you maybe looking for something like this?

See the Pen ExQqejP?editors=0011 by GreenSock (@GreenSock) on CodePen



You were creating three timelines, all of these were playing at the same time and each transition was at an absolute time in seconds.
I've moved the timeline out of the loop, changed the times to relative and then each loop I'm adding new tweens on to the end of the global timeline in order to sequence them.

You can also use gsap.set()  instead of 'to' tweens - it's essentially a zero duration 'to' tween.

Hope this helps.

  • Like 3
Link to comment
Share on other sites

Wow! Thank you for the education 🙂

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