anime.js / v4 field demos

anime.js 4.5.0 · 24.5 KB · no dependencies

Motion that feels inevitable.

Six live demos of the v4 API — staggered reveals, easing curves, sequenced timelines, SVG line-draw and morph, throwable drag physics and per-character type. Every snippet below is copy-paste ready.

animate() createTimeline() onScroll() svg.draw createDraggable() splitText()
24.5KB

Whole library, every feature — before any per-module tree-shaking.

0deps

No runtime dependencies, no build step required — one ES module.

4.5version

Latest npm release. Layout, Text and Adapters are the newest sections.

01

One API, six primitives.

Everything animates through the same engine. Hover a card to see a one-line tween fire; the grid itself is revealed by stagger() as you scroll.

A

animate()

Tween CSS, attributes, SVG geometry and plain JS objects from one call.

B

createTimeline()

Label, position and replay sequences down to the millisecond.

C

onScroll()

Lock playback to scroll position, or fire at precise thresholds.

D

svg.draw

Draw paths, follow motion paths, morph shapes with matched point counts.

E

createDraggable()

Drag, snap, flick and spring back with a configurable release spring.

F

splitText()

Split into lines, words and characters, then animate each one.

animate('.card', {
  y: ['100%', '0%'], opacity: [0, 1],
  delay: stagger(70), ease: 'out(3)',
});
02

Ten easings, same duration.

The only difference is the curve. Replay to compare how each one accelerates, overshoot-free, into its final state.

scaleX · 1500 ms · loop alternate
animate(bar, {
  scaleX: [0.06, 1], duration: 1500,
  ease: bar.dataset.ease, loop: true, alternate: true,
});
03

Timelines keep the beat.

A 14-bar equaliser built from two .add() calls: one sweep in with stagger(), one sweep back from the last bar.

createTimeline · loop
stagger(50)stagger(50, { from: 'last' })
createTimeline({ loop: true, defaults: { duration: 460, ease: 'inOutQuad' } })
  .add('.bar', { scaleY: [0.18, 1] }, stagger(50))
  .add('.bar', { scaleY: [1, 0.18] }, stagger(50, { from: 'last' }));
04

SVG is just more targets.

Left: a path draws itself as it enters the viewport. Right: two shapes melt into each other on a loop.

svg.createDrawable() → draw: '0 1'
svg.morphTo('#blob-b')
animate(svg.createDrawable(path), { draw: ['0 0', '0 1'], ease: 'inOutQuad' });
animate('#blob-a', { d: svg.morphTo('#blob-b', 0.33), loop: true, alternate: true });
05

Physics you can throw.

Drag the disc and let go. releaseEase is a real spring — stiffness and damping, evaluated every frame.

drag

held at rest · grab and throw inside the board

createDraggable('.knob', {
  container: '.board', containerPadding: 10,
  releaseEase: spring({ stiffness: 120, damping: 7 }),
});
06

Split the type, keep control.

splitText() wraps every character, word and line in its own element and hands them back as arrays. Then it is just stagger().

Type is scenery. Motion is the weather.

const { chars } = splitText('.split-title', { words: { wrap: 'clip' }, chars: true });
animate(chars, { y: ['110%', '0%'], delay: stagger(14), ease: 'out(3)' });