Jump to content
Search Community

Enable/Disable animation based on isTweening

ektorp test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi - I simply want to set an animation based on whether or not it is currently animating. I see GSAP's isTweening but it does not seem to be working as expected. In my simple CodePen example, I simply want to click the button and then show the box, and then click anywhere on the document or page, to then hide or fade out the box. If you click the button super fast multiple times it does then seem to work. So I think there is some basic step in this simple request that I am missing. Any help would be greatly appreciated.

See the Pen ZEvVweM by pen (@pen) on CodePen

Link to comment
Share on other sites

  • Solution

This has to do with event bubbling. A click on the "#show" button IS a click on the document. If you put a console.log() inside each event handler, you'll see that when you click on the "show box" button it triggers BOTH event handlers. That has nothing to do with GSAP - it's just a logic thing in your code. 

 

There are a lot of ways you could do this. Here's just one: 

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

 

Does that help? 

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