jeremyckahn / shifty

The fastest TypeScript animation engine on the web
https://jeremyckahn.github.io/shifty/doc/
MIT License
1.54k stars 88 forks source link

Don't retriggers handler when seeking to the same frame #62

Closed SBoudrias closed 9 years ago

SBoudrias commented 9 years ago

When seeking through a tweenable, I think it would make sense to not triggers the step handlers if there's no change at the time head.

For example:

tween.seek(15);
// This is triggering the step handler as expected.

// Then some time later
tween.seek(15);
// As we're still at the same position, we shouldn't triggers the handlers again

This is easily handled by user side code, but handling this on the side of shifty would make user code cleaner and probably helps to silently improve performances.

jeremyckahn commented 9 years ago

Good call, I'll get to this soon!

SBoudrias commented 9 years ago

Actually, this is not so easy to handle user side - even more in the setup we have on Yelp where we coordinates multiples tween based off a single one. So yeah, having this by default inside shifty would be very helpful!

jeremyckahn commented 9 years ago

This should be pretty straightforward to do. I don't have time to implement and test this now, but hopefully in the next day or so. If you need this sooner, feel free to make a Pull Request.

jeremyckahn commented 9 years ago

Okay, now I actually referenced the correct issue. Please test this out when you can and let me know if it's working for you.

jeremyckahn commented 9 years ago

@SBoudrias, did you get a chance to test out this fix?

SBoudrias commented 9 years ago

Not yet, we have a bad infrastructure for open source third parties, so it's pretty involving. I should have some time to check it out next week.

SBoudrias commented 9 years ago

Hey @jeremyckahn, sorry this took so long! Finally got around to test it on Yelp and the fix is resolving the issue described here.

jeremyckahn commented 9 years ago

No problem. I've merged the fix into master, and it is available as version 1.3.11. Thanks for your help!