Jump to content
Search Community

Make element go to end or start of timeline if retriggered

dubfonik test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

If you click the trigger and let the animation play completely there is no problem. However, if you click it again before the animation ends the element gets "stuck" at the point it was retriggered from. This is even more apparent if you click the trigger multiple times fast

 

What would be the best way to fix this?

See the Pen NWRbvXE by joelklease (@joelklease) on CodePen

Link to comment
Share on other sites

  • Solution

 

Hey @dubfonik

 

What you experience, happens because on click you create new tweens on that same element over and over again.

 

Instead, you should create a tween beforehand, store it in a variable, and on click only control the (play-)state of that tween.

 

To make it restart from 0 everytime you click, you could use .play(0) or .restart().

 

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

 

 

Cheers, Paul.

 

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