Academy · Lesson 2 of 6 · · 1 min read

Scroll-driven motion, explained

Scroll-driven motion ties an animation to the scroll position instead of to time. Scroll down and the animation moves forward; scroll up and it plays back. It is the most common kind of motion on animated websites because the visitor stays in control of the pace.

By the AnimatedWebs team · Animated websites from zero

Three patterns you will see everywhere

  • Reveal on enter. An element fades or slides in once when it scrolls into view. Browsers report this with the Intersection Observer API.
  • Pinned section. A section sticks to the screen while the scroll drives a sequence inside it, then lets go.
  • Scrubbed sequence. A film, a set of frames or a 3D scene moves forward and back exactly with the scroll.

How a scrubbed sequence works

The page reads how far the visitor has scrolled through a section, as a number from 0 to 1. That number picks the frame of a film, the angle of a 3D object or the step of a story. Because the number comes from scroll, the visitor sets the speed.

Scroll progress through one section
const section = document.querySelector('#story');
function progress() {
  const r = section.getBoundingClientRect();
  const total = r.height - window.innerHeight;
  return Math.min(1, Math.max(0, -r.top / total));
}
// Read progress() inside requestAnimationFrame and draw that frame.

Modern CSS can also link an animation to scroll with animation-timeline: scroll() or view(), with no JavaScript. Check browser support on the MDN page before you rely on it.

Examples from the catalog

Reed & Rivet Music scrubs a five-shot film with your scroll. Nocta Dive Watch takes a watch apart as you scroll. Kerfmoor builds a table from rough planks. Carbon Buoy Ocean Chapters is a free template with pinned, line-drawn chapters.

Rules that keep scroll motion usable

  • Never take over the scroll speed. The wheel and the thumb should feel normal.
  • Keep pinned sections short. A visitor who wants to skip should get through in a few flicks.
  • Put the key text in the HTML, not inside the film, so it can be read and found by search.
  • Give visitors who prefer reduced motion a still version. Lesson 5 covers this.

Questions people ask

Do I need a library for scroll animation?+

Not always. Simple reveals need only Intersection Observer or CSS. Long pinned stories are easier with a library, and many templates in the catalog use one.

Why does my scroll animation stutter on phones?+

Usually the page does heavy work on every scroll event. Read the scroll position once per animation frame and move only transform and opacity, which the browser can animate cheaply.

What is a scroll film?+

A short camera move, encoded so the browser can jump to any frame, that plays forward and back with the scroll. Several templates in the catalog are built this way.

Sources

Related templates

See the technique running

Play the live demos, open the one you like, and start with a free template or unlock the whole library.