tween.js
tween.js copied to clipboard
Slow down the tween on update
Hey,
I am currently moving an object with a tween, and i would like to slow down the tween when the mouse is upon it.
What did i try :
- Raise the tween duration when mouse is upon it inside the update function (threw
tween.duration()function) - Change the update time parameter
But i couldn't figure it out yet. Like the timeScale function from GSAP I would be more than grateful for any help
Thanks a lot
Tween.js doesn't have time management built in (it would be cool to add though!). You have the right idea. You'll need to either
- stop the current tween when mouse enters and make a new tween with new starting point and new
tovalues. It can become more verbose to make multiple tweens. - or adjust the time values that you pass into the
updatecalls. F.e. when no mouse, passpreviousTime + deltaTime, and when the mouse enters, passpreviousTime + deltaTime / 2to make it play at half speed.
If you figure it out, it would be interesting to know how you do it. Maybe we can come up with something to add to Tween.js.