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.

docs: fix the Scrub drawing size and small notes in the Scroll-Based sheet part 1

matin1db49f375295
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 b4251334..1491868d 100644
--- a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
+++ b/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
@@ -34,7 +34,7 @@ These decisions and the category rules below read the same in part 1 and part 2.
4. **Trigger lines:** every trigger-line choice must be reachable within the box's scroll distance at every size, from the tallest box to a narrow window just over 600px (part 1: Reveal on Scroll, Stagger Reveal, ScrollTrigger Animation — check and state it).
5. **`container-type:size`:** only on a scroller whose height comes from outside (the stage, or `height:100%` of it); never together with `hb-grow`; never padding on that scroller (cqh measures its content box); any `cqh` use needs that container (without one it falls back to the viewport). No `--box-h` script fallback.
6. **Play stops on input:** the shared script stops Play on any trusted input anywhere inside the stage (pointer, wheel, touch, key). Sections state it as a fact; no page works around it (part 2's Scrollspy "blocker" line becomes a plain statement).
-7. **Snapping during Play:** the shared script turns CSS scroll snapping off on the scroller while Play runs — it saves the scroller's inline `scroll-snap-type`, sets it to `none`, and restores the saved inline value when the run ends, is stopped, or Back to top is pressed (it does nothing when snapping is already off). So no page sets `scroll-snap-type` inline: Snap Scrolling's Snapping setting sets an attribute (e.g. `data-snap="mandatory|proximity|off"` with three CSS rules). When a wheel turn stops Play, snapping returns and the box settles on the nearest point by itself.
+7. **Snapping during Play:** while Play runs, the shared script marks the scroller with `data-hb-autoscrolling`, and a shared rule turns CSS scroll snapping off on a marked scroller (`scroll-snap-type:none !important`). When the run ends, is stopped, or Back to top is pressed, the mark goes and the scroller's own snapping applies again — whatever the page set, even during the run. Pages set snapping however they like, but never with `!important`; Snap Scrolling's Snapping setting sets an attribute (e.g. `data-snap="mandatory|proximity|off"` with three CSS rules). When a wheel turn stops Play, snapping returns and the box settles on the nearest point by itself.
8. **Instant jumps:** Back to top, and Play restarting from the top, are instant jumps. Say so wherever an effect reads scroll speed or eases toward the scroll position; Velocity Skew ignores the frame after a jump (listen for clicks on `#btn-top` / `#btn-scroll`, by id) and measures speed per 1/60 s, so 120 Hz screens lean the same.
9. **Small stage text:** paragraph text in the stage is at least 14px; small labels (chips, ticks, captions, buttons) at least 11px. Part 1: `.chip-name`, `.card-sub`, `.card-btn`, `.dir` grow to 11px. Part 2: Smooth Scroll's `.card-body` and Background Color's `p` go to 14px.
10. **Text that changes every frame** (counters, depth numbers, frame counts): `role="img"` plus an `aria-label` with the real value, or `aria-hidden="true"` when it only repeats something else on the stage; never a live region (part 1: Scrollytelling's `#depth-num`, Scrub Animation's frame count and `.dir`).
@@ -279,7 +279,7 @@ None: leave out the `details.hb-options` block.
- The cover's full height becomes 85% of the box: `.cover{height:85cqh}` in the CSS, and `measure()` sets `FULL = Math.round(stage.clientHeight * 0.85)` (530px of a 620px stage today), so the whole cover shows on arrival: 321px at 1280×800, 276px at 1366×657, 219px at 1280×590 and 253px on phones (measured: its text, with its margins and padding, needs 171px there and 192px on phones). `--cover-full` goes; `--cover-min` stays (56px, 64px under 600px).
- The scene's `min-height:2500px` goes. Today it leaves about 1,700px of empty box after the article, so Play would spend most of its six seconds on nothing. `measure()` sets `scene.style.minHeight = Math.max(FULL + article.offsetHeight, stage.clientHeight + 440) + 'px'`, so the box scrolls far enough to finish the longest shrink and its scroll length does not change while the cover shrinks. At every measured size the first term wins, so once the cover is slim, `FULL − MIN` of box is left empty after the article: 265px at 1280×800, 163px at 1280×590, 189px on phones. `measure()` also runs after `document.fonts.ready` (the article's height depends on the font).
- A closing line fills that space (owner decision 4): `<p class="end-cue">The end · scroll back up and the cover opens again</p>`, the last child of `.scene`, with `position:absolute;left:0;right:0;bottom:0;margin:0;display:flex;align-items:center;justify-content:center` and the cue style (shared rule 14: 13px `#8a8a92`, `letter-spacing:.1em`, `text-align:center;padding:0 24px`). `measure()` sets its height to `FULL − MIN` (`.scene` is already `position:relative`).
- - The cover's title becomes `<p class="cover-title" id="cover-title">` (was an `h1`, shared rule 13): the shared rule `.hb-page h1` would restyle it at 64px. `.cover-title` keeps its own look (26px, `#d1f7d6`, `line-height:1.2`, `letter-spacing:-.5px`, `margin-bottom:8px`, `transform-origin:left top`). Measured: when the cover is slim, the title's two lines scale to half size and sit 22–53px down the 56px bar (64px on phones).
+ - The cover's title becomes `<p class="cover-title" id="cover-title">` (was an `h1`, shared rule 13): the shared rule `.hb-page h1` would restyle it at 64px. `.cover-title` keeps its own look (26px, `#d1f7d6`, `line-height:1.2`, `letter-spacing:-.5px`, `margin-bottom:8px`, `transform-origin:left top`) and gets `font-weight:700`, the weight the `h1` gave it. Measured: when the cover is slim, the title's two lines scale to half size and sit 22–53px down the 56px bar (64px on phones).
- The code shown on the cover (`.cover-code`) goes, with its line in `render()` (`coverCode.style.opacity`).
- Text on the cover: the subtitle becomes "Why a tall cover can fold into a slim bar as you read" (was "How browsers render scroll-driven animations at 60fps"); "Article · 8 min read", the title and "Matin M. · May 2026" stay. `.cover-meta`, `.author-name` and `.chip-name` become 11px (were 10px) and `.cover-sub` 14px (was 12px). `.cover-meta`, `.cover-sub` and `.author-name` use `#5fa577` (was `#3d7a52`, 3.1:1 on the cover's green; the new green is 5.3:1); `.chip-name` keeps `#d1f7d6`.
- The article is rewritten in plain words (today's text speaks of compositors, easing curves and the removed slider), with `.article-body p` at 14px (was 12px), the headings 12px (was 11px) and the blockquote 15px (was 13px). Its three headings become `h3` (were `h2`, shared rule 13), so the `.article-body h2` rule becomes `.article-body h3`. In order:
@@ -596,7 +596,7 @@ None: leave out the `details.hb-options` block.
- `.track{height:300cqh}`; `.pinned{position:sticky;top:0;height:100cqh}` (with its flex column, gap and padding). Measured: the route shrinks to fit above the panel at every size. The drawing is shown at 0.83 of its size at 1280×800, 0.62 at 1366×657, 0.35 in the 258px box of a 1280×590 window (87px tall, the panel still inside the box), 1.06 at 768×1024, 0.50 on a 375px phone and 0.42 on a 320px phone.
- The player panel stays: it is the demo's picture of a video's playhead. Its label reads "Forward", "Backward" and "Still" (was "scrubbing", "rewinding" and "idle"); the frame count and the bar stay.
- Text that changes every frame (shared rule 10): the frame count (`#frame`) gets `role="img"`, and `render()` sets its `aria-label` together with its text ("Frame 42 of 120"); the direction label (`#dir`) gets `aria-hidden="true"`, because it only repeats which way the plane is moving. Neither is a live region.
- - The route's labels (0%, 25% … 100%) keep one size on screen (shared rule 11, as part 2's SVG Line Draw does): today they are 9px in the drawing's units, so 7.5px on screen at 1280×800 and 3–6px on phones and short laptops. `.mark-label` loses its `font-size` and `stroke-width` in the CSS, and `buildMarks()` works out `k = 1 / rail.getScreenCTM().a` and gives each label `style.fontSize = 12 * k + 'px'`, `style.strokeWidth = 3 * k + 'px'` and `y = pt.y - 14 * k`, so they show at 12px, 14px above their mark, at every size. The `.flight` svg gets `overflow:visible`, so the 50% label over the top of the curve is not cut when the drawing is small. `.ticks` becomes 11px (was 9px).
+ - The route's labels (0%, 25% … 100%) keep one size on screen (shared rule 11, as part 2's SVG Line Draw does): today they are 9px in the drawing's units, so 7.5px on screen at 1280×800 and 3–6px on phones and short laptops. `.mark-label` loses its `font-size` and `stroke-width` in the CSS, and `buildMarks()` works out `k = 1 / rail.getScreenCTM().a` and gives each label `style.fontSize = 12 * k + 'px'`, `style.strokeWidth = 3 * k + 'px'` and `y = pt.y - 14 * k`, so they show at 12px, 14px above their mark, at every size. The `.flight` svg gets `overflow:visible;min-height:0`: `overflow:visible` keeps the 50% label over the top of the curve from being cut when the drawing is small, and `min-height:0` keeps the drawing shrinking, because the svg is a flex item and `overflow:visible` alone would make its smallest size its full 365px (measured: without it the drawing stays at 1.46 of its size and pushes the panel out of the box at 1280×800, 1366×657 and 1280×590; with it the scales above hold and the panel stays inside the box at every size). `.ticks` becomes 11px (was 9px).
- Script: `easeSel.value` becomes a variable `ease` set by Feel; `render()` loses its side-panel readout lines (`progKv`, `frameKv`, `seekVal`, the slider), and `setDir()` loses `dirKv`. The Seek slider's listener goes. `measure()` (which calls `buildMarks()`) also runs after `document.fonts.ready`, because the drawing's size depends on the panel's text.
- `hb-dots`: no. Default height.
@@ -659,7 +659,9 @@ None: leave out the `details.hb-options` block.
- The phone drawing gets `aria-hidden="true"`: it repeats the feature's number and title (shared rule 12). On computers it becomes `.phone-wrap svg{height:min(200px,72cqh);width:auto}`, so it fits the 258px box of a 1280×590 window, where it is 186px tall (today's 200px drawing and the 32px padding need 264px). Measured: the phone 35–221px and the text 48–212px down the 258px box; at 1280×800 and above it stays 200px.
- Phone rules (under 600px): the phone stays beside its text (today it stacks above it, and the text is cut off in the 300px box; measured): `.pin-inner{gap:14px;padding:16px}` keeps its row (today's `flex-direction:column` goes), and `.phone-wrap svg{width:72px;height:131px}` in place of `transform:scale(.8)`. Measured with the 14px text: the longest feature's text takes 150px on a 375px phone and 198px on a 320px phone (51–249px down the 298px box).
- `.feat-desc` becomes 14px (was 12px), and so do the intro's and the closing panel's text (was 13px).
- - The intro's and the closing panel's titles become `<p class="panel-title">` (were `h2`, shared rule 13), with the same sizes (`clamp(20px,3vw,28px)` and `clamp(18px,2.5vw,24px)`, 12px and 10px below) and `font-weight:700`.
+ - The intro's and the closing panel's titles become `<p class="panel-title">` (were `h2`, shared rule 13). Today's `.intro p` and `.outro p` rules would also match them, so the text rules exclude the titles and the titles get rules of their own:
+ - `.intro p:not(.panel-title){font-size:14px;color:var(--ui-muted);max-width:340px;line-height:1.65}` and `.outro p:not(.panel-title){font-size:14px;color:var(--ui-muted);max-width:300px;line-height:1.6}` (were `.intro p` and `.outro p` at 13px);
+ - `.intro .panel-title{font-size:clamp(20px,3vw,28px);font-weight:700;margin-bottom:12px}` and `.outro .panel-title{font-size:clamp(18px,2.5vw,24px);font-weight:700;margin-bottom:10px}` (were `.intro h2` and `.outro h2`), so the titles keep the stage's white and a normal line height.
- The intro's text reads "The phone and its text will stop in the middle of the box and hold still while four features go by." (today it says CSS handles the pinning). The closing panel keeps "Pin released", and its text reads "The phone and its text let go and scroll away with the page again." (today it speaks of the document flow).
- The four features' texts stay.
- Script: `update()` keeps the feature index, the texts and the phone's colours; the Scroll, Lifecycle and Feature readouts and the segment bar go.
@@ -724,13 +726,13 @@ None: leave out the `details.hb-options` block.
- **Player bar:** Play · Back to top
- **Scroller:** `<div class="scroller" id="scroller" data-hb-scroller tabindex="0" role="region" aria-label="Five sections that the box snaps to">` inside the `.stage`. The `.stage` does the job of today's `.stage-wrap`: it holds the dots beside the scroller, so they stay in place while the sections move. The script calls it `scroller` wherever it said `stage`.
- **What scrolling shows:** five full-box sections in different colours. Stop scrolling between two and the box glides to the nearer one, so a section always shows whole; with When close it only settles near a section, and with Off it stops anywhere. The dots at the right edge light up for the section in view, and pressing a dot glides to its section. Play glides straight through, because the shared script turns snapping off while it runs (shared rule 7); any input inside the stage stops Play (shared rule 6), snapping comes back, and the box settles on the nearest section by itself.
-- **Scroll distance and Play:** five sections at 100cqh: four box heights of scrolling (1,512px at 1280×800, 1,192px on a phone). Play glides through all five in six seconds, a section about every 1.5 seconds, without snapping (owner decision 2); the snapping shows when the visitor scrolls. The page does nothing for this: it never writes `scroll-snap-type` inline, so the shared script can turn it off and back on.
+- **Scroll distance and Play:** five sections at 100cqh: four box heights of scrolling (1,512px at 1280×800, 1,192px on a phone). Play glides through all five in six seconds, a section about every 1.5 seconds, without snapping (owner decision 2); the snapping shows when the visitor scrolls. The page does nothing for this: while Play runs, the shared script marks the scroller with `data-hb-autoscrolling` and a shared rule turns its snapping off; when the run ends or is stopped, the page's own snapping applies again, including a Snapping choice made during the run (shared rule 7).
- **Reduced motion:** nothing scrolls by itself. As today, the box lands on a section at once instead of gliding, and the dots change without their transition: the demo's rule becomes `@media(prefers-reduced-motion:reduce){.scroller{scroll-behavior:auto!important}.dot::before{transition:none!important}}`.
- **Stage font:** site font. The quote drops its italic.
- **Stage:**
- `.stage`: `position:relative;overflow:hidden;background:#0b0b0d`.
- `.scroller`: `height:100%;overflow-y:auto;scrollbar-width:none;position:relative;container-type:size;scroll-behavior:smooth`, with the `::-webkit-scrollbar{display:none}` rule. The old stage's border and height go.
- - Snapping comes from an attribute, never from an inline style (shared rule 7): the scroller starts with `data-snap="mandatory"`, and three rules read it: `.scroller[data-snap="mandatory"]{scroll-snap-type:y mandatory}`, `.scroller[data-snap="proximity"]{scroll-snap-type:y proximity}` and `.scroller[data-snap="off"]{scroll-snap-type:none}`.
+ - Snapping comes from an attribute (shared rule 7): the scroller starts with `data-snap="mandatory"`, and three rules read it: `.scroller[data-snap="mandatory"]{scroll-snap-type:y mandatory}`, `.scroller[data-snap="proximity"]{scroll-snap-type:y proximity}` and `.scroller[data-snap="off"]{scroll-snap-type:none}`. None uses `!important`, so the shared rule can turn snapping off during Play.
- `.section{height:100cqh}` (was 620px, 480px on phones). The script's `620` becomes `scroller.clientHeight` (the dot and the section in view: `Math.min(Math.round(scroller.scrollTop / scroller.clientHeight), 4)`; the dot's jump: `scroller.scrollTo({ top: i * scroller.clientHeight })`, without `behavior`, so the box's own `scroll-behavior` decides: a glide, or a jump under reduced motion).
- The dots sit at the right edge inside the box on every screen: `.snap-dots{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column}`; the phone rule that fixed them to the window goes. Each dot becomes `<button type="button" class="dot" aria-label="Section 1">` (to 5): `.dot{width:44px;height:44px;padding:0;border:0;background:none;display:grid;place-items:center;cursor:pointer}`, with the 8px dot drawn by `.dot::before{content:'';width:8px;height:8px;border-radius:50%;background:var(--ui-muted);transition:background .2s,transform .2s}` and `.dot.active::before{background:var(--ui-accent);transform:scale(1.4)}`. The active dot also gets `aria-current="true"`. The shared script stops Play on any press inside the stage, so a dot works during Play too. Five dots take 220px, which fits the 258px box of a 1280×590 window and the 298px phone box. The dots' focus ring comes from the shared stylesheet (shared rule 2).
- The section texts are rewritten in plain words (today's speak of the browser engine, CSS and JavaScript):
@@ -751,7 +753,7 @@ None: leave out the `details.hb-options` block.
| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |
|---|---|---|---|---|---|
-| Snapping | Choice buttons | Always · When close · Off | Always | When close only settles near a section; Off never does. | `scroller.dataset.snap`: `'mandatory'` / `'proximity'` / `'off'` (the three CSS rules above set `scroll-snap-type`) |
+| Snapping | Choice buttons | Always · When close · Off | Always | Scroll by hand to see it; Play glides without snapping. | `scroller.dataset.snap`: `'mandatory'` / `'proximity'` / `'off'` (the three CSS rules above set `scroll-snap-type`) |
**More options**
@@ -798,7 +800,7 @@ None: leave out the `details.hb-options` block.
}
```
- - "The mode toggle in the demo changes `scroll-snap-type` live." becomes "The Snapping setting switches between the three through a `data-snap` attribute that three CSS rules read. The page never writes `scroll-snap-type` inline: the Play button turns snapping off inline while it scrolls the box, and puts back what was there when it stops."
+ - "The mode toggle in the demo changes `scroll-snap-type` live." becomes "The Snapping setting switches between the three through a `data-snap` attribute that three CSS rules read. While the Play button scrolls the box, a shared rule turns snapping off on it, and the page's own snapping applies again when it stops."
- "Pagination dots and jump-to buttons use `scrollTo` with `behavior: 'smooth'`:" becomes "The dots scroll to their section; leaving out `behavior` lets the box's own `scroll-behavior` decide, so it glides, or jumps under reduced motion:", and its snippet becomes `scroller.scrollTo({ top: sectionIndex * scroller.clientHeight });`.
- The last snippet becomes `const sectionIndex = Math.round(scroller.scrollTop / scroller.clientHeight);`.
- **README Production notes:** unchanged
@@ -872,7 +874,7 @@ None: leave out the `details.hb-options` block.
- **Player bar:** Play · Back to top
- **Scroller:** `<div class="scroller" id="scroller" data-hb-scroller tabindex="0" role="region" aria-label="Seven cards that appear as you scroll">` inside the `.stage`. The `.stage` does the job of today's `.stage-wrap`: it holds the dashed trigger line beside the scroller, so the line stays in place while the cards move. The script calls it `scroller` wherever it said `stage`.
- **What scrolling shows:** seven cards rise toward a dashed line across the box. Each stays hidden until its top passes the line, then settles into place in its own way: a fade, a rise, a slide from the left, a grow, a sharpen from a blur, a wipe from the left, and a group of four chips that arrive one by one. A card stays shown after that, unless Plays every time is on; then it hides again when it drops back below the line.
-- **Scroll distance and Play:** the cards' own height, with 200px of room after the last so it can pass the highest line: about 2.1 box heights at 1280×800 (800px) and 3.1 on a 375px phone (921px). The first card or two show on arrival (two on laptops and tablets, one in the 258px box and on phones), and Play reveals the rest about a second apart.
+- **Scroll distance and Play:** the cards' own height, with 200px of room after the last so it can pass the highest line: about 2.1 box heights at 1280×800 (800px) and 3.1 on a 375px phone (921px). At the Normal line the first cards show on arrival: two at 1280×800, at 1366×657 and on a 375px phone, three in the 438px boxes (768×1024 and 610×1000), and one in the 258px box of a 1280×590 window and on a 320px phone. Play reveals the rest about a second apart.
- **Every Trigger line is reached** (shared rule 4): at the end of the scroll the last card's top is at most 115px down the box (at 768×1024 and at 610×1000, where the box is 438px), always above even the Higher line at half the box; measured from the 258px box to the 438px box and on phones.
- **Back to top and Play from the end:** Back to top, and Play pressed with the box at its end (Play then starts from the top), hide every card and arm the reveals again, as today's Reset all cards did. The page listens for clicks on `#btn-top`, and on `#btn-scroll` when `scroller.scrollTop >= scroller.scrollHeight - scroller.clientHeight - 2`: it calls `hide()` on every card and `buildObserver()` 50ms later, after the jump to the top. This relies on the order of the listeners: the page's inline script registers its click listeners before the shared script (loaded with `defer`) registers Play's and Back to top's, so on a click the page still sees the box at its end before Play jumps it to the top. The listeners must stay in the inline script's top level.
- **Reduced motion:** nothing scrolls by itself. As today, each card appears at the line without moving (`.card, .card .stagger-child{transition:none!important}`).