AnimationTimeline: currentTime property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
ThecurrentTime read-only property of theWeb Animations API'sAnimationTimeline interface returns the timeline's current time in milliseconds, ornull if the timeline is inactive.
In this article
Value
A number representing the timeline's current time in milliseconds, ornull if the timeline is inactive.
Reduced time precision
To offer protection against timing attacks andfingerprinting, the precision ofanimationTimeline.currentTime might get rounded depending on browser settings. In Firefox, theprivacy.reduceTimerPrecision preference is enabled by default and defaults to 2ms. You can also enableprivacy.resistFingerprinting, in which case the precision will be 100ms or the value ofprivacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.
For example, with reduced time precision, the result ofanimationTimeline.currentTime will always be a multiple of 0.002, or a multiple of 0.1 (orprivacy.resistFingerprinting.reduceTimerPrecision.microseconds) withprivacy.resistFingerprinting enabled.
// reduced time precision (2ms) in Firefox 60animationTimeline.currentTime;// Might be:// 23.404// 24.192// 25.514// …// reduced time precision with `privacy.resistFingerprinting` enabledanimationTimeline.currentTime;// Might be:// 49.8// 50.6// 51.7// …Specifications
| Specification |
|---|
| Web Animations> # dom-animationtimeline-currenttime> |
Browser compatibility
See also
- Web Animations API
AnimationTimelineDocumentTimelineinherits this propertyDocument.timelinereturns a timeline object which inherits this property