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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
docs: say when Stagger Reveal's groups replay
matin52994d90fa55
diff --git a/animations/01-scroll-based/stagger-reveal/README.md b/animations/01-scroll-based/stagger-reveal/README.mdindex f38f81df..714410e5 100644--- a/animations/01-scroll-based/stagger-reveal/README.md+++ b/animations/01-scroll-based/stagger-reveal/README.md@@ -31,7 +31,7 @@ function staggerIn(items) {The order array holds a *rank* per item, not a target — item `i` waits `order[i] × staggerMs`. Center-out works by using distance-from-center as the rank, so the middle items (rank 0) fire first.-`later()` is `setTimeout` that also remembers its timer. A group plays once, when half of it is in the box or its bottom edge has come into the box. The observers watch the group's items, not the section around them, so the cascade starts while the items are on screen instead of while they are still below the box; a threshold every 5% makes them report on the way, so a quick jump to the end is still noticed and no visible row is left hidden. Back to top, pressing Play with the box already at its end, and changing a setting all call `rebuild()` at once, which cancels the timers still waiting, builds the three groups again hidden and attaches fresh observers, so the groups in the box play again with the current settings. The observers report on the next frame, after the box has jumped to the top, so the finished groups are never drawn there. The last group ends with 80px of padding, more than the 20px an item sits low before it appears; without it the hidden items would stretch the scroll length and give it back as they arrive, and a script that reads the length once (as the demo's Play button does) would aim at an end that is not there.+`later()` is `setTimeout` that also remembers its timer. A group plays once, when half of it is in the box or its bottom edge has come into the box. The observers watch the group's items, not the section around them, so the cascade starts while the items are on screen instead of while they are still below the box; a threshold every 5% makes them report on the way, so a quick jump to the end is still noticed; a group less than half in view whose bottom edge is still below the box waits, hidden, until more of it scrolls in. Back to top, pressing Play with the box already at its end, and changing a setting all call `rebuild()` at once, which cancels the timers still waiting, builds the three groups again hidden and attaches fresh observers, so a group half in the box, or with its bottom edge in it, plays at once with the current settings. The observers report on the next frame, after the box has jumped to the top, so the finished groups are never drawn there. The last group ends with 80px of padding, more than the 20px an item sits low before it appears; without it the hidden items would stretch the scroll length and give it back as they arrive, and a script that reads the length once (as the demo's Play button does) would aim at an end that is not there.## Key parameters| Parameter | Default | Effect |diff --git a/animations/01-scroll-based/stagger-reveal/index.html b/animations/01-scroll-based/stagger-reveal/index.htmlindex 9a0302d7..6654bcb8 100644--- a/animations/01-scroll-based/stagger-reveal/index.html+++ b/animations/01-scroll-based/stagger-reveal/index.html@@ -212,7 +212,8 @@// Each group plays once, when half of it is in the box or its bottom edge has come into the box. The observers watch the// group's items, not the section around them, so the cascade starts while the items are on screen. A threshold every 5%- // makes them report on the way, so a jump straight to the end is not missed and no visible row is left hidden.+ // makes them report on the way, so a jump straight to the end is not missed; a group less than half in view whose bottom+ // edge is still below the box waits, hidden, until more of it scrolls in.const STEPS=Array.from({length:21},(_,i)=>i/20);function attachObservers(){observers.forEach(o=>o.disconnect());observers=[];@@ -226,8 +227,8 @@}attachObservers();- // Builds the three groups again, hidden, and watches them again: the groups in the box play at once with the current- // settings, the others when they scroll in+ // Builds the three groups again, hidden, and watches them again: a group half in the box, or with its bottom edge in it,+ // plays at once with the current settings, the others when they scroll infunction rebuild(){timers.forEach(clearTimeout);timers=[];gridItems=buildGrid();listItems=buildList();chipItems=buildChips();diff --git a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md b/docs/superpowers/plans/2026-09-29-scroll-content-part1.mdindex db82e259..0ef238a7 100644--- a/docs/superpowers/plans/2026-09-29-scroll-content-part1.md+++ b/docs/superpowers/plans/2026-09-29-scroll-content-part1.md@@ -971,7 +971,7 @@ None: leave out the `details.hb-options` block.- **What scrolling shows:** three groups: a grid of twelve cards (two columns on phones), a list of six people and a cluster of eight tags. As each group comes into the box, its items fade in and rise one after another, a short delay apart, in the chosen order. A group stays shown after that. On arrival the grid is in the box and plays at once; the list and the tags play as the box scrolls, each once half of it is in the box or its bottom edge is, so their cascades happen where the visitor can see them.- **Scroll distance and Play:** the groups' own height: about 1.3 box heights at 1280×800 (510px) and 2.7 on a phone (792px). Play reaches the list between about one and three seconds in (0.9 to 2.8 s: earlier in a tall box, later on a phone) and the tags about five seconds in (4.8 to 5.2 s), so their cascades end about when the six-second run does (only the grid plays on arrival, at every size).- **Every group plays** (shared rule 4): a group has no line. It plays once half of it is in the box, or its bottom edge has come into the box, so the last rows of a long group are never left hidden. The observers watch the group's items (`#grid`, `#list` and `#chips`), not the section around them (whose padding and heading made the cascade run before any item was on screen), and have a threshold every 5% (`Array.from({length:21},(_,i)=>i/20)`), so a jump straight to the end is not missed: a plain `threshold:.5` leaves the visible rows hidden at the end, and `[0,.5]` misses a jump from the top to the end. The box scrolls until the last group is wholly in view, so all three play at every size, and in Play 3 to 4 of the 6 list rows and all 8 tags are seen fading in at every size. Until a group plays, the items of it already in the box stay hidden (up to three list rows for about a second in Play).-- **Back to top, Play from the end, and settings:** Back to top, Play pressed with the box at its end, and every settings change rebuild the three groups hidden and watch them again, as today's Replay all groups did (without its scroll to the top). A new helper `rebuild()` clears the timers still pending from the last reveal, rebuilds the grid, list and chips hidden, and calls `attachObservers()`; the groups in the box then replay with the current settings. The page calls it on clicks on `#btn-top`, and on `#btn-scroll` when `stage.scrollTop >= stage.scrollHeight - stage.clientHeight - 2`, at once in the same click, as a settings change does, so the difference shows where the box is. It does not wait for the jump to the top: the new observers first report on the next frame, after the shared script has jumped the box, so the groups in view play from the top and the finished groups are never drawn there (with a 50ms delay they stayed on screen for about four frames). 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.+- **Back to top, Play from the end, and settings:** Back to top, Play pressed with the box at its end, and every settings change rebuild the three groups hidden and watch them again, as today's Replay all groups did (without its scroll to the top). A new helper `rebuild()` clears the timers still pending from the last reveal, rebuilds the grid, list and chips hidden, and calls `attachObservers()`; a group half in the box, or with its bottom edge in it, then plays at once with the current settings, and the others when they scroll in. The page calls it on clicks on `#btn-top`, and on `#btn-scroll` when `stage.scrollTop >= stage.scrollHeight - stage.clientHeight - 2`, at once in the same click, as a settings change does, so the difference shows where the box is. It does not wait for the jump to the top: the new observers first report on the next frame, after the shared script has jumped the box, so the groups in view play from the top and the finished groups are never drawn there (with a 50ms delay they stayed on screen for about four frames). 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, the items appear in the same order and with the same delays, but without moving (`.item{transition:none!important}`).- **Stage font:** site font.- **Stage:**@@ -1025,3 +1025,4 @@ None: leave out the `details.hb-options` block.- **README Production notes:** the Reduced motion bullet becomes: "**Reduced motion**: transitions are disabled under `prefers-reduced-motion`, so each item simply appears at its turn, without moving — the stagger is decorative, never load-bearing." The rest is unchanged.- **Category line:** `01.13 · Scroll-Based`- **Pager:** Previous: Reveal on Scroll (`../reveal-on-scroll/`) · Next: Horizontal Scroll (`../horizontal-scroll/`)+- **Final fix wave:** wording only. The page comments, the README and the rebuild line above no longer say that no visible row is left hidden or that the groups in the box replay. A group half in the box, or with its bottom edge in it, plays at once (also after a rebuild); a group less than half in view whose bottom edge is still below the box waits, hidden, until more of it scrolls in. Checked after a rebuild at 1280×800 and 375×812: a group 30% or 45% in view stays hidden and one 60% in view plays; a group 30% in view with its bottom edge in the box plays.