dubfonik Posted December 11, 2020 Share Posted December 11, 2020 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 More sharing options...
Solution akapowl Posted December 11, 2020 Solution Share Posted December 11, 2020 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. 4 Link to comment Share on other sites More sharing options...
dubfonik Posted December 12, 2020 Author Share Posted December 12, 2020 That makes perfect sense now! Thanks a lot @akapowl Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now