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.

typescript

API

Parameters

Input parameters accepted by this util.

el
required
Element
The DOM element to animate.
keyframes
required
Array<Keyframe> | PropertyIndexedKeyframes | null
Keyframe descriptors in WAAPI format — either an array of Keyframe objects or a property-indexed object.
options
number | 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

typescript