Frontend / Accessibility
Make scroll position the source of truth
Build a reversible pinned scene from geometry, give each layer a bounded interval, and retain a complete reduced-motion layout.

A workshop photograph begins inside a frame, expands as the visitor scrolls and meets its caption at the end of the section. Someone halfway through should be able to stop, see an intentional composition and reverse it by scrolling back. Give the scene a playhead derived from position so its state does not depend on how quickly the visitor arrived.
Find the length of the pinned interval
Set a section taller than a sticky stage. With a stage that's sticky at the top of the viewport, travel is the section height minus the stage height. At the start, the top of the section meets the top of the viewport. At the end, the bottom of the section meets the bottom of the stage. Keeping this geometry explicit makes the motion much easier to test.
const clamp = (value) => Math.min(1, Math.max(0, value));
function pinnedProgress(section, stage) {
const rect = section.getBoundingClientRect();
const travel = Math.max(1, rect.height - stage.offsetHeight);
return clamp(-rect.top / travel);
}
function progressBetween(progress, start, end) {
const t = clamp((progress - start) / (end - start));
return t * t * (3 - 2 * t);
}
For a stage pinned below a header, use its actual sticky top offset in the numerator and keep the geometry consistent in CSS. Measure the wrapping section rather than the sticky element itself. Its top continues moving while the stage is pinned.
Overlap a few clear changes
Let the frame begin opening while the text moves from the title into the caption. For example, drive the crop with progressBetween(p, 0.12, 0.74) and the caption with progressBetween(p, 0.58, 0.88). Each property has a predictable value on either side of its interval. Reversing scroll then reverses every property, even if the visitor skipped the first half by using the scrollbar.
For a simple frame reveal, CSS scroll-driven animations can bind a property to scroll or view progress. A named view timeline can track an element's traversal through the scrollport. Where your scene also needs to set a shader uniform, camera position and image crop from exactly the same value, taking one geometry reading in JavaScript and sharing it is often clearer. CSS Scroll-driven Animations specification · MDN guide to CSS scroll-driven animations
Use a passive listener to request a single animation frame, and read positions before writing styles. Redraw the canvas when its inputs change, at a pixel density the device can afford. Recalculate geometry on resize and test screenshots with the mobile address bar in both positions. Releasing a pinned scene gracefully is part of the animation.
Keep the story in document order
Put the photograph, caption and navigation links in the HTML. Draw any shader or background effect around that content. Under prefers-reduced-motion: reduce, render the stage in normal flow with a stable crop, no camera or pinning and the same information. When JavaScript is unavailable, visitors should still be able to read the caption and follow the links. W3C guidance on animation from interactions
Verify the intermediate states
Capture the opening, midpoint and release. Return to the midpoint from the end and compare the frame, text position and shader state. If they differ, the timeline is carrying hidden state. Check Tab navigation in the middle of the sequence and ensure controls belonging to an invisible scene cannot receive focus. Repeat on a narrow viewport and with reduced motion enabled. A scene that works in reverse is usually easier to maintain.
See how the chapter applied the model to the event reel and committee portrait on the website engineering page.
Cover illustration by ACM MPSTME.