Jump to content

Ron Itelman

GSAP - killall equivalent?

Moderator Tag

Recommended Posts

Hello, looking at the api, the only kill function requires me to know which tween I wish to kill: https://greensock.com/docs/v3/GSAP/gsap.killTweensOf()

However, I have single page app and if a user were to click around before an animation is completed the animation continues (which doesn't make sense to the user). I would like to kill all running animations on any new view the user selects, without having to hard cord (and know in advance) every single possible set of animations I would need to kill.  Is there anyway to do this? This site is for demo purposes / prototyping only internally to our company so I'm focused on whatever is easiest as possible to not get random animations running as a user clicks through. Any suggestions are appreciated both in quick fixes or programmatic paradigms!

Link to comment
Share on other sites

Hey Ron. You can use .killTweensOf() to do that. Just pass in "*" as the target to select all DOM elements. Or a more scoped selector if you only want to kill the ones under a given section.

  • Like 3
Link to comment
Share on other sites

The only problem with the "*" solution is that'll only kill tweens of elements that can currently be found in the DOM, so if you truly want to kill all tweens I'd do something like this: 

gsap.globalTimeline.getChildren().forEach(t => t.kill());


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