Jump to content
Search Community

gsap timeline autoRemoveChildren: true makes animations tweak out

Kobold Taskmaster test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I have a gsap.timeline() I'm using for animation in a Phaser game.

I have events which I receive from a server and I timeline.to(sprite, { x: ..., y:... }) them to move them around.

I also have some fake tweens like timeline.to({ duration: 0.5 }, {onComplete: () => {}})

 

Everything is working perfectly, until I set the {autoRemoveChildren: true} setting for the timeline.

Then the movement animations don't play for the duration of the fake tweens.

And afterward, any further timeline.to movements applied happen instantly (sprite just teleports to end location).

 

I've linked a codepen where I try to reproduce the error, but I'm actually unable to.  I'm going to keep winding back my program to something closer to the codepen to see what's wrong. But in the meantime, does anyone have any suggestions on beginning to debug this based on clues I've given?

I've attached some videos...

See the Pen qBwWOjM by koboldtaskmaster (@koboldtaskmaster) on CodePen

Link to comment
Share on other sites

  • Solution

It looks to me like it's working as expected. Why are you setting autoRemoveChildren: true anyway? 

 

Let's say you've got a 1-second tween in a timeline with autoRemoveChildren: true and then you do a setTimeout() so that 1 second later, you add more tweens to that timeline. Well at that point the first tween has completed and been REMOVED, thus the duration of that timeline is 0, so you add new stuff in there but the startTime of that timeline was 1 second ago (meaning the global playhead would be 1 second past the start of that timeline), so when you add a new 1-second tween into that timeline, it'd simply render at its very end because the new timeline's duration expanded out to 1 second, but the global timeline playhead is already at the end of that. Of course you could simply call restart() on that timeline if you want it to adjust its startTime such that its very start is wherever the global timeline's playhead currently is. 

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