Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSAP v3 Timeline '.clear' issue #365

Closed
Ch1pStar opened this issue Feb 27, 2020 · 4 comments
Closed

GSAP v3 Timeline '.clear' issue #365

Ch1pStar opened this issue Feb 27, 2020 · 4 comments

Comments

@Ch1pStar
Copy link

Ch1pStar commented Feb 27, 2020

I'm trying to migrate a project from TweenMax v1.17.0 to gsap v3.2.0, but I'm facing some issues.

Even though I'm currently using an older version of gsap, I'm finding those issues when I compare TweenMax v2.1.3 with gsap v3.0.0.
What I have is a timeline where I add new tweens infinitely(like a loop) until some event happens and adding the tweens should stop. At that point I clear the timeline and add a final tween on the same target.

Using TweenMax v1.17.0(also v2.1.3) everything runs smoothly (open then link and check the pen's console).
Codepen : https://codepen.io/angelgbg/pen/oNXZKJY

However when I use gsap v3.2.0(also v3.0.0), the final tween is executed immediately without any tweening (please open then link and check the pen's console).
Codepen: https://codepen.io/angelgbg/pen/poJeMoV

I believe the problem is when I call timeline.clear which I think works differently than before.
I know than when stopping the loop I can kill the timeline and create another one, but there is more logic around this timeline which is not in the pen and ideally I would like to keep the current timeline, but just clear all existing tweens.

Has anyone noticed this issue and have you found a work around?

@ZachSaucier
Copy link
Member

Hey Ch1pStar.

In my console in both pens I see:

########################################## LOOPING ##########################################
##################### STOPPING #####################
... a bunch of numerical values going down to 0 ...
##################### COMPLETE #####################
FINAL: 5

What's difference are we supposed to be seeing?

@Ch1pStar
Copy link
Author

Hi ZachSaucier,

Thank you for your reply. 🙂

The numeric values are just logs of the delta between the current tweening target's value and the previously cached one.
It seems that the 'loop' I was simulating has timed out(as for testing purpose it is based on setTimeout) before you have opened the codepen. I've edited it and allowed for bigger timeout before stopping the looping tween.
Could you please check the links one by one and open the tab as soon as you click on the link, so the setTimeout doesn't end before that?

Looking at the GSAP Timeline v3.2.0 you'll notice that there is no actual tweening after clearing the 'looping' tween and attaching the final tween to the timeline (i.e. onUpdate is called only once).

Thank you. 🙂

@ZachSaucier
Copy link
Member

I see. Thank you for the additional details. For cases like this it might be helpful to use console.clear() at the top of the script and change the default behavior of the CodePen to run when you click "Run" instead of auto-updating (you can change that in the pen's settings - the cog icon). The setTimeout finishing before I go to the window might be a good reason to use gsap.delayedCall() instead as well 🙂

But that's besides the point. I see what you mean now. After "Stopping" the GSAP 3 version just logs one value while the older version logs more tweened values. That's what you're referencing, right?

I think it might be related to your timeline continuing to play after the clear so the playhead is already past the very small duration of the tween? Jack is more familiar with the specifics of how the timeline's playhead works so we can wait for him to respond.

Why are you using a timeline for this anyway? I'd just use a regular tween since you're using a tail function call for recursion: https://codepen.io/GreenSock/pen/abOWZZY?editors=0010

jackdoyle added a commit that referenced this issue Feb 28, 2020
- FIXED: [CRITICAL] regression in 3.2.1: if you animate a transform-related value on an SVG element that has no width (according to its getBBox()), it could cause a critical error (gets caught in a loop trying to discern the width).

- FIXED: if you set a timeline to be initially reversed (before adding any child animations), tweens that get added on that same tick won't inherit defaults from the root timeline.

- FIXED: if an anchor element is passed in for a scrollTo, like scrollTo: document.querySelector('[name="anchor"]'), it could be interpreted incorrectly (the browser reports it as being coercible to a number). See #366

- FIXED: A timeline that gets cleared and then has new animations added may not have its timing adjusted properly. See #365

- FIXED: due to some recent browser bugs that cause confusion with reading sourcemap files, we removed the pointers inside the minified files. In other words, // sourceMappingURL=gsap.min.js.map was removed but we're still providing the sourcemap files themselves. You can manually add them in Chrome Dev Tools. We may add the pointer back in future versions once the browser issue is resolved.
@jackdoyle
Copy link
Member

Should be resolved in 3.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants