sukjae Posted December 6, 2022 Share Posted December 6, 2022 What's the best practice to end a gsap animation all at once and roll it back to the initial state? In our example, we want to end all animations under card class and return to the default style. Is it just a way to save all timelines and do kill and clearProps? ++ Is doing kill and clearProps the best way to end animation and return to initial style? ++ By the way, I'm curious about what clearProps does. Reset to browser defaults? Or doe revert the style to the state before gsap's edit (before doing set, to,... etc.) If we use clearProps, it seems to revert all styles modified by js libraries other than gsap. For example, in the example below, I want the h3 tag to remain in green color. But back to default. If we use clearProps, it seems to keep any changes made by the css. See the Pen BaVvOgO by leesukjae (@leesukjae) on CodePen Link to comment Share on other sites More sharing options...
Rodrigo Posted December 6, 2022 Share Posted December 6, 2022 Hi, Regardless of the instance type (Tween or Timeline) the best option for what you're trying to do is the revert() method: https://greensock.com/docs/v3/GSAP/Tween/revert() Also is worth noticing that GSAP Context also has a revert method that reverts every GSAP instance that is added in or to it: https://greensock.com/docs/v3/GSAP/gsap.context() Finally GSAP Match Media is basically a wrapper for a Context instance (with other capabilities of course) that also has a revert method:https://greensock.com/docs/v3/GSAP/gsap.matchMedia() Let us know if you have more questions. Happy Tweening! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now