Jump to content
Search Community

Detect the number of clicks and run play() accordingly

momo12 test
Moderator Tag

Go to solution Solved by momo12,

Recommended Posts

  • Solution

Sorry guys,

 

I have a few gsap.timelines(); I want to animate something when user clicks on a button for the first time (It will use A as GSAP.timeline()) and if user clicks on a button for the second time (It will use B as GSAP.timeline()).

 

The problem I have is what should I do if user clicks continously? Third and fourth and ...! I use this code but doesn't work for some reasons!

var clicks = 0;
$(".m-btn").click(function() {
    if (clicks % 2 == 0)
    {
         tl.play("spin");
    } 
    else
      {
          tl.play("spinn");
      }
     clicks++;
});


Found the problem! Added GSAP a few times caused the issue :)

Link to comment
Share on other sites

  • momo12 changed the title to Detect the number of clicks and run play() accordingly

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