Jump to content
Search Community

Kill/prevent running of stagger if toggle/trigger on/off is fired too rapidly

aok test
Moderator Tag

Go to solution Solved by mikel,

Recommended Posts

I always tend to have a problem when I fire a gsap stagger/animation from a toggle (run when toggle on and kill/stop when toggle off) as if the user toggles super quickly (exhaustive testing) it won't kill/clear in time etc and I'm left with some items staggered in and others not.

 

My thinking would be to create some sort of timeout to prevent this but I'm not sure. This is what I have for my stagger.

 

staggerMenuItems: function(open, $elem) {

	let $elems = $elem.querySelectorAll('li');

	if (open) {
		gsap.to($elems, {
			visibility: 'visible',
			stagger: -0.5,
			delay: 0.5
		});
	} else {
		gsap.set($elems, {
			clearProps: 'all'
		});
	}
}

 

Any thoughts on how to improve this?

See the Pen GRjPZOK by richardcool (@richardcool) on CodePen

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