Interface Animation
currentTime: CSSNumberish | null;
effect: AnimationEffect | null;
finished: Promise<Animation>;
id: string;
oncancel: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null;
onfinish: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null;
onremove: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null;
pending: boolean;
playbackRate: number;
playState: AnimationPlayState;
ready: Promise<Animation>;
replaceState: AnimationReplaceState;
startTime: CSSNumberish | null;
timeline: AnimationTimeline | null;
addEventListener<K extends keyof AnimationEventMap>(
type: K,
listener: (this: Animation, ev: AnimationEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
cancel(): void;
commitStyles(): void;
dispatchEvent(event: Event): boolean;
finish(): void;
pause(): void;
persist(): void;
play(): void;
removeEventListener<K extends keyof AnimationEventMap>(
type: K,
listener: (this: Animation, ev: AnimationEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
reverse(): void;
updatePlaybackRate(playbackRate: number): void;
}
Hierarchy
- EventTarget
- Animation
Properties
currentTime
The Animation.currentTime property of the Web Animations API returns and sets the current time value of the animation in milliseconds, whether running or paused.
effect
The Animation.effect property of the Web Animations API gets and sets the target effect of an animation.
Readonlyfinished
The Animation.finished read-only property of the Web Animations API returns a Promise which resolves once the animation has finished playing.
id
The Animation.id property of the Web Animations API returns or sets a string used to identify the animation.
oncancel
onfinish
onremove
Readonlypending
The read-only Animation.pending property of the Web Animations API indicates whether the animation is currently waiting for an asynchronous operation such as initiating playback or pausing a running animation.
playbackRate
The Animation.playbackRate property of the Web Animations API returns or sets the playback rate of the animation.
ReadonlyplayState
The read-only Animation.playState property of the Web Animations API returns an enumerated value describing the playback state of an animation.
Readonlyready
The read-only Animation.ready property of the Web Animations API returns a Promise which resolves when the animation is ready to play.
ReadonlyreplaceState
The read-only Animation.replaceState property of the Web Animations API indicates whether the animation has been removed by the browser automatically after being replaced by another animation.
startTime
The Animation.startTime property of the Animation interface is a double-precision floating-point value which indicates the scheduled time when an animation's playback should begin.
timeline
The Animation.timeline property of the Animation interface returns or sets the AnimationTimeline associated with this animation.
Methods
addEventListener
- addEventListener<K extends keyof AnimationEventMap>(
type: K,
listener: (this: Animation, ev: AnimationEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends keyof AnimationEventMap
Parameters
- type: K
- listener: (this: Animation, ev: AnimationEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
- addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
cancel
The Web Animations API's
cancel()method of the Animation interface clears all KeyframeEffects caused by this animation and aborts its playback.Returns void
commitStyles
The
commitStyles()method of the Web Animations API's Animation interface writes the computed values of the animation's current styles into its target element'sstyleattribute.Returns void
dispatchEvent
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.Parameters
- event: Event
Returns boolean
finish
The
finish()method of the Web Animations API's Animation Interface sets the current playback time to the end of the animation corresponding to the current playback direction.Returns void
pause
The
pause()method of the Web Animations API's Animation interface suspends playback of the animation.Returns void
persist
The
persist()method of the Web Animations API's Animation interface explicitly persists an animation, preventing it from being automatically removed when it is replaced by another animation.Returns void
play
The
play()method of the Web Animations API's Animation Interface starts or resumes playing of an animation.Returns void
removeEventListener
- removeEventListener<K extends keyof AnimationEventMap>(
type: K,
listener: (this: Animation, ev: AnimationEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Type Parameters
- K extends keyof AnimationEventMap
Parameters
- type: K
- listener: (this: Animation, ev: AnimationEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
- removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
reverse
The
Animation.reverse()method of the Animation Interface reverses the playback direction, meaning the animation ends at its beginning.Returns void
updatePlaybackRate
The
updatePlaybackRate()method of the Web Animations API's synchronizing its playback position.Parameters
- playbackRate: number
Returns void
The
Animationinterface of the Web Animations API represents a single animation player and provides playback controls and a timeline for an animation node or source.MDN Reference