anime.js (v4)
anime.js is a fast, lightweight JavaScript animation
library with a small, composable API. v4 is a ground-up rewrite: it is
modular and ESM-first — you import named functions (animate,
createTimeline, …) rather than calling a single default anime() object as in
v3. Always write v4-style code unless the user explicitly pins v3.
When to use this skill
- "Animate this element / these cards / this SVG."
- "Make a timeline that sequences several animations."
- "Add a staggered entrance / scroll-reveal / hover effect."
- "Morph this SVG path into that one" or "draw this SVG line on scroll."
- "Make this element draggable with momentum / springy motion."
- "Animate text in character by character."
- Any request to add motion to a web page, or to debug/upgrade existing anime.js.
If the user is on v3 (default anime({...}) syntax) and wants to upgrade,
see the Migration notes below.
Install / import
npm (recommended, ESM):
npm install animejs
import { animate, createTimeline, stagger, svg, utils } from 'animejs';
CDN — ES modules (no build step):
<script type="module">
import { animate, stagger } from 'https://esm.sh/animejs@4';
animate('.box', { x: 200, duration: 800 });
</script>
CDN — classic UMD global (anime namespace; methods hang off it):
<script src="https://cdn.jsdelivr.net/npm/animejs@4"></script>
<script>
anime.animate('.box', { x: 200, rotate: '1turn', duration: 800 });
</script>
TypeScript types ship with the package — no @types needed.
Core mental model
Every animatable thing is created by a factory function that returns an object
with playback controls (.play(), .pause(), .restart(), .seek(),
.reverse(), plus a .then()/completed promise). You target CSS
selectors, DOM nodes, NodeLists, or plain JS objects.
animate(targets, {
// properties to animate (CSS, transforms, attributes, or object keys)
x: 320, // translateX shorthand
rotate: { from: -180 }, // per-property keyframe object
opacity: [0, 1], // [from, to]
// timing & behavior
duration: 1250,
delay: stagger(65, { from: 'center' }),
ease: 'inOutQuint',
loop: true,
alternate: true,
// callbacks
onComplete: self => console.log('done', self),
});
Key shorthands: x/y/z (translate), rotate, scale, skew. Values can be
numbers (px assumed), units ('50%', '2rem', '1turn'), [from, to] arrays,
{ from, to } objects, function values (el, i) => ..., or relative strings
('+=100').
The v4 modules
| Import |
Use it for |
animate(targets, params) |
The workhorse — animate CSS, transforms, attributes, or JS object properties. |
createTimeline(params) |
Sequence/overlap multiple animations with precise offsets via .add()/.sync(). |
createTimer(params) |
A standalone clock (no targets) with onUpdate/onComplete — great for counters and game loops. |
createAnimatable(target, params) |
A persistent handle for high-frequency updates (e.g. cursor-follow) without re-creating animations. |
createDraggable(target, params) |
Drag interactions with inertia, snapping, and bounds. |
createScope({ root, mediaQueries }) |
Scope animations to a root element + responsive media queries; .revert() cleans them all up (ideal for React/Vue effects). |
onScroll(params) / scroll thresholds |
Drive or trigger animations from scroll position (enter/leave, sync). Pass as a delay/autoplay or use directly. |
svg.morphTo, svg.createDrawable, svg.createMotionPath |
SVG path morphing, line-drawing (stroke dash), and motion-path following. |
text.split |
Split text into lines/words/chars for per-character stagger. |
stagger(value, opts) |
Generate incremental delays/values across targets (from, grid, ease, range). |
utils |
Helpers: $ (select), get/set, remove, clamp, mapRange, lerp, round, random, snap. |
eases / createSpring |
Easing functions and spring physics generators. |
engine |
Global config: engine.timeUnit, engine.fps, engine.speed, pause-on-tab-blur. |
waapi |
Render via the native Web Animations API (waapi.animate) for GPU-offloaded transforms. |
For concrete, copy-pasteable snippets of each module, read
reference.md. A complete runnable demo (CDN, no build) is in
examples/index.html.
Common recipes
Timeline (sequence + overlap):
import { createTimeline, stagger } from 'animejs';
const tl = createTimeline({ defaults: { duration: 600, ease: 'outQuad' } });
tl.add('.title', { y: [40, 0], opacity: [0, 1] })
.add('.card', { scale: [0.8, 1], opacity: [0, 1], delay: stagger(80) }, '-=200') // overlap by 200ms
.add('.cta', { opacity: [0, 1] });
Stagger grid:
animate('.cell', {
scale: [0, 1],
delay: stagger(50, { grid: [10, 10], from: 'center' }),
});
Scroll-triggered reveal:
import { animate, onScroll } from 'animejs';
animate('.section', {
opacity: [0, 1], y: [50, 0],
autoplay: onScroll({ enter: 'bottom-=100 top', sync: 0.5 }),
});
SVG line drawing:
import { animate, svg } from 'animejs';
animate(svg.createDrawable('.path'), { draw: '0 1', duration: 2000, ease: 'inOutQuad' });
Draggable with physics:
import { createDraggable } from 'animejs';
createDraggable('.box', { container: '.bounds', releaseStiffness: 40, snap: 50 });
Migrating from v3
- v3
anime({ targets, ... }) → v4 animate(targets, { ... }) (targets is the
first arg, not a param).
- v3
easing: 'easeInOutQuad' → v4 ease: 'inOutQuad' (renamed + shorter names).
- v3
anime.timeline() → v4 createTimeline(); .add(params, offset) →
.add(targets, params, offset).
- v3
anime.stagger() → v4 stagger() (named import).
- v3
anime.set() / anime.random() → v4 utils.set() / utils.random().
loop/direction: 'alternate' → loop + alternate: true.
- Full guide: https://animejs.com/documentation/migrating-from-v3.
Tips & gotchas
- Prefer transforms (
x, y, scale, rotate) and opacity for smooth,
GPU-friendly motion; animating width/top/left triggers layout.
- Use
ease: createSpring({ stiffness, damping }) for natural motion instead of
guessing cubic-bezier values.
- In React/Vue/Svelte, wrap creation in an effect and call
scope.revert() (or the returned animation's .revert()) on cleanup so you
don't leak timers across re-renders. createScope exists for exactly this.
- Respect
prefers-reduced-motion: gate non-essential animation behind a media
query check.
- Animations autoplay by default; pass
autoplay: false and call .play()
to control timing, or autoplay: onScroll(...) to tie it to scroll.
Credits
Powered by anime.js (v4, MIT) by
Julian Garnier. This skill documents and wraps the library for the Claude
Agent Skills format; all credit for the animation engine belongs to its author
and contributors.
1---2name: animejs3description: Build web animations with anime.js v4 — a fast, lightweight JavaScript animation library. Use this skill whenever the user wants to animate DOM elements, CSS properties, SVG (morphing, line drawing, motion paths), or plain JS objects; build timelines, staggered effects, scroll-triggered animations, draggable elements, spring physics, or animated text. Covers the v4 module API (animate, createTimeline, createTimer, createDraggable, onScroll, svg, text, stagger, utils, eases) and how to install it via npm or a CDN.4license: MIT5---67# anime.js (v4)89[anime.js](https://animejs.com) is a fast, lightweight JavaScript animation10library with a small, composable API. **v4** is a ground-up rewrite: it is11**modular and ESM-first** — you import named functions (`animate`,12`createTimeline`, …) rather than calling a single default `anime()` object as in13v3. Always write v4-style code unless the user explicitly pins v3.1415## When to use this skill1617- "Animate this element / these cards / this SVG."18- "Make a timeline that sequences several animations."19- "Add a staggered entrance / scroll-reveal / hover effect."20- "Morph this SVG path into that one" or "draw this SVG line on scroll."21- "Make this element draggable with momentum / springy motion."22- "Animate text in character by character."23- Any request to add motion to a web page, or to debug/upgrade existing anime.js.2425If the user is on **v3** (default `anime({...})` syntax) and wants to upgrade,26see the [Migration](#migrating-from-v3) notes below.2728## Install / import2930**npm (recommended, ESM):**3132```bash33npm install animejs34```3536```js37import { animate, createTimeline, stagger, svg, utils } from 'animejs';38```3940**CDN — ES modules (no build step):**4142```html43<script type="module">44 import { animate, stagger } from 'https://esm.sh/animejs@4';45 animate('.box', { x: 200, duration: 800 });46</script>47```4849**CDN — classic UMD global** (`anime` namespace; methods hang off it):5051```html52<script src="https://cdn.jsdelivr.net/npm/animejs@4"></script>53<script>54 anime.animate('.box', { x: 200, rotate: '1turn', duration: 800 });55</script>56```5758TypeScript types ship with the package — no `@types` needed.5960## Core mental model6162Every animatable thing is created by a factory function that returns an object63with **playback controls** (`.play()`, `.pause()`, `.restart()`, `.seek()`,64`.reverse()`, plus a `.then()`/`completed` promise). You target **CSS65selectors, DOM nodes, NodeLists, or plain JS objects**.6667```js68animate(targets, {69 // properties to animate (CSS, transforms, attributes, or object keys)70 x: 320, // translateX shorthand71 rotate: { from: -180 }, // per-property keyframe object72 opacity: [0, 1], // [from, to]73 // timing & behavior74 duration: 1250,75 delay: stagger(65, { from: 'center' }),76 ease: 'inOutQuint',77 loop: true,78 alternate: true,79 // callbacks80 onComplete: self => console.log('done', self),81});82```8384Key shorthands: `x`/`y`/`z` (translate), `rotate`, `scale`, `skew`. Values can be85numbers (px assumed), units (`'50%'`, `'2rem'`, `'1turn'`), `[from, to]` arrays,86`{ from, to }` objects, function values `(el, i) => ...`, or relative strings87(`'+=100'`).8889## The v4 modules9091| Import | Use it for |92|---|---|93| `animate(targets, params)` | The workhorse — animate CSS, transforms, attributes, or JS object properties. |94| `createTimeline(params)` | Sequence/overlap multiple animations with precise offsets via `.add()`/`.sync()`. |95| `createTimer(params)` | A standalone clock (no targets) with `onUpdate`/`onComplete` — great for counters and game loops. |96| `createAnimatable(target, params)` | A persistent handle for high-frequency updates (e.g. cursor-follow) without re-creating animations. |97| `createDraggable(target, params)` | Drag interactions with inertia, snapping, and bounds. |98| `createScope({ root, mediaQueries })` | Scope animations to a root element + responsive media queries; `.revert()` cleans them all up (ideal for React/Vue effects). |99| `onScroll(params)` / scroll thresholds | Drive or trigger animations from scroll position (`enter`/`leave`, `sync`). Pass as a `delay`/`autoplay` or use directly. |100| `svg.morphTo`, `svg.createDrawable`, `svg.createMotionPath` | SVG path morphing, line-drawing (stroke dash), and motion-path following. |101| `text.split` | Split text into lines/words/chars for per-character stagger. |102| `stagger(value, opts)` | Generate incremental delays/values across targets (`from`, `grid`, `ease`, `range`). |103| `utils` | Helpers: `$` (select), `get`/`set`, `remove`, `clamp`, `mapRange`, `lerp`, `round`, `random`, `snap`. |104| `eases` / `createSpring` | Easing functions and spring physics generators. |105| `engine` | Global config: `engine.timeUnit`, `engine.fps`, `engine.speed`, pause-on-tab-blur. |106| `waapi` | Render via the native Web Animations API (`waapi.animate`) for GPU-offloaded transforms. |107108For concrete, copy-pasteable snippets of each module, read109[`reference.md`](reference.md). A complete runnable demo (CDN, no build) is in110[`examples/index.html`](examples/index.html).111112## Common recipes113114**Timeline (sequence + overlap):**115116```js117import { createTimeline, stagger } from 'animejs';118119const tl = createTimeline({ defaults: { duration: 600, ease: 'outQuad' } });120tl.add('.title', { y: [40, 0], opacity: [0, 1] })121 .add('.card', { scale: [0.8, 1], opacity: [0, 1], delay: stagger(80) }, '-=200') // overlap by 200ms122 .add('.cta', { opacity: [0, 1] });123```124125**Stagger grid:**126127```js128animate('.cell', {129 scale: [0, 1],130 delay: stagger(50, { grid: [10, 10], from: 'center' }),131});132```133134**Scroll-triggered reveal:**135136```js137import { animate, onScroll } from 'animejs';138animate('.section', {139 opacity: [0, 1], y: [50, 0],140 autoplay: onScroll({ enter: 'bottom-=100 top', sync: 0.5 }),141});142```143144**SVG line drawing:**145146```js147import { animate, svg } from 'animejs';148animate(svg.createDrawable('.path'), { draw: '0 1', duration: 2000, ease: 'inOutQuad' });149```150151**Draggable with physics:**152153```js154import { createDraggable } from 'animejs';155createDraggable('.box', { container: '.bounds', releaseStiffness: 40, snap: 50 });156```157158## Migrating from v3159160- v3 `anime({ targets, ... })` → v4 `animate(targets, { ... })` (targets is the161 first arg, not a param).162- v3 `easing: 'easeInOutQuad'` → v4 `ease: 'inOutQuad'` (renamed + shorter names).163- v3 `anime.timeline()` → v4 `createTimeline()`; `.add(params, offset)` →164 `.add(targets, params, offset)`.165- v3 `anime.stagger()` → v4 `stagger()` (named import).166- v3 `anime.set()` / `anime.random()` → v4 `utils.set()` / `utils.random()`.167- `loop`/`direction: 'alternate'` → `loop` + `alternate: true`.168- Full guide: <https://animejs.com/documentation/migrating-from-v3>.169170## Tips & gotchas171172- **Prefer transforms** (`x`, `y`, `scale`, `rotate`) and `opacity` for smooth,173 GPU-friendly motion; animating `width`/`top`/`left` triggers layout.174- Use `ease: createSpring({ stiffness, damping })` for natural motion instead of175 guessing cubic-bezier values.176- In **React/Vue/Svelte**, wrap creation in an effect and call177 `scope.revert()` (or the returned animation's `.revert()`) on cleanup so you178 don't leak timers across re-renders. `createScope` exists for exactly this.179- Respect `prefers-reduced-motion`: gate non-essential animation behind a media180 query check.181- Animations **autoplay by default**; pass `autoplay: false` and call `.play()`182 to control timing, or `autoplay: onScroll(...)` to tie it to scroll.183184## Credits185186Powered by [**anime.js**](https://github.com/juliangarnier/anime) (v4, MIT) by187**Julian Garnier**. This skill documents and wraps the library for the Claude188Agent Skills format; all credit for the animation engine belongs to its author189and contributors.