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: keep Pull to Refresh silent to screen readers while Show me refreshes

matinab371b50c9cc
diff --git a/animations/04-micro-interactions/pull-to-refresh/index.html b/animations/04-micro-interactions/pull-to-refresh/index.html
index 57662f2b..5d847380 100644
--- a/animations/04-micro-interactions/pull-to-refresh/index.html
+++ b/animations/04-micro-interactions/pull-to-refresh/index.html
@@ -275,7 +275,7 @@
indicator.classList.add('ready');
hint.textContent='Refreshing…';
spin.style.transform='';spin.classList.add('spinning');
- statusEl.textContent='Refreshing…';
+ if(!demoRefresh)statusEl.textContent='Refreshing…'; // Show me's refresh says nothing aloud
refreshFrom=performance.now();
refreshTimer=setTimeout(finishRefresh,dur);
}
@@ -287,9 +287,10 @@
spin.classList.remove('spinning');
pull=0;setY(0,true);drawSpin();
refreshing=false;
+ // Show me's refresh says nothing aloud, because nothing was really updated: its new item shows for 1.5 s, whatever Refresh time became,
+ // then the list is put back to its first six items
+ if(demoRefresh){demoRefresh=false;later(toRest,0,1500);return}
statusEl.textContent='Updated — 1 new item added.';
- // Show me's refresh: its new item shows for 1.5 s, whatever Refresh time became, then the list is put back to its first six items
- if(demoRefresh){demoRefresh=false;later(toRest,0,1500)}
}
// Show me: one run at a time. Every timer of the run goes through later(); stopRun() cancels the whole run.
@@ -299,7 +300,7 @@
const id=setTimeout(()=>{runTimers=runTimers.filter(t=>t!==id);fn()},move+(hold||0));
runTimers.push(id);
}
- // A run is under way while a timer or the drawn frame is pending, and while its own refresh is (demoRefresh: from the release to the clean-up).
+ // A run is under way while a timer or the drawn frame is pending, and while its own refresh is (demoRefresh: from the release until the new item arrives; the clean-up after it is a run timer).
function running(){return runTimers.length>0||runFrame!==0||demoRefresh}
function stopRun(){runTimers.forEach(clearTimeout);runTimers=[];cancelAnimationFrame(runFrame);runFrame=0;demoRefresh=false}
// A run starts with the first six items, the list at the top and nothing pulled, put there without animating: the transitions are
diff --git a/docs/superpowers/plans/2026-09-29-micro-content-part2.md b/docs/superpowers/plans/2026-09-29-micro-content-part2.md
index e7bc377f..5b150956 100644
--- a/docs/superpowers/plans/2026-09-29-micro-content-part2.md
+++ b/docs/superpowers/plans/2026-09-29-micro-content-part2.md
@@ -1094,12 +1094,14 @@ None: leave out the `details.hb-options` block.
- `later(release, 0, 850)`: `release()` marks the refresh as the run's (`demoRefresh=true`) and calls `startRefresh()`, as a release past the line does. It spins for Refresh time, adds the new item at the top and springs back; the list is back up about 2.4 s after the press at the defaults;
- when that refresh ends, `finishRefresh()` clears `demoRefresh` and runs `later(toRest, 0, 1500)`: the new item shows for 1.5 s, then `toRest()` puts the list back to its six first items, so the run ends at rest, as the preamble says of every run. The step is scheduled as the item arrives, not at the release, so a Refresh time changed during the refresh is counted and the item always shows its full 1.5 s. About 3.6 s after the press at the defaults (3.1 s at Short, 4.4 s at Long). The browser check needs this step: it compares the stage before and after a run, and under reduced motion nothing has run before it, so a run that leaves a seventh item could never match.
- `running()` is also true from the release until the clean-up has run (`demoRefresh`), and `stopRun()` also clears `demoRefresh`. On `hb:input`: `stopRun()`, so no clean-up follows. During the pull the list then springs back, `pull=0; setY(0,true); drawSpin()`, and the visitor's own drag takes over. Once the refresh has started, it finishes as usual and its new item stays (no spring back is drawn while `refreshing`).
+ A run's refresh is silent, as the preamble says of every run (it never announces anything that did not really happen): while `demoRefresh` is set, `startRefresh()` leaves the status line alone, and `finishRefresh()` schedules the clean-up and returns before it writes "Updated — 1 new item added.". The Refresh button, a real drag and a refresh the visitor has taken over (`stopRun()` clears `demoRefresh`, and the new item stays) announce as before.
+
+ `running()` is also true from the release until the new item arrives (`demoRefresh`); the clean-up after it is a run timer, so `running()` stays true until that has run. `stopRun()` also clears `demoRefresh`. On `hb:input`: `stopRun()`, so no clean-up follows. During the pull the list then springs back, `pull=0; setY(0,true); drawSpin()`, and the visitor's own drag takes over. Once the refresh has started, it finishes as usual and its new item stays (no spring back is drawn while `refreshing`).
- **Reset:** puts the list back to its six first items (the new ones go, `n` returns to 0) and scrolls it to the top, after `stopRun()`. A refresh under way ends at once: `startRefresh()` keeps its timer in `refreshTimer`, which Reset clears; then the spinner stops, `refreshing` becomes false and the list is set back to 0 without a transition.
- **Slow motion:** none.
- **Reduced motion:** the demo's rules stay: the list snaps back without its tween, and new items appear without sliding in.
- **Touch:** already Pointer Events, claimed only at the top of the list, with `touchmove` blocked once the pull is claimed. The list still scrolls normally.
-- **Pull curve:** today's `resist()` moved the list at 1/Resistance of the finger from the first pixel, and the line was 1.83 × Pull distance × Resistance of finger travel away: 235px at Medium/Medium, about the whole height of the feed (201px on the 260px stage, 241px on phones, 268 to 381px on the others). At the defaults a drag that stayed inside the stage refreshed only at 1280×800. The curve becomes `function resist(dy){const max=threshold*(1+2.4/resistance);return max*dy/(dy+max)}`: the list follows the finger 1:1 at first and stiffens as the drag grows, and Resistance only sets how fast. Pull distance is still the pull after the curve, and the line is `threshold × (1 + resistance / 2.4)` of finger travel away. For Short · Medium · Long that is 68 · 91 · 113px at Low, 88 · 117 · 147px at Medium and 108 · 144 · 180px at High (checked in Chrome: 3px less springs back, 3px more refreshes). A drag from the middle of the first card to 4px above the stage's bottom edge (about 160px of room on the 260px stages, 200px on phones, 227px at 1366×657, 280px at 1280×800) therefore refreshes at the defaults on every stage, with a mouse and with a finger, and a 60px drag still springs back. Every combination refreshes inside the stage except Long/High (180px) on the two 260px stages, the "long drag" the README names. Show me sets `pull` itself, so it does not change.
+- **Pull curve:** today's `resist()` moved the list at 1/Resistance of the finger from the first pixel, and the line was 1.83 × Pull distance × Resistance of finger travel away: 235px at Medium/Medium, about the whole height of the feed (201px on the 260px stage, 241px on phones, 268 to 381px on the others). At the defaults a drag that stayed inside the stage refreshed only where the feed is tall: 1280×800, 1440×900, 1024×768 and 768×1024. The curve becomes `function resist(dy){const max=threshold*(1+2.4/resistance);return max*dy/(dy+max)}`: the list follows the finger 1:1 at first and stiffens as the drag grows, and Resistance only sets how fast. Pull distance is still the pull after the curve, and the line is `threshold × (1 + resistance / 2.4)` of finger travel away. For Short · Medium · Long that is 68 · 91 · 113px at Low, 88 · 117 · 147px at Medium and 108 · 144 · 180px at High (checked in Chrome: 3px less springs back, 3px more refreshes). A drag from the middle of the first card to 4px above the stage's bottom edge (about 160px of room on the 260px stages, 170px at 1024×600, 200px on phones, 227px at 1366×657, 280px at 1280×800) therefore refreshes at the defaults on every stage, with a mouse and with a finger, and a 60px drag still springs back. Every combination refreshes inside the stage except Long/High (180px) on the 260px stages (1280×590, 1366×560, 667×375, 812×375) and at 1024×600 (feed 211px): that is the "long drag" the README names. Show me sets `pull` itself, so it does not change.
- **Stage font:** site font. The new Refresh button gets `font-family:inherit`. `.indicator` and `.meta .s` go up to 11px (were 10px).
- **Stage:** the list scrolls inside its own box. The stage's own rule keeps `position:relative;overflow:hidden` and adds `display:flex;flex-direction:column`.
- The stage becomes a small app screen. At the top is a header bar with the title "Updates" and, at its right, a Refresh button: a ↻ icon, `aria-label="Refresh"`, 44×44px, calling `startRefresh()`. It is today's "↻ Refresh now" moved from the old panel onto the stage; the README calls it the keyboard way to refresh.