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: sync the Page Transitions content sheet with Elastic Transition's fixed-step spring

matin956a13baf731
diff --git a/docs/superpowers/plans/2026-09-29-transitions-content.md b/docs/superpowers/plans/2026-09-29-transitions-content.md
index 3f445ad2..5df1da6f 100644
--- a/docs/superpowers/plans/2026-09-29-transitions-content.md
+++ b/docs/superpowers/plans/2026-09-29-transitions-content.md
@@ -758,7 +758,7 @@ None: leave out the `details.hb-options` block.
- **Reset:** yes. Home at once.
- **Slow motion:**
- Planned path: the keyframe animations' `dur` and the timer that waits for them are multiplied by 3.
- - Live spring: the old page's 300ms slide-out and the 100ms start delay are multiplied by 3, and the spring's time step is divided by 3 (`dt`, after its 50ms limit), so the spring moves at a third of its speed.
+ - Live spring: the old page's 300ms slide-out and the 100ms start delay are multiplied by 3, and the time each frame adds to the spring is divided by 3 (after its 50ms limit), so the spring makes the same bounce three times slower.
- **Reduced motion:** the demo's rule `.page{transition:none!important;animation:none!important}` and its `motionOk` branch stay: the pages swap at once. Show me swaps to Work and back.
- **Stage font:** site font.
- **Stage:**
@@ -774,19 +774,19 @@ None: leave out the `details.hb-options` block.
|---|---|---|---|---|---|
| How it bounces | Choice buttons | Planned path · Live spring | Planned path | A planned path is cheap; a live spring feels more physical. | `mode`: `'css'` / `'spring'` |
| Bounce size | Choice buttons | Small · Medium · Large | Medium | How far the page goes past its place before settling. | planned path: `overshoot` 30 / 60 / 100 (passed to `buildKF()`); live spring: `damping` from the table below |
-| Speed | Choice buttons | Slow · Normal · Fast | Normal | How quickly the page springs into place. | planned path: `dur` 1400 / 900 / 550 (ms); live spring: `stiffness` 70 / 180 / 500 |
+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How quickly the page springs into place. | planned path: `dur` 1400 / 900 / 550 (ms); live spring: `stiffness` 75 / 200 / 640 |
**More options**
None: leave out the `details.hb-options` block.
-Live-spring damping, measured with the demo's own spring loop. The loop takes one step per frame at 60 frames a second: the first frame has no time step, and the loop stops when position and speed are both under 0.5. A loop that steps once per frame damps much more than the textbook formula predicts, so each value was found by running it. For each speed and size, the whole number shown gives the overshoot nearest the planned path's for the same size (3.6%, 7.2% and 12% of the width); the overshoot it gives is in brackets. The spring settles within 1.3s. Normal and Medium become 180 and 16 (owner decision): today's 20 goes only 1.1% past its place, which barely shows. At 120 frames a second, or in slow motion, the steps are smaller and every bounce is a little larger (up to 6.7%, 10.7% and 13.9% for Small, Medium and Large); the three sizes stay apart. At 30 frames a second the steps are larger and Small barely bounces (1.4%, 1.2% and 0% at Slow, Normal and Fast); the README's Production notes say so. Every value lies inside the old sliders' ranges (stiffness 50–500, damping 5–50).
+Live-spring stiffness and damping, measured with the demo's own spring loop. The loop moves the spring in fixed steps of 1/120 s: each frame adds the time since the last one to a running total (at most 50ms, and a third of it in slow motion; the first frame adds none) and takes as many steps as that covers, at most 8, and the loop stops when position and speed are both under 0.5. Stepping the spring in whole steps calms it more than the textbook formula predicts, so each value was found by running the loop. The stiffness is 75, 200 and 640 for Slow, Normal and Fast (it was 70, 180 and 500), and the damping is in the table (one decimal now). The values were found so that the overshoot at 60 frames a second stays where the earlier one-step-per-frame loop had it (Small 2.6, 3.5 and 3.9%, Medium 8.1, 7.2 and 7.9%, Large 12.0, 12.3 and 11.2%, at Slow, Normal and Fast; each new value is within about 0.1 point of these), about as far past its place as the planned path goes for the same size (3.6%, 7.2% and 12% of the width); the overshoot it gives is in brackets. The spring settles within 1.3s. Normal and Medium are 200 and 17.4: they give the bounce that the owner-decided 180 and 16 gave the one-step-per-frame loop (today's 20 goes only 1.1% past its place, which barely shows). The bounce is now the same at any frame rate: at 30, 48, 72, 90, 120, 144, 165 and 240 frames a second, and in slow motion, each overshoot is within 0.4 point of the one in brackets. The damping lies inside the old sliders' range (5–50); the stiffness lies inside theirs (50–500) except for Fast, whose 640 is above it.
-| Bounce size | Slow (70) | Normal (180) | Fast (500) |
+| Bounce size | Slow (75) | Normal (200) | Fast (640) |
|---|---|---|---|
-| Small | 12 (2.6%) | 18 (3.5%) | 28 (3.9%) |
-| Medium | 10 (8.1%) | 16 (7.2%) | 25 (7.9%) |
-| Large | 9 (12.0%) | 14 (12.3%) | 23 (11.2%) |
+| Small | 12.8 (2.5%) | 19.7 (3.6%) | 33.6 (3.9%) |
+| Medium | 10.6 (8.0%) | 17.4 (7.3%) | 29.7 (7.9%) |
+| Large | 9.5 (12.0%) | 15.2 (12.3%) | 27.2 (11.2%) |
- **Removed:**
- The note.
@@ -798,7 +798,7 @@ Live-spring damping, measured with the demo's own spring loop. The loop takes on
- **Good for:** Playful apps · Panels and drawers · Games · **Avoid on:** Formal sites
- **Prompt:**
- > Add an elastic transition to [the pages or panels you want to move between]. The new page should slide in from the side, go a little past its place and spring back before settling, as if pulled by a rubber band, while the old page slides away. The bounce can be planned ahead as a fixed path, which is cheap, or worked out live with a simple spring, which can react if the visitor interrupts it; with a live spring, limit each time step so one slow frame cannot throw it off. If the visitor has reduced motion turned on, switch pages without movement. Match the settings listed below.
+ > Add an elastic transition to [the pages or panels you want to move between]. The new page should slide in from the side, go a little past its place and spring back before settling, as if pulled by a rubber band, while the old page slides away. The bounce can be planned ahead as a fixed path, which is cheap, or worked out live with a simple spring, which can react if the visitor interrupts it; with a live spring, advance it in small fixed time steps so it moves the same on every screen, and limit the time one frame adds so a slow frame cannot throw it off. If the visitor has reduced motion turned on, switch pages without movement. Match the settings listed below.
- **README What it is:** rewritten:
@@ -808,7 +808,7 @@ Live-spring damping, measured with the demo's own spring loop. The loop takes on
| Parameter | Default | Effect |
|-----------|---------|--------|
- | How it bounces | Planned path | A planned path plays a bounce decided in advance, which is cheap; a live spring works out the movement on every frame, which feels physical and can react to interruptions |
+ | How it bounces | Planned path | A planned path plays a bounce decided in advance, which is cheap; a live spring works out the movement in small fixed time steps, which feels physical and can react to interruptions |
| Bounce size | Medium | How far the page goes past its place before settling; with a live spring, a bigger bounce means less damping, so it swings for longer |
| Speed | Normal | How quickly it settles: on the planned path slow is 1400ms, normal 900ms and fast 550ms; with a live spring, a faster speed is a stiffer spring |
@@ -818,14 +818,15 @@ Live-spring damping, measured with the demo's own spring loop. The loop takes on
- [FLIP Technique](../flip-technique/) — elements glide to their new places
- [Morph Transition](../morph-transition/) — a shape changes between pages
- **README How it works:**
- - The first paragraph names the two ways as on the page: "This demo offers two modes. The CSS mode writes" becomes "This demo offers two ways to bounce. The planned path writes"; "with the overshoot amount scaled by a control" becomes "with the overshoot amount set by Bounce size"; and "The JS mode integrates" becomes "The live spring integrates".
+ - The first paragraph names the two ways as on the page: "This demo offers two modes. The CSS mode writes" becomes "This demo offers two ways to bounce. The planned path writes"; "with the overshoot amount scaled by a control" becomes "with the overshoot amount set by Bounce size"; and "The JS mode integrates" becomes "The live spring integrates an actual spring in fixed steps of 1/120 of a second: force equals `-stiffness × displacement − damping × velocity`, each frame takes as many steps as the time that has passed needs, and the loop runs until both position and velocity fall below a threshold."
- In the snippet, `let pos = -100, vel = 0, target = 0; // start off-screen right` becomes `let pos = 100, vel = 0, target = 0; // start off-screen right`, as in the demo.
- - The snippet's first line reads `function doSpring(o, n, stiffness, damping) {`, the names the page gives the old and the new page plus the two spring values it reads (so the snippet runs as written). It read `function doSpring(prev, next) {`, so the `n` the loop moves was not defined.
- - In the last paragraph, the sentence "Recorded positions are plotted to a small canvas so the overshoot-and-settle curve is visible." is replaced by: "On the demo page, Speed and Bounce size set both ways of bouncing: the planned path's length (1400, 900 or 550ms) and overshoot (30, 60 or 100), or the live spring's stiffness (70, 180 or 500) and damping. The damping values were found by running this loop at 60 frames a second, so the spring goes about as far past its place as the planned path does (about 3.6%, 7.2% and 12% of the width). Moving the spring one step per frame calms it more than the usual spring formula expects, so the values were measured rather than worked out."
-- **README Production notes:** a bullet goes in after "**Clamp the time step.**": "**Frame rate.** The demo moves its spring one step per frame, so how far it bounces depends on the frame rate: at 30 frames a second the small bounce hardly shows, and at 120 it is a little larger. A spring that steps by time instead — fixed small steps, as many as the time that has passed needs — bounces the same at any frame rate." The rest is unchanged.
+ - The snippet's `doSpring` line reads `function doSpring(o, n, stiffness, damping) {`, the names the page gives the old and the new page plus the two spring values it reads (so the snippet runs as written); a `const STEP = 1 / 120;` line comes before it. It read `function doSpring(prev, next) {`, so the `n` the loop moves was not defined.
+ - In the last paragraph, the sentence "The `dt` is clamped to 50ms so a dropped frame or a backgrounded tab cannot inject a huge time step that would make the spring explode." is replaced by "A frame adds the time since the last one to `acc`, never more than 50ms, which keeps the spring from jumping ahead after a pause, a slow frame or a backgrounded tab, and then spends it in whole steps. The first frame adds nothing, because there is no earlier frame to measure from. The last step can end a little after the frame, so the page is drawn between the last two steps, at the frame's own time; a frame that fits no whole step still moves the page.", and the sentence "Recorded positions are plotted to a small canvas so the overshoot-and-settle curve is visible." is replaced by: "On the demo page, Speed and Bounce size set both ways of bouncing: the planned path's length (1400, 900 or 550ms) and overshoot (30, 60 or 100), or the live spring's stiffness (75, 200 or 640) and damping. These values were found by running this loop, so the spring goes about as far past its place as the planned path does (about 3.6%, 7.2% and 12% of the width). Stepping the spring in whole steps calms it more than the usual spring formula expects, so the values were measured rather than worked out."
+- **README Production notes:** the "**Clamp the time step.**" bullet becomes "**Clamp the time a frame adds.** One step of the raw frame delta is the classic spring bug: after one long frame `pos` shoots to infinity. Fixed steps avoid that, but the time a frame adds still needs a limit: added whole, a pause or a slow frame would make the spring jump ahead, and the bounce would be over in one frame. The 50ms clamp (`0.05` seconds in the snippet) keeps it moving on from where it was, and it also keeps a frame to a handful of steps.", and a bullet goes in after it: "**Frame rate.** The demo moves its spring in fixed steps of 1/120 of a second, as many as the time that has passed needs, so it bounces the same at any frame rate. A spring that takes one step per frame does not: at 30 frames a second a small bounce hardly shows, and at 120 it is a little larger. Draw the page between the last two steps, or a frame that fits no whole step shows the spring standing still." The rest is unchanged.
- **Category line:** `03.09 · Page Transitions`
- **Pager:** Previous: Blur Transition (`../blur-transition/`) · Next: Portal / Tunnel Zoom (`../portal-zoom/`)
- **Final fix wave:** `rest()` sets `inert` on a page that is not on show, so a screen reader reads only the page on show and Tab cannot enter a hidden one; the planned path and the live spring both end in `rest()`. The name of the page on show carries `aria-current="page"` and the other two `"false"` (`updateNav`).
+- **Frame-rate fix (wrap-up):** the live spring moves in fixed steps of 1/120 s, so its bounce is the same at any frame rate. Each frame adds the time since the last one to `acc` (`Math.min(now - lastTime, 50) / 1000`, divided by 3 in slow motion; the first frame adds none) and `tick` takes as many steps as `acc` covers, at most 8, dropping the time left if that limit is reached; the last step can end a little after the frame, so the page is drawn between the last two steps (`shown = pos + (before - pos) * (-acc / STEP)`). The stiffness is now 75 / 200 / 640 and the damping table is measured again (above), so the overshoot at 60 Hz is within about 0.1 point of the one-step-per-frame table, and at any other rate within 0.4 point. Slow motion is now the normal bounce three times slower; before, its smaller steps made it bounce more (Small with Normal: 5.1% in slow motion, 3.6% now, the same as at normal speed). README: the snippet and its paragraph in How it works, the How it bounces row of Key parameters, and the Production notes on the time a frame adds and on the frame rate. The prompt says the spring advances "in small fixed time steps" and that the time one frame adds is limited.
---