Anime class provides a fluent interface for creating animations using Anime.js library. It simplifies the process of defining and executing animations with a chainable API.
Overview
The Anime class wraps the popular Anime.js animation library, providing a convenient way to create animations with sensible defaults and a chainable method pattern.Constructor
Target element(s) to animate
Initial animation configuration options
Default options
The Anime class initializes with these default settings:Configuration methods
setOptions
Merges custom options with current animation options.Animation options to merge
duration
Sets the animation duration in milliseconds.Duration in milliseconds
delay
Sets the animation delay.Delay in milliseconds or function returning delay
easing
Sets the animation easing function.Easing function name (see Anime.js documentation)
Transform methods
opacity
Animates element opacity.Target opacity value or [from, to] array
scale
Animates element scale.Scale value or [from, to] array
translateX
Animates horizontal translation.Translation value (pixels or percentage)
translateY
Animates vertical translation.Translation value (pixels or percentage)
Layout methods
height
Animates element height.Height value or [from, to] array
margin
Animates element margin.Margin value or [from, to] array
paddingTop
Animates top padding.Padding value or [from, to] array
paddingBottom
Animates bottom padding.Padding value or [from, to] array
Advanced methods
stagger
Creates a staggered delay for multiple elements.Stagger interval in milliseconds
complete
Sets a callback function to execute when animation completes.Callback function
set
Generic method to set any animation property.Property name
Property value
play
Executes the animation with all configured options.Usage examples
Basic fade in animation
Staggered list animation
Scale and fade animation
Slide in from left
Global access
The Anime.js library is also available globally:While the global
anime object provides direct access to Anime.js, using the Anime class wrapper provides a more consistent API and chainable methods.