Jump to content
GreenSock

buster808

OnClick reset animation before playing another.

Moderator Tag
Go to solution Solved by GreenSock,

Recommended Posts

Hi, I have two animations start and end,  How can I stop or reset end if I click start.

Want animations to work better if buttons are pressed quickly.

 

Thanks

See the Pen gOmazwa by buster808 (@buster808) on CodePen

Link to comment
Share on other sites

Tweens (and timelines) have a bunch of control methods you can use to... well... control them I guess. Some examples would be tween.play() tween.progress() or tween.kill()

You can read more about them in the docs 

In your case you could kill the previous tween, then recreate a tween with the correct stagger direction and play it?

See the Pen 2d6ff124460711653b7cbe1e9dd3961d?editors=0011 by cassie-codes (@cassie-codes) on CodePen

  • Like 2
Link to comment
Share on other sites

  • Solution

Another option is to set overwrite: true on your tween which will cause it to find all other tweens of the same target(s) and immediately kill them. Basically, you were creating conflicting tweens. 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

ah! That's a good one, I always forget that exists.

  • Like 1
  • 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.
×