---
title: Animation
slug: Web/API/Animation
tags:
- API
- Animations
- Animações da Web
- Experimental
- Interface
- Referencia
- api de animações da web
- waapi
translation_of: Web/API/Animation
---
{{ APIRef("Web Animations") }}{{SeeCompatTable}}
The Animation
interface of the Web Animations API represents a single animation player and provides playback controls and a timeline for an animation node or source.
Construtor
- {{domxref("Animation.Animation()", "Animation()")}}
- Creates a new
Animation
object instance.
Propriedades
- {{domxref("Animation.currentTime")}}
- The current time value of the animation in milliseconds, whether running or paused. If the animation lacks a {{domxref("AnimationTimeline", "timeline")}}, is inactive or hasn't been played yet, its value is
null
.
- {{domxref("Animation.effect")}}
- Gets and sets the {{domxref("AnimationEffectReadOnly")}} associated with this animation. This will usually be a {{domxref("KeyframeEffect")}} object.
- {{domxref("Animation.finished")}} {{readOnlyInline}}
- Returns the current finished Promise for this animation.
- {{domxref("Animation.id")}}
- Gets and sets the
String
used to identify the animation.
- {{domxref("Animation.pending")}} {{readonlyinline}}
- Indicates whether the animation is currently waiting for an asynchronous operation such as initiating playback or pausing a running animation.
- {{domxref("Animation.playState")}} {{readOnlyInline}}
- Returns an enumerated value describing the playback state of an animation.
- {{domxref("Animation.playbackRate")}}
- Gets or sets the playback rate of the animation.
- {{domxref("Animation.ready")}} {{readOnlyInline}}
- Returns the current ready Promise for this animation.
- {{domxref("Animation.startTime")}}
- Gets or sets the scheduled time when an animation's playback should begin.
- {{domxref("Animation.timeline")}}
- Gets or sets the {{domxref("AnimationTimeline", "timeline")}} associated with this animation.
Manipuladores de evento
- {{domxref("Animation.oncancel")}}
- Gets and sets the event handler for the
cancel
event.
- {{domxref("Animation.onfinish")}}
- Gets and sets the event handler for the
finish
event.
Métodos
- {{domxref("Animation.cancel()")}}
- Clears all {{domxref("KeyframeEffect", "keyframeEffects")}} caused by this animation and aborts its playback.
- {{domxref("Animation.finish()")}}
- Seeks either end of an animation, depending on whether the animation is playing or reversing.
- {{domxref("Animation.pause()")}}
- Suspends playing of an animation.
- {{domxref("Animation.play()")}}
- Starts or resumes playing of an animation, or begins the animation again if it previously finished.
- {{domxref("Animation.reverse()")}}
- Reverses playback direction, stopping at the start of the animation. If the animation is finished or unplayed, it will play from end to beginning.
- {{domxref("Animation.updatePlaybackRate()")}}
- Sets the speed of an animation after first synchronizing its playback position.
Preocupações de acessibilidade
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 to create a complimentary experience for users who have expressed a preference for no animated experiences.
Especificações
Especificação |
Estado |
Comentário |
{{SpecName("Web Animations", "#the-animation-interface", "Animation")}} |
{{Spec2("Web Animations")}} |
Initial definition |
Compatibilidade de navegador
{{Compat("api.Animation")}}