Jump to content
GreenSock

Andyp

invalidate()

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 all,

 

I'm using tweenmax to build a timeline which changes the top and left css values of elements.  Those are based on the browserHeight and width.  On window resize, I want to rebuild my timelines to reflect the change in those values.

 

So I used timeline.invalidate() and then create a new timeline.  If the window is resized, in the middle of the timeline, it works going forward in the timeline.  However, if I reverse, it uses the same values as the pre window.resize() status.

 

Does invalidate() not change already animated values when reversing?

Link to comment
Share on other sites

I wonder if maybe you thought invalidate() is the same thing as clear(), as if it would eliminate any existing tweens/timelines inside that timeline?

 

invalidate() simply wipes out any of the recorded starting values in tweens that have already initialized (rendered for the first time), and forces them to re-initialize on the next render. Are you saying that after you invalidate() a timeline, some of its tweens that have already run retain their starting values incorrectly? It's pretty tough to diagnose without seeing an example - would you mind posting a very simple codepen or jsfiddle that clearly demonstrates the odd behavior? We'd be happy to take a peek. 

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