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: move Scrub Animation's playhead bar with transforms

matinc50e22c35000
diff --git a/animations/01-scroll-based/scrub-animation/index.html b/animations/01-scroll-based/scrub-animation/index.html
index 8e96b318..e323540e 100644
--- a/animations/01-scroll-based/scrub-animation/index.html
+++ b/animations/01-scroll-based/scrub-animation/index.html
@@ -51,8 +51,9 @@
border:1px solid var(--ui-border);border-radius:20px;padding:4px 10px;white-space:nowrap}
.dir.fwd{color:var(--ui-accent);border-color:var(--ui-accent)}
.dir.rev{color:#f0883e;border-color:#f0883e}
- .seek{position:relative;height:8px;border-radius:6px;background:rgba(255,255,255,.07)}
- .seek-fill{position:absolute;inset:0 auto 0 0;width:0;border-radius:6px;background:var(--ui-accent)}
+ .seek{position:relative;height:8px;border-radius:6px;background:rgba(255,255,255,.07);container-type:inline-size}
+ .seek-clip{position:absolute;inset:0;border-radius:6px;overflow:hidden}
+ .seek-fill{position:absolute;inset:0;border-radius:6px;background:var(--ui-accent);transform:translateX(-100%)}
.seek-head{position:absolute;top:50%;left:0;width:16px;height:16px;margin:-8px 0 0 -8px;border-radius:50%;
background:var(--ui-text);border:3px solid var(--ui-accent)}
.ticks{display:flex;justify-content:space-between;margin-top:6px;font-size:11px;color:var(--ui-muted)}
@@ -100,7 +101,7 @@
<div class="dir" id="dir" aria-hidden="true">Still</div>
</div>
<div class="seek">
- <div class="seek-fill" id="seek-fill"></div>
+ <div class="seek-clip"><div class="seek-fill" id="seek-fill"></div></div>
<div class="seek-head" id="seek-head"></div>
</div>
<div class="ticks"><span>0%</span><span>25%</span><span>50%</span><span>75%</span><span>100%</span></div>
@@ -236,7 +237,7 @@
frameEl.firstChild.nodeValue = String(v).padStart(3, '0');
frameEl.setAttribute('aria-label', `Frame ${v} of ${FRAMES}`);
});
- set('pct', pct, v => { seekFill.style.width = v + '%'; seekHead.style.left = v + '%'; });
+ set('pct', pct, v => { seekFill.style.transform = `translateX(${v - 100}%)`; seekHead.style.transform = `translateX(${v}cqw)`; });
set('marks', Math.floor(e * 4 + 1e-6), v => {
[...marks.querySelectorAll('.mark')].forEach((c, i) => c.classList.toggle('done', i <= v));
});
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 4f41b92f..255b626f 100644
--- a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
+++ b/docs/superpowers/plans/2026-09-29-scroll-content-part1.md
@@ -608,7 +608,7 @@ None: leave out the `details.hb-options` block.
- **Stage:**
- `.stage`: `position:relative;overflow-y:auto;scrollbar-width:none;container-type:size;background:#0b0b0d`, with `aria-label="A plane on a flight route"`.
- `.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.
+ - 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. The bar's fill and handle move with transforms, not width and left: `.seek` is an inline-size container (`container-type:inline-size`), the fill is a full-width strip inside a clipping `.seek-clip`, moved by `translateX(pct - 100%)`, and the handle moves by `translateX(pct cqw)`.
- 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;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.
@@ -652,6 +652,7 @@ None: leave out the `details.hb-options` block.
- **README Production notes:** the Accessibility bullet becomes: "**Accessibility.** The page scrolls the box once on arrival, and not at all under `prefers-reduced-motion: reduce`; after that it moves only when the visitor scrolls, so this is direct manipulation rather than imposed motion. Under reduced motion the demo drops the decorative glow and keeps the mapping, since removing it entirely would leave the control inert rather than calmer." The rest is unchanged.
- **Category line:** `01.08 · Scroll-Based`
- **Pager:** Previous: ScrollTrigger Animation (`../scroll-trigger/`) · Next: Pin Animation (`../pin-animation/`)
+- **Final fix wave (2026-09-30):** the final category review found the playhead bar animating `width` and `left` (CLAUDE.md: transform and opacity only), so the fill and the handle now move with transforms (see the panel line above). Against the page as it was, only the bar's sub-pixel edges differ: at five sizes and eleven scroll positions everything outside the bar is identical, and inside it at most about 120 pixels of the handle's and the fill's edges change. The frame count still changes text on every frame, so the panel is still laid out then; this change is for compliance.
---