animate
Commons
stable
Safe wrapper around the Web Animations API. Falls back to a resolved-promise stub when the browser does not support Element.animate() or when an exception is thrown.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- elrequiredElement
- The DOM element to animate.
- keyframesrequiredArray<Keyframe> | PropertyIndexedKeyframes | null
- Keyframe descriptors in WAAPI format — either an array of Keyframe objects or a property-indexed object.
- optionsnumber | KeyframeAnimationOptions
- Duration in milliseconds (number) or a full KeyframeAnimationOptions object controlling easing, delay, fill, etc.
API
Return value
The value returned by this util.
- The native Animation object, or a stub with a resolved finished promise when the API is unavailable.
Usage
Examples
Ready-to-paste usage snippets.
Fade-in an element