Jump to content
Search Community

Stop tween playing after click

Woj 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

I have a very simple animation. Hover over the left side and the dart shifts left. Hover over right and it shifts to the right. Upon click, the dart tweens to center of dart board. Pretty simple stuff. The issue I have is that after the dart tweens to the center of dart board is you mouseOff or mouseLeave the dart shifts back to the center position. I thought that setting the buttons visibility to hidden would work but it doesnt. Ive tried killing tweens. Im kind of stuck.

See the Pen eEEJpR by stevewojcik (@stevewojcik) on CodePen

Link to comment
Share on other sites

GSAP is going to use this function as the selector engine.

function $(id){return document.getElementById(id);}

 

To prevent GSAP from using that function, you can set the selector back to querySelectorAll.

TweenLite.selector = document.querySelectorAll.bind(document);

 

It's also better to use addEventListener and removeEventListener. See how I remove the listeners in the onClick function.

 

 

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