Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: reset Parallax Depth-of-Field at once after a jump

matin7db3dc2728c8
diff --git a/animations/01-scroll-based/parallax-depth-of-field/README.md b/animations/01-scroll-based/parallax-depth-of-field/README.md
index 61fce950..4cb93e79 100644
--- a/animations/01-scroll-based/parallax-depth-of-field/README.md
+++ b/animations/01-scroll-based/parallax-depth-of-field/README.md
@@ -47,6 +47,10 @@ current += (target - current) * EASE; // inside a requestAnimationFrame loop
The loop only runs while the two values differ, so an idle page costs nothing.
+Back to top, and Play starting again from the top, move the box in one jump; a
+click on either button sets the eased value to the new position at once, so the
+layers do not rewind through the whole focus pull.
+
## Key parameters
| Parameter | Default | Effect |
diff --git a/animations/01-scroll-based/parallax-depth-of-field/index.html b/animations/01-scroll-based/parallax-depth-of-field/index.html
index 4ede4506..de5aea5d 100644
--- a/animations/01-scroll-based/parallax-depth-of-field/index.html
+++ b/animations/01-scroll-based/parallax-depth-of-field/index.html
@@ -226,6 +226,8 @@
}
stage.addEventListener('scroll', onScroll, { passive: true });
+ // Back to top, and Play starting again from the top, jump the box (the shared script moves it before the click reaches the document): the layers jump with it
+ document.addEventListener('click', e => { if (e.target.closest('#btn-top,#btn-scroll')) { onScroll(); current = target; render(current); } });
let rt;
window.addEventListener('resize', () => {
diff --git a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md b/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
index 14dd2c07..c17ca1fe 100644
--- a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
+++ b/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
@@ -68,7 +68,7 @@ These decisions and the category rules below read the same in part 1 and part 2.
- The old stage's `flex`, `min-width`, `width`, `height`, `border` and `border-radius` go; the page owns them.
- **Stage height:** every page takes the shared stage height (300–440px on computers and tablets, 260–327px on short laptops, 300px on phones; 378px inside the border at 1280×800, 325px at 1366×657, 258px at 1280×590 and 298px on phones). No page sets `--hb-stage-h` or `--hb-stage-h-phone`, and none uses `hb-grow` (no page takes typed text). The old `--stage-h` (600–640px, and 480–560px on phones), its phone overrides and the old fixed stage heights go. Each section's fits were measured from the 258px box to the 438px box of a tablet and a 610px-wide window, and on 375px and 320px phones (shared rule 3).
- **What was sized in stage heights inside the box** is sized in the scroller's own height, as in part 2 and under shared rule 5: the scroller gets `container-type:size`, and `var(--stage-h)` (or the old stage height written in pixels) becomes `100cqh`, so `calc(var(--stage-h) * 4)` becomes `400cqh`. A pinned part stays exactly one box tall at every stage height, and the scene keeps today's proportions to its box. Measured in headless Chrome on Parallax Depth-of-Field, Stacking Cards (including its CSS scroll timeline) and ScrollTrigger Animation: the same pictures and scroll lengths as sizing with a pixel value. No scroller that has `container-type` has padding. Pages that size nothing from the stage (Fly-in Fly-out Contact List, Reveal on Scroll, Stagger Reveal) leave `container-type` off.
-- **Every effect follows the scroller's `scroll` event**, an IntersectionObserver rooted on it, or a CSS scroll timeline, so it answers Play, Back to top, the wheel, touch and keys alike. No page reads the wheel itself or scroll speed. Any trusted input inside the stage stops Play (shared rule 6). While Play runs, the shared script turns snapping off (shared rule 7), so Snap Scrolling's Play glides through its sections. Back to top, and Play restarting from the top, jump at once (shared rule 8); the two pages that ease toward the scroll position (Parallax Depth-of-Field and Cover Card to Fixed Header) say so.
+- **Every effect follows the scroller's `scroll` event**, an IntersectionObserver rooted on it, or a CSS scroll timeline, so it answers Play, Back to top, the wheel, touch and keys alike. No page reads the wheel itself or scroll speed. Any trusted input inside the stage stops Play (shared rule 6). While Play runs, the shared script turns snapping off (shared rule 7), so Snap Scrolling's Play glides through its sections. Back to top, and Play restarting from the top, jump at once (shared rule 8); the two pages that ease toward the scroll position (Parallax Depth-of-Field and Cover Card to Fixed Header) say so, and jump with the box when either button is clicked.
- **`:root`** keeps `--ui-accent:#6ea8ff` and the variables the stage rules still use. `--stage-h`, `--disp` and `--mono` go, and `--ui-muted` becomes `#8a8a92` wherever stage text uses it (the old `#77777e` is 4.4:1 on `#0b0b0d` and 4.2:1 on the cards' `#111114`; the new grey is 5.5:1 or more). Stage text faded with `opacity` below 4.5:1 is fixed in its section.
- **Small stage text** follows shared rule 9: paragraph text at least 14px, labels at least 11px (the old 8–10px labels were drawn in the monospace font). Each section gives the new sizes.
- **`hb-dots`** is left off on every page: the dots would stay still while the content scrolls over them.
@@ -98,7 +98,7 @@ These decisions and the category rules below read the same in part 1 and part 2.
- **Player bar:** Play · Back to top
- **Try it:** none (owner decision 1). The demo's only control, the Focal Plane slider, is not a setting: it moves the same 0–1 value that scrolling moves (a second way to scrub, like Scrub Animation's Seek slider), and the next scroll overwrites it. The page has steps 1 and 2.
- **Scroller:** the stage.
-- **What scrolling shows:** a night landscape of five layers (sky, far peaks, mountains, hills, the ridge in front) held still in the box. As the box scrolls, each layer sinks by an amount that grows with its nearness, and the one sharp layer moves from the sky at the top to the ridge at the end; every other layer blurs by how far it sits from the sharp one. The layers ease toward the scroll position, so a wheel's jumps turn into a glide. Scrolling back reverses it. Back to top, and Play restarting from the top, jump the box at once; the layers then ease back over a moment, as after a wheel jump.
+- **What scrolling shows:** a night landscape of five layers (sky, far peaks, mountains, hills, the ridge in front) held still in the box. As the box scrolls, each layer sinks by an amount that grows with its nearness, and the one sharp layer moves from the sky at the top to the ridge at the end; every other layer blurs by how far it sits from the sharp one. The layers ease toward the scroll position, so a wheel's jumps turn into a glide. Scrolling back reverses it. Back to top, and Play restarting from the top, jump the box at once, and the layers jump with it (a click on either button sets the eased value at once).
- **Scroll distance and Play:** `.scene` 400cqh with the sticky `.pinned` 100cqh: three box heights of scrolling (1,134px at 1280×800, 894px on a phone). Play racks the focus from far to near in six seconds.
- **Reduced motion:** nothing scrolls by itself. As today, the layers never move (the page's `reduced` flag keeps their offset at 0) and scrolling only moves the focus, without easing. The CSS rule `.layer{will-change:auto}` stays.
- **Stage font:** no text on the stage.
@@ -139,6 +139,7 @@ These decisions and the category rules below read the same in part 1 and part 2.
- **README Production notes:** unchanged
- **Category line:** `01.01 · Scroll-Based`
- **Pager:** Previous: none · Next: Parallax Scrolling (`../parallax-scrolling/`)
+- **Final fix wave (Scroll-Based final review, 2026-09-30).** A `click` listener on the document, for `#btn-top` and `#btn-scroll` (by id, as Velocity Skew and SVG Line Draw do), runs `onScroll(); current = target; render(current);`, so the layers stand at the box's new position in the same click instead of easing back over the whole focus pull. The shared script has already moved the box when the click reaches the document. README How it works gains a paragraph saying so.
---