Jump to content
Search Community

Prevent spamming Timeline

Korben Dallas 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

Hello everyone,

I'm creating an animated menu with CSS Grid / Greensock.

My animation is triggered by an event 'click'.

The animation run pretty well, but if the user spam click the open button for whatever reason, the animation repeat itself very strangely.

The solution I found is to not use Timeline, since they are repeated when we click multiple times on the open btn.

But i'm pretty sure there is a more elegant / convenient solution.

 

Can you give me a hand ? 

Thank's alot.

See the Pen GRKPbOr by Ziratsu (@Ziratsu) on CodePen

Link to comment
Share on other sites

Hey Enzo,

 

The biggest issue is that your timelines are in conflict with each other. Secondarily, instead of adding to the timeline each time the button is clicked. You should instead create a timeline animation when everything is initialized and then play(), reverse(), or tweenTo() depending on your needs.

 

You'll need to restructure your animation to handle conflicts or wait until the animations complete like Mikel suggested. 

 

I'd do something like this: 

 

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

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