Jump to content
Search Community

Prevent an event-triggered timeline being queued if event is triggered while animation is in progress

alan0buchanan test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

In my Codepen example, there is a gold circle. When you click the gold circle, it moves around the page using `x` and `y`.

 

If you click the circle while it's moving around, another timeline animation for the circle gets queued and runs after the initial one has finished.

 

I want to prevent this behaviour. My instinct tells me to use lodash `throttle`, but I feel there should be a better way to do this, especially as I would need the duration of the animation to use a throttle.

 

I want any click to the circle to have no effect if the animation is in progress. Is there a `TimelineMax` method I can use to achieve this?

See the Pen gROvjG by alanbuchanan (@alanbuchanan) 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...