React AnimeJS
Components/Scroll-Linked Animations18 / 25

Scroll-Linked Animations

Code

1// No linked animation or callbacks here: progress is read each scroll
2// tick and mapped to per-layer transforms manually.
3const { ref, containerRef, isInView, progress } = useAnimeOnScroll({
4 enter: 'bottom top',
5 leave: 'top bottom',
6});
7
8const p = Math.max(0, Math.min(1, progress));
9const ty = p * layer.depth * -56; // depth drives parallax rate
10
11<div ref={containerRef} style={{ overflowY: 'auto' }}>
12 <div ref={ref}>
13 {layers.map((layer) => (
14 <div style={{ transform: `translateY(${p * layer.depth * -56}px)` }}>
15 {layer.label}
16 </div>
17 ))}
18 </div>
19</div>

Scroll-driven parallax — layer translate/opacity derived from scroll progress.

Live previewOpen Playground
Scroll-Linked AnimationsParallax depth · scroll scrub
Scroll ↓
Scroll inside the panel to scrub the parallax
fg
mid
bg
000
Props
NameTypeDefaultDescription
enterstring-Enter boundary (e.g. 'bottom top')
leavestring-Leave boundary (e.g. 'top bottom')
refRefObject<T>-Observed trigger element
containerRefRefObject<T>-Inner scroll container
progressnumber-Clamped 0-1 scroll progress
isInViewboolean-True when trigger is in viewport
linkedScrollLinkedTarget-Optional: animation to scrub (not used in this demo)

Related components