Jump to content
Search Community

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

Catalin R.
Posted

Hi,

I have a timelineMax which runs on a click event.

What is the best way to prevent to run the timelineMax again until the animation is completed?

Thanks!

Shaun Gorneau
Posted

There are a few ways you can do this ... one simple way is to set a global boolean, modify it within the click handler, and then modify it within the timeline's onComplete callback.

 

See the Pen KRxqvz by sgorneau (@sgorneau) on CodePen.

 

  • Like 5
Catalin R.
Posted (edited)

Hi Shaun,

I've made a codepen with my case:

See the Pen BrZKGJ by ZenTao (@ZenTao) on CodePen.

When I click an icon I want to do something with those divs "animateMe" and "fading". Is there any possibility to prevent to run the timelineMax again until the animation is completed?

https://codepen.io/ZenTao/pen/BrZKGJ

Thanks

Edited by DevSaver
Give a link to codepen
Posted

I'm not sure if Shaun will be online again today so I'll jump back in. It looks like you're using GSAP to set() a new class name on click, but that class is a CSS transition? That may cause problems as mixing the two will many times result in a fight for control of the element.

 

I don't think we understood you wanted to do this with multiple elements in a jQuery each() loop. Here's a basic demo of creating a timeline for each() jQuery element and checking a global variable to see if a click should allow the timeline to play. 

 

See the Pen rvZKVg by PointC (@PointC) on CodePen.

 

Hopefully that helps. Happy tweening.

:)

 

 

 

  • Like 5
Posted

Great demo, Craig. I love how little code there is and how you take the time to make these so nicely responsive too ;)

  • Like 3

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