Jump to content
Search Community

Changing a tween in a timeline is ignored by the siblings

Asored test
Moderator Tag

Go to solution Solved by Carl,

Recommended Posts

Hi everyone!

 

I have a question which is very simple to ask, but where I currently do not know what to do. 

 

To make it clear, I've created a codepen on which I tried to reproduce my project as simple as possible. Basically, if I change a tween within a timeline, how do I make all the other tweens change with it? For example I could update the duration of a tween..and depending on the duration for a tween, the next tween in the timeline should change the startTime. Or do I understand something wrong? 

 

If my timeline has two tweens, both with the duration of 1 second. The structure will look like that:

 

First Tween: Duration: 1, Start Time: 0

Second Tween: Duration: 1, Start Time: 1

 

When changing now the duration for the first tween to 5, for my understanding it should be:

 

First Tween: Duration: 5, Start Time: 0

Second Tween: Duration: 1, Start Time: 5

 

But the start time remains to: 1. Please check my CodePen example. There you'll find some comments about this.

 

The context is that I'm creating a timeline visualization. I need to change the values in real time. The UI is located in a different place than where the timeline creation is located. Therefore I have to work with a parent variable that stores the timelines globally. I think that should be fine. The user can change the duration of each tween inside an Input field. As result, the duration of the timeline changes successfully. But all other tweens ignores the change of this one tween.

 

Do you have an idea how to achieve what I need? I hope that I was able to explain this understandably enough. :-)

 

 

See the Pen rNKxxVe by asored (@asored) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the clear demo. Things are working as designed. Changing the duration of a tween after it is inserted into a timeline does not shift every animation after it. This is done mainly as a performance optimization as it would be quite taxing for every animation to constantly be aware of changes to its duration. 

 

However, you can use shiftChildren()

https://greensock.com/docs/v3/GSAP/Timeline/shiftChildren()

 

demo

 

See the Pen BaVjjrX?editors=1011 by snorkltv (@snorkltv) on CodePen

 

 

 

 

  • Like 3
Link to comment
Share on other sites

22 hours ago, Carl said:

Thanks for the clear demo. Things are working as designed. Changing the duration of a tween after it is inserted into a timeline does not shift every animation after it. This is done mainly as a performance optimization as it would be quite taxing for every animation to constantly be aware of changes to its duration. 

 

However, you can use shiftChildren()

https://greensock.com/docs/v3/GSAP/Timeline/shiftChildren()

 

demo

 

 

Hi @Carl Thanks so much! Works like a charm! :)

 

 

 

 

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