Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Use requestAnimationFrame's build in high precision timestamp #22

Closed

Conversation

GordoRank
Copy link

requestAnimationFrame passes back a high.precision timestamp which is far more accurate than Date.now() Switch to this to improve animations smoothness and accuracy.

requestAnimationFrame passes back a high.precision timestamp which is far more accurate than ```Date.now()``` Switch to this to improve animations smoothness and accuracy.
@oori
Copy link

oori commented Aug 13, 2016

Yeap! here's the related discussion: jquery/jquery#3143
Safer alternative would be:

 _this.springSystem.loop(timeStamp || Date.now());

wbinnssmith pushed a commit that referenced this pull request Feb 28, 2018
This uses performance.now (or a fallback to Date.now in environments
without it) to provide a more accurate measurement of time while
animating, which should result in smoother animations.

Deliberately use this rather than using `requestAnimationFrame`'s
callback's argument as it can sometimes misrepresent the current time.
[See its use in
velocity](https://github.com/julianshapiro/velocity/blob/92f6981723e51895855812366739a04fef93176b/src/Velocity/tick.ts#L158-L160).

Supercedes #22.
wbinnssmith pushed a commit that referenced this pull request Feb 28, 2018
This uses performance.now (or a fallback to Date.now in environments
without it) to provide a more accurate measurement of time while
animating, which should result in smoother animations.

Deliberately use this rather than using `requestAnimationFrame`'s
callback's argument as it can sometimes misrepresent the current time.
[See its use in
velocity](https://github.com/julianshapiro/velocity/blob/92f6981723e51895855812366739a04fef93176b/src/Velocity/tick.ts#L158-L160).

Supercedes #22.
@wbinnssmith
Copy link
Contributor

This is resolved by #47 🎉

thanks for your motivation and your patch :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants