CSSAnimation
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
TheCSSAnimation
interface of theWeb Animations API represents anAnimation
object.
In this article
Instance properties
This interface inherits properties from its parent,Animation
.
CSSAnimation.animationName
Read onlyReturns the animation name as a string.
Instance methods
This interface inherits methods from its parent,Animation
.
Examples
>Inspecting the returned CSSAnimation
The animation in the following example is defined in CSS with the nameslide-in
. CallingElement.getAnimations()
returns an array of allAnimation
objects. In our case this returns aCSSAnimation
object, representing the animation created in CSS.
css
.animate { animation: slide-in 0.7s both;}@keyframes slide-in { 0% { transform: translateY(-1000px); } 100% { transform: translateY(0); }}
js
let animations = document.querySelector(".animate").getAnimations();console.log(animations[0]);
Specifications
Specification |
---|
CSS Animations Level 2> # the-CSSAnimation-interface> |
Browser compatibility
Loading…