Jump to content
Search Community

best practice for resetting elements tweened by a timeline back to their original state?

UltraCakeBakery test
Moderator Tag

Recommended Posts

Hello everone.

I have a timeline that tweens multiple DOM elements. I need to reset those elements back to their original state (no left over 'style' or 'css' parameters etc).

I think I can just simply set 'style' back to null but idk if this may cause problems due to possible caching in the background?
What would be the best GSAP compliant way to reset elements back to their original state?

Link to comment
Share on other sites

Hello @UltraCakeBakery and Welcome to the GreenSock Forum!

 

There are various methods you can use such as clearProps or invalidate() before you restart() the animation.

 

But to better help you please provide a limited reduced Codepen demo example so we can test your code in a live environment.

 

Resources:
 

GSAP v2 TimelineMax: https://greensock.com/docs/v2/TimelineMax

GSAP v2 invalidate(): https://greensock.com/docs/v2/TimelineMax/invalidate()
 

GSAP v3 Timeline: https://greensock.com/docs/v3/GSAP/Timeline

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

 

Happy Tweening :)

 

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