Jump to content
Search Community

how to stop a timeline animation for a specific object using gsap timeline (gsap.to)

one77 test
Moderator Tag

Recommended Posts

Good day everyone, 

please you all should bear with me on this one, am still a gsap newbie.

i have multiple animations going on some simultaneously on my onboarding page, but i noticed it places alot of load on my pc.

currently i stop some objects from animting by setting their opacity to zero which i think doesnt stop the animation in the background.

so please how do i stop an aniamtion especially when its done.

See the Pen KKQqGgW by Eraloop (@Eraloop) on CodePen

Link to comment
Share on other sites

That's correct - setting opacity to 0 on an element won't suddenly stop all of its animations.

 

The simplest way to stop all the animations for those particular elements would probably be: 

gsap.killTweensOf(".box");

Or you can save each tween (as variables or in an Array) and call .kill() on each one individually. 

 

I think you could simplify things a bit, like this (click to kill): 

See the Pen mdXwzGe?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Have fun!

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