Jump to content
Search Community

timeline does not work consistently 

Alatr test
Moderator Tag

Recommended Posts

7 minutes ago, ZachSaucier said:

Hey Alatr and welcome to the GreenSock forums.

 

What is not working consistently about the demo that you shared?

i expect in first step, box will open then close, but  i dont see open step

Link to comment
Share on other sites

2 minutes ago, Alatr said:

i expect in first step, box will open then close, but  i dont see open step

Thanks, I understand now. Thanks for a clear demo!

 

Let me explain what is going on:

  1. You create a timeline a1 that is paused and the playhead is at time 0.
  2. You add that timeline to a master timeline.
  3. You then attempt to add the same timeline a second time to the master timeline but this time in the reverse direction.

All of the above happens when the master timeline is initialized.

 

Since both times you are referring to the same timeline object, the timeline's (a1's) playhead is changed to be at the end and going in the reverse direction when the master timeline's gets to where it should play a1 the first time. Thus there's nothing to play. So it moves on to the second (reversed) timeline and plays that.

 

To do what you are wanting to do, you should create two timelines: One to animate it in, one to animate it out. I would probably use a .call() to make sure the timeline isn't affected until the correct time comes. 

See the Pen gOaxmvv?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Please let me know if you have questions.

  • Like 2
Link to comment
Share on other sites

1 hour ago, ZachSaucier said:

Thanks, I understand now. Thanks for a clear demo!

 

Let me explain what is going on:

  1. You create a timeline a1 that is paused and the playhead is at time 0.
  2. You add that timeline to a master timeline.
  3. You then attempt to add the same timeline a second time to the master timeline but this time in the reverse direction.

All of the above happens when the master timeline is initialized.

 

Since both times you are referring to the same timeline object, the timeline's (a1's) playhead is changed to be at the end and going in the reverse direction when the master timeline's gets to where it should play a1 the first time. Thus there's nothing to play. So it moves on to the second (reversed) timeline and plays that.

 

To do what you are wanting to do, you should create two timelines: One to animate it in, one to animate it out. I would probably use a .call() to make sure the timeline isn't affected until the correct time comes. 

 

 

 

Please let me know if you have questions.

thank you so much, you really helped, great explanation

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