Jump to content
Search Community

Multiple timelines which animates the same element cause unexpected result

RolandSoos test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

in this example I have two timelines and both has an animation which animates the same element in both tween. 

 

First:

  • move y: 500 -> 0 and "set" rotationZ: 0
  • When this timeline ends, play Second. (Imagine that the second timeline plays in the future when a specific event happens)

 

Second:

  • rotationZ: 0 -> 45deg
  • When this timeline ends, play the First again from the start.

 

Problem:

  • When the first timeline plays again, the rotationZ is not set back to 0 and stays on 45deg which was set by the Second timeline.

 

 

Why the First timeline does not set rotationZ back to 0? 

 

If there is only one timeline, it works as expected:

See the Pen yxYQeM by anon (@anon) on CodePen

 

See the Pen xawyvY by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi RolandSoos,

 

Thanks for the demo, very helpful.

 

I'm a bit puzzled by this as I wasn't expecting the results you were seeing, and I don't think this is a case where you should have to use invalidate().

My first assumption in such a case is that the immediateRender of fromTo() tweens was causing an overwrite or something strange, but I don't think that is the case.

 

What I did find was that using values in both tweens instead of rotationX worked as expected. For instance if you change rotationX to rotation, I think it does what you want

 

See the Pen GXpeqb?editors=0010 by anon (@anon) on CodePen

 

We will have to investigate this a bit more and get back to you.

 

Carl

 

 

 

 

 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

Hi @RolandSoos

 

I would have though clearProps:"all" as the first .set() on tl1 would have taken care of things ... but that doesn't do it either. ?

 

For some reason ... "rotation" works as opposed to "rotationZ".

 

 

See the Pen NLGoJW?editors=0010 by sgorneau (@sgorneau) on CodePen

 

Edit: Sorry Carl ... didn't see you in there :)

  • Like 2
Link to comment
Share on other sites

Thanks guys,

it is strange the rotationZ is the only one which does not work. For example rotationY works fine: 

See the Pen WgQmZo by anon (@anon) on CodePen

 

So, it might be a bug in a GSAP and the example should work without invalidation. I will wait for the result of your investigation, until that I can use invaliate() as it fixes this issue temporary.

 

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