The scene model
React components and JavaScript scene definitions share the same animation and timing rules.
Director
Creates the scroll track and sticky stage. Import from scroll-director/react.
| Prop | Default | Description |
|---|---|---|
height | 100svh | Positive pixel number or CSS height. |
scroller | Window | An ancestor scrollable HTMLElement. Without an explicit height, its client height is used. |
reducedMotion | "auto" | "auto" | "always" | "never". Auto follows the system preference. |
onUpdate | — | Called with a frame whenever the engine renders. |
onSceneChange | — | Called when the active scene changes. |
onError | — | React setup errors. Without a handler, errors reach React error boundaries. |
ref | — | A DirectorHandle with navigation and lifecycle methods. |
Scene
| Prop | Default | Description |
|---|---|---|
id | Generated | Unique inside the director. Use a stable id for navigation. |
duration | Required | Positive scroll distance in CSS pixels. |
transition | "cut" | An incoming transition name, or { type, duration }. |
label | — | Accessible label for the scene section. |
React scenes also accept className, style and children. Place them directly under Director; fragments are supported. The first scene’s incoming transition is ignored.
Camera
Transforms the scene’s world wrapper. A scene can contain one camera.
| Track | Unit | Default |
|---|---|---|
x, y, z | Pixels | 0 |
zoom | Scale factor | 1 |
rotate, rotateX, rotateY | Degrees | 0 |
All camera tracks accept the keyframe formats. The scene uses a CSS perspective of 1,200 pixels.
Layer
| Prop | Default | Description |
|---|---|---|
depth | 0 | Parallax multiplier: -depth × height × 0.25 × progress. |
animate | — | Numeric motion tracks listed below. |
start / end | 0 / 1 | Local scene-progress window. Must satisfy 0 ≤ start < end ≤ 1. |
easing | "linear" | Changes the whole local clock. |
Motion tracks: x, y, z, scale, scaleX, scaleY, rotate, rotateX, rotateY, opacity, blur. Position and blur use pixels; rotation uses degrees. Opacity is clamped to 0–1, blur to nonnegative values. Uniform scale multiplies the individual axis scales.
Layers are absolute full-stage wrappers. Style inner content for placement and your own transforms. Fully transparent layers become inert.
Keyframes
A track can be a fixed number, an evenly spaced array, or an object with explicit offsets.
x: 40
y: [0, -40, -100]
opacity: {
values: [0, 1, 1, 0],
offsets: [0, 0.2, 0.8, 1],
easing: "ease-in-out"
}Offsets must match the values, strictly increase and include both 0 and 1. Layer easing affects the whole window; a track’s easing applies to each segment.
Supported easings: linear, ease-in, ease-out, ease-in-out, smoothstep. Values hold at their nearest endpoint outside the animation window.
Transitions
Specify a transition on the incoming scene. A string uses 300 additional scroll pixels. Set { type: "mask", duration: 400 } to choose a distance.
| Type | Behavior |
|---|---|
cut | Instant switch; adds no distance. |
dissolve | Crossfade between scenes. |
fade | Fade through the stage background. |
zoom | Crossfade with scene scaling. |
mask | Reveal the next scene from left to right. |
blur | Crossfade with up to 12 px of blur. Large filtered surfaces can be expensive. |
The active scene switches at the transition midpoint. Its content clock starts after the transition completes.
Controls and events
| Method | Behavior |
|---|---|
getSnapshot() | A copied frame, or null after destruction. |
seek(progress, options?) | Navigate to global progress from 0 to 1. |
goTo(id, options?) | Navigate to a scene. Options include local progress and behavior. |
refresh() | Remeasure layout and render immediately. |
on(event, listener) | Subscribe to update or scenechange. Returns an unsubscribe function. |
destroy() | Disconnect events and observers, cancel frames and restore authored DOM. Repeatable. |
Navigation behavior is "instant" by default; "smooth" opts into native browser smoothing. Reduced motion forces instant navigation and navigates to static scene sections.
Frames include progress, position, sceneIndex, sceneId, sceneProgress, transitionProgress and a scenes array.
Vanilla JavaScript
createDirector(host, options) takes the same scene model with an element for each scene and layer. Selectors are scoped to their host or scene. Actual HTML elements are also accepted.
import { createDirector } from "scroll-director";
import "scroll-director/style.css";
const director = createDirector(document.querySelector("#story"), {
scenes: [
{
id: "intro", element: "#intro", duration: 1600,
camera: { zoom: [1, 1.2] },
layers: [
{ id: "title", element: ".title",
animate: { y: [40, -40], opacity: [1, 0] } }
]
},
{ id: "chapter-two", element: "#chapter-two",
duration: 1200, transition: "dissolve" }
]
});
// director.seek(0.5);
// director.destroy();The host must be connected to the document. The vanilla engine manages its subtree until destruction; use the React adapter for React-owned DOM.
Pure timeline
Use the DOM-free entry point for tooling or server-side frame evaluation. Scene definitions are JSON-compatible.
import { createTimeline, evaluateTimeline }
from "scroll-director/timeline";
const timeline = createTimeline([
{ id: "intro", duration: 1600 },
{ id: "chapter-two", duration: 1200, transition: "dissolve" }
]);
const frame = evaluateTimeline(timeline, 0.5);Definitions are copied and frozen during compilation. This is an engine for scenes, not a visual editing application; ScrollDirector Studio is not included.