Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
james182

GSAP Custom Checkbox Issue

Recommended Posts

I have the animation working on one checkbox but whene i add another both play. This should be simple to resolve but i can't figure it out.

I am trying to have it so the document is looked over for the checkboxes on the page an invoke the animation on individual checkboxes.

See the Pen oNzeJKO by james182 (@james182) on CodePen

Link to post
Share on other sites

Hey @james182

 

You are making one of the most common GSAP mistakes.

You are using a general selector, when instead you would want to loop over each item you want to animate individually.

What you also don't want to do is listen on the document for any change on any input-element, but listen to that specific's element's state instead. Does this make sense?

 

Here is an example of how to do that (with jquery, since you are using it).

 

See the Pen PoGJprq by akapowl (@akapowl) on CodePen

 

 

Also, your check for the checked-state of those checkboxes didn't quite seem to work, so just for this example, I set your timeline to reversed and check for the reversed state of the timeline with regard to animating it instead.

 

Hope this helps.

 

Cheers,

Paul

  • Like 4
  • Thanks 1
Link to post
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.

×