Animation APIs

See below to learn more about properties, slots, events, style variables, CSS parts, and methods.

There is no difference between the APIs of the elements, And the only difference is in the names of the events

Properties

Name
composite
Type
'add' | 'accumulate' | 'replace'
Default
'replace'
Attribute
composite
Reflect
false
Description

Determines how values are combined between this animation and other, separate animations that do not specify their own specific composite operation.

Name
delay
Type
number
Default
0
Attribute
delay
Reflect
false
Description

The number of milliseconds to delay the start of the animation.

Name
direction
Type
'alternate-reverse' | 'alternate' | 'normal' | 'reverse'
Default
'normal'
Attribute
direction
Reflect
false
Description

Whether the animation runs forwards (normal), backwards (reverse), switches direction after each iteration (alternate), or runs backwards and switches direction after each iteration (alternate-reverse).

Name
duration
Type
number
Default
1000
Attribute
duration
Reflect
false
Description

The number of milliseconds each iteration of the animation takes to complete. Keep in mind that your animation will not run if this value is 0.

Name
easing
Type
string
Default
'linear'
Attribute
easing
Reflect
false
Description

The rate of the animation's change over time. Accepts the pre-defined values "linear", "ease", "ease-in", "ease-out", and "ease-in-out", or a custom "cubic-bezier" value like "cubic-bezier(0.42, 0, 0.58, 1)".

Name
endDelay
Type
number
Default
0
Attribute
end-delay
Reflect
false
Description

The number of milliseconds to delay after the end of an animation. This is primarily of use when sequencing animations based on the end time of another animation.

Name
fill
Type
'backwards' | 'forwards' | 'none'
Default
'none'
Attribute
fill
Reflect
false
Description

Dictates whether the animation's effects should be reflected by the element(s) prior to playing ("backwards"), retained after the animation has completed playing ("forwards"), or both.

Name
instance
Type
globalThis.Animation
Default
undefined
Attribute
instance
Reflect
false
Description

The Animation object instance.

Name
iterationComposite
Type
'accumulate' | 'replace'
Default
'replace'
Attribute
iteration-composite
Reflect
false
Description

Determines how values build from iteration to iteration in this animation. Can be set to accumulate or replace.

Name
iterations
Type
number
Default
1
Attribute
iterations
Reflect
false
Description

The number of times the animation should repeat. And can also take a value of Infinity to make it repeat for as long as the element exists.

Name
iterationStart
Type
number
Default
0
Attribute
iteration-start
Reflect
false
Description

Describes at what point in the iteration the animation should start. 0.5 would indicate starting halfway through the first iteration for example, and with this value set, an animation with 2 iterations would end halfway through a third iteration.

Name
keyframes
Type
Keyframe[]
Default
undefined
Attribute
keyframes
Reflect
false
Description

A keyframes object or null.

Name
name
Default
undefined
Attribute
name
Reflect
false
Description

Specifies what kind of animation will play. The list of available animations is here.

Name
playbackRate
Type
number
Default
1
Attribute
playback-rate
Reflect
false
Description

Sets the animation's playback rate.

Name
run
Type
boolean
Default
undefined
Attribute
run
Reflect
true
Description

Starts the animation.

Name
overrides
Default
undefined
Attribute
overrides
Reflect
false
Description

Overrides default configuration for specific breakpoints. See Overrides for details.

Name
variant
Default
undefined
Attribute
variant
Reflect
true
Description

See Variant for details.

Slots

Name
default
Description

The default slot.

Events

Name
plus-cancel
Type
EventEmitter<void>
Cancelable
false
Description

Fires when the Animation.cancel() method is called or when the animation enters the "idle" play state from another state.

Name
plus-finish
Type
EventEmitter<void>
Cancelable
false
Description

Fires when the animation finishes playing.

Name
plus-remove
Type
EventEmitter<void>
Cancelable
false
Description

Fires when the animation is removed (i.e., put into an active replace state).

CSS Variables

There are no CSS Variables.

CSS Parts

There are no CSS Parts.

Methods

Name
cancel
Type
void
Signature
cancel() => void
Description

Clears all keyframeEffects caused by this animation and aborts its playback.

Name
commitStyles
Type
void
Signature
commitStyles() => void
Description

Commits the end styling state of an animation to the element being animated, even after that animation has been removed. It will cause the end styling state to be written to the element being animated, in the form of properties inside a style attribute.

Name
finish
Type
void
Signature
finish() => void
Description

Seeks either end of an animation, depending on whether the animation is playing or reversing.

Name
pause
Type
void
Signature
pause() => void
Description

Suspends playing of an animation.

Name
persist
Type
void
Signature
persist() => void
Description

Explicitly persists an animation, when it would otherwise be removed due to the browser's Automatically removing filling animations behavior.

Name
play
Type
void
Signature
play() => void
Description

Starts or resumes playing of an animation, or begins the animation again if it previously finished.

Name
reverse
Type
void
Signature
reverse() => void
Description

Reverses playback direction, stopping at the start of the animation. If the animation is finished or unplayed, it will play from end to beginning.

Name
updatePlaybackRate
Type
void
Signature
updatePlaybackRate(playbackRate: number) => void
Description

Sets the speed of an animation after first synchronizing its playback position.