e01.org

Web Animations API

Web Animations

Web Animations

The **Web Animations API** allows for synchronizing and timing changes to the presentation of a Web page, i.e., animation of DOM elements. It does so by combining two models: the Timing Model and the Animation Model.

## Concepts and usage

The Web Animations API provides a common language for browsers and developers to describe animations on DOM elements. To get more information on the concepts behind the API and how to use it, read [Using the Web Animations API](/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API).

### Accessibility

Blinking and flashing animation can be problematic for people with cognitive concerns such as Attention Deficit Hyperactivity Disorder (ADHD). Additionally, certain kinds of motion can be a trigger for Vestibular disorders, epilepsy, and migraine, and Scotopic sensitivity.

Consider providing a mechanism for pausing or disabling animation, as well as using the [Reduced Motion Media Query](/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion) (or equivalent [user agent client hint](/docs/Web/HTTP/Guides/Client_hints#user_agent_client_hints) Sec-CH-Prefers-Reduced-Motion) to create a complementary experience for users who have expressed a preference for no animated experiences.

- [Designing Safer Web Animation For Motion Sensitivity · An A List Apart Article](https://alistapart.com/article/designing-safer-web-animation-for-motion-sensitivity/)
- [An Introduction to the Reduced Motion Media Query | CSS-Tricks](https://css-tricks.com/introduction-reduced-motion-media-query/)
- [Responsive Design for Motion | WebKit](https://webkit.org/blog/7551/responsive-design-for-motion/)
- [MDN Understanding WCAG, Guideline 2.2 explanations](/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable#guideline_2.2_%e2%80%94_enough_time_provide_users_enough_time_to_read_and_use_content)
- [Understanding Success Criterion 2.2.2 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/time-limits-pause.html)

## Web Animations interfaces

- Animation
- : Provides playback controls and a timeline for an animation node or source. Can take an object created with the KeyframeEffect() constructor.
- KeyframeEffect
- : Describes sets of animatable properties and values, called **keyframes** and their timing options. These can then be played using the Animation() constructor.
- AnimationTimeline
- : Represents the timeline of animation. This interface exists to define timeline features (inherited by DocumentTimeline and future timeline objects) and is not itself accessed by developers.
- AnimationEvent
- : Part of the [CSS Animations](/docs/Web/CSS/Guides/Animations) module, capturing the animation name and elapsed time.
- DocumentTimeline
- : Represents animation timelines, including the default document timeline (accessed using the Document.timeline property).

## Extensions to other interfaces

The Web Animations API adds features to document and element.

### Extensions to the `Document` interface

- document.timeline
- : The `DocumentTimeline` object representing the default document timeline.
- document.getAnimations()
- : Returns an Array of Animation objects currently in effect on elements in the `document`.

### Extensions to the `Element` interface

- Element.animate()
- : A shortcut method for creating and playing an animation on an element. It returns the created Animation object instance.
- Element.getAnimations()
- : Returns an Array of Animation objects currently affecting an element or which are scheduled to do so in the future.

## Specifications

## See also

- CSS animation shorthand property
- CSS animation-timeline property
- [Using the Web Animations API](/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API)
- [Using CSS animations](/docs/Web/CSS/Guides/Animations/Using)
- [CSS animations](/docs/Web/CSS/Guides/Animations) module
- [CSS scroll-driven animations](/docs/Web/CSS/Guides/Scroll-driven_animations) module

source: MDN Web Docs mirror · page

Cite this

"Web Animations API". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API

JSON record · API collection · citation policy