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.

Merge main into feat/famous-effects before its release, with the generated files written again

matind727a40817ae
diff --cc CLAUDE.md
index c54bcf78,22afe4bd..771f183a
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@@ -304,12 -266,9 +310,14 @@@ Run both before calling a page done. Th
- **Home page:** `node tools/check-pages.mjs --base http://127.0.0.1:<port> home` checks the home page at the same
six setups (six `ok` lines). Its desktop run also tries the tiles, the search and Show all, and compares
Copy prompt on the home page with every page's own; its phone run tries a tile and the slim bar, and its
- reduced-motion run checks that nothing moves. Run it after changing any page's settings or prompt.
+ reduced-motion run checks that nothing moves. Every setup also opens the finder (`?view=find`): its desktop run works the answers, See N matches,
+ Start over, Show all, the Not here? link and the ways in, and its reduced-motion run checks that every How picture holds a still.
+ Run it after changing any page's settings or prompt.
+- **Famous effects:** `node tools/check-pages.mjs --base http://127.0.0.1:<port> famous` checks `famous/` at the same six
+ setups (six `ok` lines): the first screen, overflow and touch targets; its desktop run presses each jump link, watches
+ each entry's previews and presses each Copy prompt (twice more with the clipboard refused or missing); its
+ reduced-motion run checks that nothing moves, that every preview holds a still frame that shows something and that
+ Copy prompt's message does not slide. Run it after changing that page, its cards or a preview it shows.
## Out of scope
- Backend code, databases, APIs.
diff --cc CONTRIBUTING.md
index 92d02c17,ed8d905b..451edb97
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@@ -303,14 -310,12 +310,17 @@@ The home page has a check of its own
`node tools/check-pages.mjs --base http://127.0.0.1:<port> home`. It checks the layout at the
six setups. Its desktop run also tries the tiles, the search and Show all, and compares Copy
prompt on the home page with every page's own prompt and default settings; its phone run tries
- a tile and the slim bar, and its reduced-motion run checks that nothing moves. Run it after
- changing any page's settings or prompt.
+ a tile and the slim bar, and its reduced-motion run checks that nothing moves.
+ Every setup also opens the finder (`?view=find`): its desktop run works the answers, See N
+ matches, Start over, Show all, the Not here? link and the ways in, and its reduced-motion run
+ checks that every How picture holds a still.
+ Run it after changing any page's settings or prompt.
+The Famous effects page has one too: `node tools/check-pages.mjs --base http://127.0.0.1:<port> famous`. It checks the
+layout at the six setups, presses each jump link and each Copy prompt and watches the previews; its reduced-motion run
+checks that nothing moves. Its previews come from the home page: after changing a preview it shows, run
+`node tools/make-famous.mjs`.
+
## Writing style
Prose, not bullet-soup. Show, then explain. Avoid hype ("stunning", "powerful") — describe
diff --cc sitemap.xml
index ed96ef1d,53aecb5f..1b4c2a36
--- a/sitemap.xml
+++ b/sitemap.xml
@@@ -1,7 -1,6 +1,7 @@@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
- <url><loc>https://matinmonshizadeh.github.io/animation-handbook/</loc><lastmod>2026-10-13</lastmod><changefreq>weekly</changefreq><priority>1.0</priority></url>
+ <url><loc>https://matinmonshizadeh.github.io/animation-handbook/</loc><lastmod>2026-10-15</lastmod><changefreq>weekly</changefreq><priority>1.0</priority></url>
+ <url><loc>https://matinmonshizadeh.github.io/animation-handbook/famous/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/parallax-depth-of-field/</loc><lastmod>2026-10-12</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/parallax-scrolling/</loc><lastmod>2026-10-12</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/01-scroll-based/reverse-scrolling-columns/</loc><lastmod>2026-10-12</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
diff --cc tools/check-pages.mjs
index adf32f01,0082d6f0..ad582b50
--- a/tools/check-pages.mjs
+++ b/tools/check-pages.mjs
@@@ -946,228 -907,272 +946,494 @@@ async function homeMotionProblems()
return problems;
}
+ // ── The finder (?view=find) ──
+ // Every home setup also opens the finder (finderLayoutProblems). The desktop run works it (finderViewProblems) and the
+ // reduced-motion run holds it still (finderMotionProblems). These are the finder's own steps; the home checks above are unchanged.
+
+ // Opens an address of the site as a new visit does; a load that does not finish is a problem of its own.
+ async function openHome(query, problems) {
+ let onLoad;
+ const loaded = new Promise(resolve => { onLoad = msg => { if (msg.method === 'Page.loadEventFired') resolve(); }; listeners.add(onLoad); });
+ await send('Page.navigate', { url: `${BASE}/${query}` });
+ try { await withTimeout(loaded, LOAD_TIMEOUT); } catch { problems.push(`finder: ${query || 'the home page'} did not load`); }
+ listeners.delete(onLoad);
+ await sleep(300);
+ }
+
+ // A real mouse click at the middle of the element the selector finds, once it is scrolled to the middle of the window. Returns
+ // what covers that point when it is not the element or something inside it (covered), and where the page was scrolled to just
+ // before the click (scrolled), so the caller can tell whether the click scrolled the page.
+ async function clickAt(selector) {
+ const spot = await evaluate(`(() => {
+ const el = document.querySelector(${JSON.stringify(selector)});
+ if (!el) return { covered: 'nothing: the page has no such element' };
+ el.scrollIntoView({ block: 'center' });
+ const b = el.getBoundingClientRect(), x = b.left + b.width / 2, y = b.top + b.height / 2, hit = document.elementFromPoint(x, y);
+ return { x, y, scrolled: Math.round(scrollY),
+ covered: el.contains(hit) ? '' : hit ? hit.tagName.toLowerCase() + (hit.getAttribute('class') ? '.' + hit.getAttribute('class').split(' ')[0] : '') : 'nothing' };
+ })()`);
+ if (spot.covered) return { covered: spot.covered, scrolled: 0 };
+ await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: spot.x, y: spot.y, button: 'none' });
+ for (const type of ['mousePressed', 'mouseReleased']) await send('Input.dispatchMouseEvent', { type, x: spot.x, y: spot.y, button: 'left', clickCount: 1 });
+ return { covered: '', scrolled: spot.scrolled };
+ }
+
+ // The finder at every setup. On the start page the Find button sits under the Popular line (on a phone 44px tall or more and as
+ // wide as the column). The finder, opened with three answers in the address: the hero and the place tiles give way to it, its
+ // cards and the Not here? panel show, nothing overflows sideways, Finder is in the top bar above 600px and the bar's links fit
+ // beside the brand, the phone bar stays away and, on phones, every answer, button and link of the finder and its results is at
+ // least 44×44. Screenshots of the finder (the window and the whole page) are saved beside the others.
+ async function finderLayoutProblems(name, setup) {
+ const problems = [];
+ await openHome('', problems);
+ const cta = await evaluate(`(() => {
+ const a = document.querySelector('.find-cta'), pop = document.querySelector('.home-hero .pop'), hero = document.querySelector('.home-hero');
+ if (!a || !a.getClientRects().length) return null;
+ const b = a.getBoundingClientRect();
+ return { width: Math.round(b.width), height: Math.round(b.height), under: !!pop && b.top >= pop.getBoundingClientRect().bottom - 1,
+ full: Math.abs(b.width - hero.getBoundingClientRect().width) <= 1 };
+ })()`);
+ if (!cta) problems.push('finder: no Find button on the start page');
+ else {
+ if (!cta.under) problems.push('finder: the Find button is not under the Popular line');
+ if (setup.width <= 600 && (cta.height < 44 || !cta.full)) problems.push(`finder: on a phone the Find button is ${cta.width}x${cta.height}${cta.full ? '' : ', not as wide as the column'}`);
+ }
+ await openHome('?view=find&what=text&when=load&how=stagger', problems);
+ await sleep(500);
+ const found = await evaluate(`(() => {
+ const r = el => el.getBoundingClientRect(), shown = el => !!el && !!el.getClientRects().length, out = [];
+ if (shown(document.querySelector('.home-hero')) || shown(document.getElementById('places'))) out.push('the hero or the place tiles show in the finder');
+ if (!shown(document.getElementById('finder'))) out.push('the finder does not show');
+ if (!document.querySelectorAll('#cards .card').length) out.push('no cards for Text or numbers · When the page opened · One after another');
+ if (!shown(document.getElementById('find-not'))) out.push('no Not here? panel');
+ if (document.documentElement.scrollWidth > document.documentElement.clientWidth + 1) out.push('horizontal overflow');
+ if (innerWidth > 600 && !shown(document.getElementById('nav-find'))) out.push('no Finder link in the top bar');
+ const brand = document.querySelector('.top .brand span'), first = [...document.querySelectorAll('.top .nav > *')].find(shown);
+ if (brand && first && r(brand).right > r(first).left - 8) out.push('the top bar links do not fit beside the brand');
+ if (getComputedStyle(document.getElementById('pinbar')).display !== 'none') out.push('the phone bar shows');
+ if (innerWidth <= 600) {
+ const small = [...document.querySelectorAll('#finder .fd-a, #finder button, #find-not a, #find-not button, #cards .card .copy, #more button')]
+ .filter(shown).filter(el => { const b = r(el); return b.width < 44 || b.height < 44; })
+ .map(el => (el.id || el.tagName.toLowerCase() + '.' + (el.getAttribute('class') || '').split(' ')[0]) + ' ' + Math.round(r(el).width) + 'x' + Math.round(r(el).height));
+ if (small.length) out.push('small targets: ' + small.slice(0, 6).join(', ') + (small.length > 6 ? ' and ' + (small.length - 6) + ' more' : ''));
+ }
+ return out;
+ })()`);
+ problems.push(...found.map(p => `finder: ${p}`));
+ const shot = await send('Page.captureScreenshot', { format: 'png' });
+ writeFileSync(join(OUT, `${name}-${setup.name}-finder.png`), Buffer.from(shot.data, 'base64'));
+ const { cssContentSize } = await send('Page.getLayoutMetrics');
+ const full = await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: true,
+ clip: { x: 0, y: 0, width: setup.width, height: Math.ceil(cssContentSize.height), scale: 1 } });
+ writeFileSync(join(OUT, `${name}-${setup.name}-finder-full.png`), Buffer.from(full.data, 'base64'));
+ return problems;
+ }
+
+ // The finder, desktop run. ?view=find opens with three questions, nothing chosen, the heading "Your matches", the line asking for
+ // an answer and no cards, the tab's title and the Finder link marked as the current page. Real clicks on answers change the cards,
+ // replace the address (no history step), never scroll the page and leave keyboard focus on the answer; with A menu or form · When I
+ // scrolled · Slid, Hide-on-Scroll Header is among the first six (case 22 of the finder's test set). The Not here? link is the form's
+ // address for those answers, in a new tab. See N matches brings the results heading into view with keyboard focus; Start over
+ // clears the answers and the cards, goes back to ?view=find, scrolls to the top and puts keyboard focus on the finder's heading.
+ // With more than twelve matches Show all shows the rest, only replacing the address, and puts keyboard focus on the thirteenth card.
+ // An address opened directly shows the same answers and cards as the clicks. The Find button and the Finder link each enter the
+ // finder with one history step and keyboard focus on its heading; after an answer, Back returns to the start in one press, and as
+ // the answer that had keyboard focus is hidden there, focus goes to the results heading. Describe it in words goes back to the start
+ // with keyboard focus in the search box.
+ async function finderViewProblems() {
+ const problems = [];
+ const FIND_TITLE = 'Find an animation you saw — Animation Handbook', ASK = 'Answer a question above, and the animations that match show here.';
+ // See N matches and the results line once something matches, each number with its own word ("See 1 match", "1 best match and
+ // 9 close matches."), never "See 1 matches"; tests/finder.test.js holds both to the page's own lines.
+ const FIND_SEE = /^See (?:1 match|(?!1 )\d+ matches)$/;
+ const FIND_LINE = /^(?:1 best match|(?!1 )\d+ best matches)(?: and (?:1 close match|(?!1 )\d+ close matches))?\.$|^No animation fits all your answers\. These come close\.$/;
+ const look = () => evaluate(`(() => {
+ const $ = id => document.getElementById(id), shown = el => !!el && !!el.getClientRects().length;
+ const links = [...document.querySelectorAll('#cards .card .title a')], a = document.activeElement;
+ return { hero: shown(document.querySelector('.home-hero')), tiles: shown($('places')), finder: shown($('finder')),
+ questions: document.querySelectorAll('#finder fieldset').length,
+ checked: [...document.querySelectorAll('#finder .fd-r:checked')].map(r => r.name.slice(3) + '=' + r.value).join('&'),
+ title: $('results-title').textContent, sub: $('results-sub').textContent, names: links.map(l => l.textContent),
+ more: $('more').hidden ? '' : $('more-label').textContent, search: location.search, steps: history.length, tab: document.title,
+ current: $('nav-find') ? $('nav-find').getAttribute('aria-current') : 'no Finder link',
+ see: shown($('find-see')) ? $('find-see').textContent : '', notHere: shown($('find-not')),
+ focus: a.id || (links.includes(a) ? 'card link ' + (links.indexOf(a) + 1) : a.tagName.toLowerCase()), scrolled: Math.round(scrollY) };
+ })()`);
+ const press = selector => evaluate(`(() => { const el = document.querySelector(${JSON.stringify(selector)}); if (el) { el.focus(); el.click(); } return !!el; })()`);
+ const answer = (question, key) => `#finder .fd-a:has(.fd-r[name="fd-${question}"][value="${key}"])`;
+ const still = () => evaluate(`new Promise(done => { let last = scrollY, same = 0;
+ const tick = () => { same = scrollY === last ? same + 1 : 0; last = scrollY; if (same >= 3) done(); else setTimeout(tick, 100); };
+ setTimeout(tick, 100); })`);
+ // A real click on an answer: then the line has been written (400 ms), the page must not have scrolled and keyboard focus must be
+ // where the click put it, on the answer.
+ const pick = async (question, key) => {
+ const spot = await clickAt(answer(question, key));
+ if (spot.covered) { problems.push(`finder: the answer ${question}=${key} is covered by ${spot.covered}`); return; }
+ await sleep(700);
+ const y = await evaluate('Math.round(scrollY)');
+ if (Math.abs(y - spot.scrolled) > 1) problems.push(`finder: picking ${question}=${key} scrolled the page from ${spot.scrolled}px to ${y}px`);
+ const on = await evaluate(`(() => { const a = document.activeElement; return a.matches('.fd-r') ? a.name.slice(3) + '=' + a.value : a.id || a.tagName.toLowerCase(); })()`);
+ if (on !== `${question}=${key}`) problems.push(`finder: picking ${question}=${key} moved keyboard focus away from the answer, to ${on}`);
+ };
+
+ // History steps are counted from a cleared history: Chrome keeps 50 entries at most (the run's own page loads have filled them, and a
+ // step then adds nothing to history.length), and a step taken after Back drops the entries ahead of the current one (so it adds nothing
+ // either). Page.resetNavigationHistory leaves the page being shown as the only entry.
+ const clearHistory = () => send('Page.resetNavigationHistory');
+ await clearHistory();
+ await openHome('?view=find', problems);
+ let s = await look();
+ if (s.hero || s.tiles || !s.finder || s.questions !== 3 || s.checked || s.names.length || s.title !== 'Your matches' || s.sub !== ASK ||
+ s.tab !== FIND_TITLE || s.current !== 'page' || s.see || s.notHere) problems.push(`finder, ?view=find: ${JSON.stringify(s)}`);
+ const steps = s.steps;
+ for (const [question, key] of [['what', 'menu'], ['when', 'scroll'], ['how', 'slide']]) await pick(question, key);
+ s = await look();
+ if (s.checked !== 'what=menu&when=scroll&how=slide' || s.search !== '?view=find&what=menu&when=scroll&how=slide' || s.steps !== steps) {
+ problems.push(`finder, three answers: chosen ${s.checked}, the address ${s.search}, ${s.steps - steps} history steps added`);
+ }
+ if (!s.names.slice(0, 6).includes('Hide-on-Scroll Header')) problems.push(`finder: A menu or form · When I scrolled · Slid shows ${s.names.slice(0, 6).join(', ') || 'no cards'} first, not Hide-on-Scroll Header`);
+ if (!FIND_SEE.test(s.see) || !s.notHere) problems.push(`finder: See N matches reads "${s.see}", Not here? is ${s.notHere ? 'shown' : 'hidden'}`);
+ if (!FIND_LINE.test(s.sub)) problems.push(`finder: the results line "${s.sub}"`);
+ const link = await evaluate(`(() => { const a = document.getElementById('find-gh');
+ return a ? { href: new URL(a.href).href, want: new URL(findIssueURL({ what: 'menu', when: 'scroll', how: 'slide' })).href, target: a.target, rel: a.rel } : null; })()`);
+ if (!link || link.href !== link.want || !link.href.startsWith('https://github.com/matinmonshizadeh/animation-handbook/issues/new?template=animation_not_here.yml&') ||
+ link.target !== '_blank' || link.rel !== 'noopener') problems.push(`finder: the Not here? link ${JSON.stringify(link)}`);
+ const picked = s.names;
+ await press('#find-see');
+ await still();
+ const seen = await evaluate(`(() => { const t = document.getElementById('results-title'), top = Math.round(t.getBoundingClientRect().top);
+ return { top, shown: top >= 0 && top <= innerHeight * .6, focus: document.activeElement === t }; })()`);
+ if (!seen.shown || !seen.focus) problems.push(`finder: after See N matches the results heading is at ${seen.top}px${seen.focus ? '' : ', without keyboard focus'}`);
+ await press('#find-reset');
+ await still();
+ await sleep(500);
+ s = await look();
+ if (s.checked || s.names.length || s.search !== '?view=find' || s.sub !== ASK || s.focus !== 'find-title' || s.see || s.notHere || s.steps !== steps || s.scrolled > 1) {
+ problems.push(`finder, Start over: ${JSON.stringify(s)}${s.scrolled > 1 ? ` (the page is ${s.scrolled}px down, not at the top)` : ''}`);
+ }
+ // More than twelve matches: twelve cards, then Show all shows every one and puts keyboard focus on the thirteenth.
+ await openHome('?view=find&what=background', problems);
+ s = await look();
+ const total = Number((s.more.match(/^Show all (\d+) matches$/) || [])[1]);
+ if (!(total > 12) || s.names.length !== 12) problems.push(`finder, The background: ${s.names.length} cards and the button "${s.more}" (twelve cards, then Show all for the rest)`);
+ else {
+ const opened = s.steps;
+ await press('#more-btn');
+ await sleep(400);
+ s = await look();
+ if (s.names.length !== total || s.search !== '?view=find&what=background&all=1' || s.focus !== 'card link 13' || s.more || s.steps !== opened) {
+ problems.push(`finder, Show all: ${s.names.length} of ${total} cards, the address ${s.search}, keyboard focus on ${s.focus}, ${s.steps - opened} history steps added (it only replaces the address), ${s.more ? `the button still reads "${s.more}"` : 'the button is gone'}`);
+ }
+ }
+ // An address opened directly shows the same answers and cards as the clicks did.
+ await openHome('?view=find&what=menu&when=scroll&how=slide', problems);
+ s = await look();
+ if (s.checked !== 'what=menu&when=scroll&how=slide' || s.names.join() !== picked.join()) problems.push(`finder, the address opened directly: chosen ${s.checked}, cards ${s.names.join(', ')}; after the clicks: ${picked.join(', ')}`);
+ // The ways in: one history step, keyboard focus on the finder's heading; after an answer, Back returns to the start in one press.
+ for (const [what, selector] of [['Find button', '.find-cta'], ['Finder link', '#nav-find']]) {
+ await openHome('', problems);
+ await clearHistory();
+ const before = await evaluate('history.length');
+ if (!(await press(selector))) { problems.push(`finder: no ${what}`); continue; }
+ await still();
+ s = await look();
+ if (s.search !== '?view=find' || s.steps !== before + 1 || s.focus !== 'find-title' || s.hero || !s.finder) problems.push(`finder, the ${what}: ${JSON.stringify(s)}`);
+ await pick('what', 'text');
+ await evaluate('history.back()');
+ await sleep(700);
+ s = await look();
+ if (s.search !== '' || !s.hero || s.finder || s.title !== 'Good places to start' || s.tab === FIND_TITLE || s.current !== null || s.focus !== 'results-title') {
+ problems.push(`finder, Back after the ${what} and an answer: ${JSON.stringify(s)}${s.focus !== 'results-title' ? ` (keyboard focus is on ${s.focus}, not on the results heading)` : ''}`);
+ }
+ }
+ // Describe it in words: back to the start, one history step, keyboard focus in the search box.
+ await openHome('?view=find&what=text', problems);
+ await clearHistory();
+ const before = await evaluate('history.length');
+ if (!(await press('#find-words'))) problems.push('finder: no Describe it in words');
+ else {
+ await still();
+ s = await look();
+ if (s.search !== '' || !s.hero || s.focus !== 'q' || s.steps !== before + 1) problems.push(`finder, Describe it in words: ${JSON.stringify(s)}`);
+ }
+ return problems;
+ }
+
+ // How much two captures of the same box differ: the share of pixels that differ by more than 48 (red, green and blue summed), and
+ // the shares of the box's width and height that the rectangle around them takes, as in the home page's reduced-motion check.
+ async function pictureChange(drawn, bare) {
+ return evaluate(`new Promise(done => {
+ const load = src => new Promise(resolve => { const img = new Image(); img.onload = () => resolve(img); img.src = 'data:image/png;base64,' + src; });
+ Promise.all([load(${JSON.stringify(drawn)}), load(${JSON.stringify(bare)})]).then(([x, y]) => {
+ const read = img => { const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const g = c.getContext('2d'); g.drawImage(img, 0, 0); return g.getImageData(0, 0, c.width, c.height).data; };
+ const p = read(x), q = read(y), w = x.width, h = x.height;
+ let changed = 0, left = w, right = -1, top = h, bottom = -1;
+ for (let i = 0; i < p.length; i += 4) {
+ if (Math.abs(p[i] - q[i]) + Math.abs(p[i + 1] - q[i + 1]) + Math.abs(p[i + 2] - q[i + 2]) <= 48) continue;
+ const px = (i / 4) % w, py = Math.floor(i / 4 / w);
+ changed++; left = Math.min(left, px); right = Math.max(right, px); top = Math.min(top, py); bottom = Math.max(bottom, py);
+ }
+ done({ share: changed / (w * h), wide: changed ? (right - left + 1) / w : 0, tall: changed ? (bottom - top + 1) / h : 0 });
+ });
+ })`);
+ }
+
+ // The finder under reduced motion: nothing runs in it, with or without cards (no animation in the page is running, on
+ // pseudo-elements too), and every How picture holds a still that shows something: captured with its parts and again with them
+ // hidden (its dark square stays), the pixels that change are at least 0.3% of the picture and the box around them at least 1%.
+ async function finderMotionProblems() {
+ const problems = [];
+ for (const query of ['?view=find', '?view=find&what=background']) {
+ await openHome(query, problems);
+ await sleep(500);
+ const running = await evaluate(`document.getAnimations().filter(a => a.playState === 'running').map(a => {
+ const t = a.effect && a.effect.target, cls = t && t.getAttribute && t.getAttribute('class');
+ return (a.animationName || a.transitionProperty || 'an animation') + ' on ' + (t ? t.tagName.toLowerCase() + (cls ? '.' + cls.split(' ').join('.') : '') : 'the page') + ((a.effect && a.effect.pseudoElement) || '');
+ })`);
+ if (running.length) problems.push(`finder, reduced motion, ${query}: ${running.length} animations run (${[...new Set(running)].slice(0, 6).join(', ')})`);
+ }
+ const pics = await evaluate(`typeof FIND_Q === 'undefined' ? [] : FIND_Q.find(q => q.key === 'how').answers.map(a => a.pic)`);
+ if (!pics.length) problems.push('finder, reduced motion: the page has no How answers');
+ const frames = 'new Promise(done => requestAnimationFrame(() => requestAnimationFrame(done)))';
+ const empty = [];
+ for (const pic of pics) {
+ const box = await evaluate(`(async () => { const p = document.querySelector('#finder .${pic}'); if (!p || !p.getClientRects().length) return null;
+ p.scrollIntoView({ block: 'center' }); await ${frames};
+ const b = p.getBoundingClientRect(); return { x: b.left + scrollX, y: b.top + scrollY, width: b.width, height: b.height }; })()`);
+ if (!box || !box.width || !box.height) { empty.push(`${pic} (no picture)`); continue; }
+ const drawn = (await send('Page.captureScreenshot', { format: 'png', clip: { ...box, scale: 1 } })).data;
+ await evaluate(`(async () => { for (const el of document.querySelector('#finder .${pic}').children) el.style.visibility = 'hidden'; await ${frames}; })()`);
+ const bare = (await send('Page.captureScreenshot', { format: 'png', clip: { ...box, scale: 1 } })).data;
+ await evaluate(`{ for (const el of document.querySelector('#finder .${pic}').children) el.style.visibility = ''; }`);
+ const seen = await pictureChange(drawn, bare);
+ if (seen.share < .003 || seen.wide * seen.tall < .01) empty.push(`${pic} (${(seen.share * 100).toFixed(2)}% of the picture)`);
+ }
+ if (empty.length) problems.push(`finder, reduced motion: ${empty.length} How pictures show nothing: ${empty.join(', ')}`);
+ return problems;
+ }
+
+// Famous effects: every scroll the steps below make themselves is instant (behavior: 'instant'), so a page with CSS smooth
+// scrolling is never still moving when a position is read. Only the page's own jump is left to glide or not.
+
+// Famous effects: waits until the page holds still (scrollY the same over three checks 100 ms apart, for up to 3 s).
+const scrollSettled = () => evaluate(`new Promise(done => { let last = scrollY, same = 0, left = 30;
+ const tick = () => { same = scrollY === last ? same + 1 : 0; last = scrollY; if (same >= 3 || !--left) done(); else setTimeout(tick, 100); };
+ setTimeout(tick, 100); })`);
+
+// Famous effects, desktop run: each link of the jump row, pressed as the keyboard presses it (focus, then activate) from the
+// top of the page, brings its entry's heading fully into the window, gives that heading keyboard focus and names the entry in
+// the address. Pressed again while the address names its entry, the last link adds no step to the history.
+async function famousJumpProblems() {
+ const hrefs = await evaluate(`[...document.querySelectorAll('.fx-jump a')].map(a => a.getAttribute('href'))`);
+ if (!hrefs.length) return ['no links in the jump row'];
+ const problems = [];
+ for (const href of hrefs) {
+ await evaluate(`(() => { scrollTo({ top: 0, behavior: 'instant' }); const a = document.querySelector('.fx-jump a[href="${href}"]'); a.focus(); a.click(); })()`);
+ await scrollSettled();
+ const got = await evaluate(`(() => { const s = document.querySelector('${href}'), h = s && s.querySelector('h2');
+ if (!h) return null;
+ const b = h.getBoundingClientRect();
+ return { top: Math.round(b.top), shown: b.top >= 0 && b.bottom <= innerHeight, focus: document.activeElement === h, hash: location.hash }; })()`);
+ if (!got) problems.push(`jump to ${href}: no entry with that id, or no heading in it`);
+ else if (!got.shown || !got.focus || got.hash !== href) problems.push(`jump to ${href}: ${JSON.stringify(got)}`);
+ }
+ const last = hrefs[hrefs.length - 1];
+ const again = await evaluate(`(() => { const before = history.length, a = document.querySelector('.fx-jump a[href="${last}"]'); a.focus(); a.click();
+ return { hash: location.hash, before, after: history.length }; })()`);
+ await scrollSettled();
+ if (again.hash !== last || again.after !== again.before) problems.push(`jump to ${last} again: ${JSON.stringify(again)} (expected the address ${last} and the same number of history steps)`);
+ return problems;
+}
+
+// Famous effects: a PNG (base64) of the stage of a card (an expression that finds the card in the page), where the page is
+// scrolled now.
+async function famousStageShot(card) {
+ const box = await evaluate(`(() => { const b = ${card}.querySelector('.stage').getBoundingClientRect();
+ return { x: b.left + scrollX, y: b.top + scrollY, width: b.width, height: b.height }; })()`);
+ return (await send('Page.captureScreenshot', { format: 'png', clip: { ...box, scale: 1 } })).data;
+}
+
+// Famous effects, desktop run: with an entry's cards in the middle of the window, each card's preview moves (its picture
+// changes within 3 s); once the last entry is in view, the first entry's previews have stopped, since a preview plays only
+// while it is on screen.
+async function famousPreviewProblems() {
+ const ids = await evaluate(`[...document.querySelectorAll('section.fx')].map(s => s.id)`);
+ if (!ids.length) return ['no entries to play'];
+ const problems = [];
+ for (const id of ids) {
+ const cards = await evaluate(`(async () => { const s = document.getElementById('${id}'), row = s.querySelector('.fx-cards');
+ if (!row) return 0;
+ row.scrollIntoView({ block: 'center', behavior: 'instant' });
+ await new Promise(r => setTimeout(r, 400));
+ return s.querySelectorAll('.card').length; })()`);
+ if (!cards) { problems.push(`${id}: no cards`); continue; }
+ for (let i = 0; i < cards; i++) {
+ const card = `document.querySelectorAll('#${id} .card')[${i}]`;
+ const first = await famousStageShot(card);
+ let moved = false;
+ for (const end = Date.now() + 3000; !moved && Date.now() < end;) { await sleep(200); moved = (await famousStageShot(card)) !== first; }
+ if (!moved) problems.push(`${id}: the preview of ${await evaluate(`${card}.dataset.slug`)} does not move while on screen`);
+ }
+ }
+ const still = await evaluate(`document.querySelector('section.fx').querySelectorAll('.card.playing').length`);
+ if (ids.length > 1 && still) problems.push(`the first entry's previews keep playing while it is off screen (${still} cards)`);
+ return problems;
+}
+
+// Famous effects: presses an entry's Copy prompt for real at its center (scrolled into view, the pointer moved onto it, then a
+// mouse press and release). Returns what went wrong, or ''.
+async function famousPressCopy(id) {
+ const spot = await evaluate(`(() => { const btn = document.querySelector('#${id} .copy'); if (!btn) return null;
+ btn.scrollIntoView({ block: 'center', behavior: 'instant' });
+ const b = btn.getBoundingClientRect(), x = b.left + b.width / 2, y = b.top + b.height / 2, hit = document.elementFromPoint(x, y);
+ return { x, y, covered: btn.contains(hit) ? '' : hit ? hit.tagName.toLowerCase() + (hit.getAttribute('class') ? '.' + hit.getAttribute('class').split(' ')[0] : '') : 'nothing' }; })()`);
+ if (!spot) return 'no Copy prompt button';
+ if (spot.covered) return `Copy prompt is covered by ${spot.covered} at its center`;
+ await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: spot.x, y: spot.y, button: 'none' });
+ for (const type of ['mousePressed', 'mouseReleased']) await send('Input.dispatchMouseEvent', { type, x: spot.x, y: spot.y, button: 'left', clickCount: 1 });
+ return '';
+}
+
+// Famous effects, desktop run: each entry's Copy prompt, pressed for real, puts exactly that entry's prompt on the clipboard
+// (stubbed: a headless run cannot grant it), reads "Copied", says so in its name and shows the message. Then the browser
+// refuses the clipboard: the first entry's press copies through the hidden text box (its copy command stubbed to report what
+// is selected), so the button reads "Copied" with the message, the text box is gone and keyboard focus is back on the button.
+// Last, with no clipboard and the copy command failing, the second entry's press (the first's again on a page of one) selects
+// its prompt and asks for Ctrl+C.
+async function famousCopyProblems() {
+ const ids = await evaluate(`[...document.querySelectorAll('section.fx')].map(s => s.id)`);
+ if (!ids.length) return ['no entries to copy'];
+ const problems = [];
+ const press = famousPressCopy;
+ const prompt = id => `document.querySelector('#${id} .fx-prompt').textContent.replace(/\\s+/g, ' ').trim()`;
+ await evaluate(`(() => { navigator.clipboard.writeText = async text => { window.__clipboardGot = text; }; })()`);
+ for (const id of ids) {
+ // The message of the entry before is put away first, so this press has to show its own.
+ await evaluate(`(() => { window.__clipboardGot = null; const t = document.getElementById('toast'); t.classList.remove('show'); t.querySelector('.toast-t').textContent = ''; })()`);
+ const trouble = await press(id);
+ if (trouble) { problems.push(`${id}: ${trouble}`); continue; }
+ const got = await evaluate(`(async () => {
+ for (let i = 0; i < 60 && window.__clipboardGot === null; i++) await new Promise(r => setTimeout(r, 50));
+ await new Promise(r => setTimeout(r, 50));
+ const btn = document.querySelector('#${id} .copy'), title = document.querySelector('#${id} h2').textContent;
+ return { same: window.__clipboardGot === ${prompt(id)}, label: btn.textContent.trim(), named: (btn.getAttribute('aria-label') || '') === 'Copied the prompt for ' + title,
+ toast: document.getElementById('toast').classList.contains('show') && document.querySelector('#toast .toast-t').textContent === 'Prompt copied. Paste it into your AI assistant.' };
+ })()`);
+ if (!got.same || got.label !== 'Copied' || !got.named || !got.toast) problems.push(`${id}: Copy prompt ${JSON.stringify(got)}`);
+ }
+ // Before each of the two presses below, the button is back to "Copy prompt" (its "Copied" lasts about two seconds) and the
+ // message is put away, so the press has to bring its own.
+ const idle = id => evaluate(`(async () => { const btn = document.querySelector('#${id} .copy');
+ for (let i = 0; i < 100 && btn.textContent.trim() !== 'Copy prompt'; i++) await new Promise(r => setTimeout(r, 50));
+ const t = document.getElementById('toast'); t.classList.remove('show'); t.querySelector('.toast-t').textContent = ''; getSelection().removeAllRanges(); })()`);
+ await evaluate(`(() => { navigator.clipboard.writeText = async () => { throw new DOMException('denied', 'NotAllowedError'); };
+ window.__boxGot = null;
+ document.execCommand = command => { const el = document.activeElement;
+ if (command === 'copy' && el && el.tagName === 'TEXTAREA') window.__boxGot = el.value.slice(el.selectionStart, el.selectionEnd);
+ return command === 'copy'; }; })()`);
+ await idle(ids[0]);
+ const trouble = await press(ids[0]);
+ if (trouble) problems.push(`${ids[0]}, clipboard refused: ${trouble}`);
+ else {
+ const boxed = await evaluate(`(async () => { const btn = document.querySelector('#${ids[0]} .copy'), title = document.querySelector('#${ids[0]} h2').textContent;
+ for (let i = 0; i < 60 && window.__boxGot === null; i++) await new Promise(r => setTimeout(r, 50));
+ await new Promise(r => setTimeout(r, 50));
+ return { same: window.__boxGot === ${prompt(ids[0])}, label: btn.textContent.trim(), named: (btn.getAttribute('aria-label') || '') === 'Copied the prompt for ' + title,
+ toast: document.getElementById('toast').classList.contains('show') && document.querySelector('#toast .toast-t').textContent === 'Prompt copied. Paste it into your AI assistant.',
+ boxGone: !document.querySelector('textarea'), focus: document.activeElement === btn }; })()`);
+ if (!boxed.same || boxed.label !== 'Copied' || !boxed.named || !boxed.toast || !boxed.boxGone || !boxed.focus) {
+ problems.push(`${ids[0]}, clipboard refused: ${JSON.stringify(boxed)} (expected the hidden text box to copy the prompt, "Copied" and the message)`);
+ }
+ }
+ const last = ids[1] || ids[0];
+ await evaluate(`(() => { Object.defineProperty(navigator, 'clipboard', { value: undefined, configurable: true }); document.execCommand = () => false; })()`);
+ await idle(last);
+ const trouble2 = await press(last);
+ if (trouble2) problems.push(`${last}, no clipboard: ${trouble2}`);
+ else {
+ const keys = await evaluate(`(async () => { const btn = document.querySelector('#${last} .copy');
+ for (let i = 0; i < 60 && !btn.textContent.includes('Ctrl+C'); i++) await new Promise(r => setTimeout(r, 50));
+ return { label: btn.textContent.trim(), selected: getSelection().toString().replace(/\\s+/g, ' ').trim() === ${prompt(last)} }; })()`);
+ if (keys.label !== 'Press Ctrl+C to copy' || !keys.selected) problems.push(`${last}, no clipboard and the text box failing: ${JSON.stringify(keys)} (expected "Press Ctrl+C to copy" and the prompt selected)`);
+ }
+ return problems;
+}
+
+// Famous effects: the pixels that differ by more than 48 (red, green and blue summed) between two captures of the same size
+// (base64 PNG), as their share of the picture and the shares of its width and of its height that the box around them takes.
+// homeMotionProblems does the same inline for the home page; this copy serves the Famous effects page, so that one stays as it is.
+const changedShare = (a, b) => evaluate(`new Promise(done => {
+ const load = src => new Promise(resolve => { const img = new Image(); img.onload = () => resolve(img); img.src = 'data:image/png;base64,' + src; });
+ Promise.all([load(${JSON.stringify(a)}), load(${JSON.stringify(b)})]).then(([x, y]) => {
+ const read = img => { const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const g = c.getContext('2d'); g.drawImage(img, 0, 0); return g.getImageData(0, 0, c.width, c.height).data; };
+ const p = read(x), q = read(y), w = x.width, h = x.height;
+ let changed = 0, left = w, right = -1, top = h, bottom = -1;
+ for (let i = 0; i < p.length; i += 4) {
+ if (Math.abs(p[i] - q[i]) + Math.abs(p[i + 1] - q[i + 1]) + Math.abs(p[i + 2] - q[i + 2]) <= 48) continue;
+ const px = (i / 4) % w, py = Math.floor(i / 4 / w);
+ changed++; left = Math.min(left, px); right = Math.max(right, px); top = Math.min(top, py); bottom = Math.max(bottom, py);
+ }
+ done({ share: changed / (w * h), wide: changed ? (right - left + 1) / w : 0, tall: changed ? (bottom - top + 1) / h : 0 });
+ });
+})`);
+
+// Famous effects, reduced-motion phone run: nothing runs (every animation in the page is paused), neither at once nor once
+// every card has been on screen; every preview holds a still frame that shows something (the home check's pixel test: the
+// stage captured with the preview and again with the preview's contents hidden must differ in at least 0.3% of its pixels,
+// inside a box of at least 1% of it); a jump does not glide: two frames after the press, the entry's heading is in the
+// window; and the first entry's Copy prompt, pressed for real, copies (the clipboard stubbed), reads "Copied" and shows the
+// message where it stands: no change of position runs on it and it is not offset.
+async function famousMotionProblems() {
+ const problems = [];
+ const running = when => evaluate(`document.getAnimations().filter(a => a.playState === 'running').map(a => {
+ const t = a.effect && a.effect.target, card = t && t.closest && t.closest('.card');
+ return (a.animationName || a.transitionProperty || 'an animation') + ' on ' + (card ? card.dataset.slug : t ? t.tagName.toLowerCase() : 'the page');
+ })`).then(found => { if (found.length) problems.push(`reduced motion: ${found.length} animations run ${when} (${[...new Set(found)].slice(0, 8).join(', ')})`); });
+ await running('at once');
+ const frames = n => `new Promise(done => { let left = ${n}; const tick = () => (--left ? requestAnimationFrame(tick) : done()); requestAnimationFrame(tick); })`;
+ const cards = await evaluate(`document.querySelectorAll('section.fx .card').length`);
+ if (!cards) return [...problems, 'reduced motion: no cards'];
+ const empty = [];
+ for (let i = 0; i < cards; i++) {
+ const card = `document.querySelectorAll('section.fx .card')[${i}]`;
+ await evaluate(`(async () => { ${card}.querySelector('.stage').scrollIntoView({ block: 'center', behavior: 'instant' }); await ${frames(2)}; })()`);
+ const drawn = await famousStageShot(card);
+ await evaluate(`(async () => { for (const el of ${card}.querySelector('.pv').children) el.style.visibility = 'hidden'; await ${frames(2)}; })()`);
+ const bare = await famousStageShot(card);
+ await evaluate(`{ for (const el of ${card}.querySelector('.pv').children) el.style.visibility = ''; }`);
+ const seen = await changedShare(drawn, bare);
+ if (seen.share < .003 || seen.wide * seen.tall < .01) {
+ empty.push(`${await evaluate(`${card}.dataset.slug`)} (${(seen.share * 100).toFixed(2)}% of the stage, in a box of ${Math.round(seen.wide * 100)}% × ${Math.round(seen.tall * 100)}%)`);
+ }
+ }
+ if (empty.length) problems.push(`reduced motion: ${empty.length} previews show nothing: ${empty.join(', ')}`);
+ await running('once every card has been on screen');
+ const jump = await evaluate(`(async () => { scrollTo({ top: 0, behavior: 'instant' }); const links = document.querySelectorAll('.fx-jump a'), a = links[links.length - 1];
+ if (!a) return null;
+ a.focus(); a.click(); await ${frames(2)};
+ const href = a.getAttribute('href'), h = document.querySelector(href + ' h2');
+ if (!h) return { href, missing: true };
+ const b = h.getBoundingClientRect();
+ return { href, shown: b.top >= 0 && b.bottom <= innerHeight, top: Math.round(b.top) }; })()`);
+ if (!jump) problems.push('reduced motion: no links in the jump row');
+ else if (jump.missing) problems.push(`reduced motion: the last link of the jump row (${jump.href}) has no entry with a heading`);
+ else if (!jump.shown) problems.push(`reduced motion: the jump to ${jump.href} glides (two frames after the press its heading is at ${jump.top}px)`);
+ const first = await evaluate(`(() => { const s = document.querySelector('section.fx'); if (!s) return null;
+ window.__clipboardGot = null; navigator.clipboard.writeText = async text => { window.__clipboardGot = text; }; return s.id; })()`);
+ const trouble = first ? await famousPressCopy(first) : 'no entry';
+ if (trouble) problems.push(`reduced motion, Copy prompt: ${trouble}`);
+ else {
+ const copy = await evaluate(`(async () => { const t = document.getElementById('toast');
+ for (let i = 0; i < 60 && !t.classList.contains('show'); i++) await new Promise(r => setTimeout(r, 50));
+ return { label: document.querySelector('#${first} .copy').textContent.trim(), copied: window.__clipboardGot !== null, shown: t.classList.contains('show'),
+ sliding: t.getAnimations().filter(a => a.transitionProperty === 'transform' || a.animationName).length, offset: Math.round(new DOMMatrix(getComputedStyle(t).transform).m42) }; })()`);
+ if (copy.label !== 'Copied' || !copy.copied || !copy.shown || copy.sliding || copy.offset) {
+ problems.push(`reduced motion, Copy prompt of ${first}: ${JSON.stringify(copy)} (expected "Copied" and the message shown in place, with no slide)`);
+ }
+ }
+ return problems;
+}
+
// The end of the run, done once: after the last page, after Ctrl+C and after an error outside the main flow.
let cleaning = null;
function cleanUp() {
@@@ -1270,15 -1274,11 +1536,19 @@@ try
if (setup.name === 'phone') problems.push(...await homePhoneProblems());
if (setup.name === 'phone-reduced') problems.push(...await homeMotionProblems());
if (setup.moves) problems.push(...await homeCopyProblems());
+ // The finder (?view=find): opened at every setup; the desktop run works it and the reduced-motion run holds it still.
+ problems.push(...await finderLayoutProblems(name, setup));
+ if (setup.moves) problems.push(...await finderViewProblems());
+ if (setup.reduce) problems.push(...await finderMotionProblems());
}
+ if (famous) {
+ if (setup.moves) {
+ problems.push(...await famousJumpProblems());
+ problems.push(...await famousPreviewProblems());
+ problems.push(...await famousCopyProblems());
+ }
+ if (setup.name === 'phone-reduced') problems.push(...await famousMotionProblems());
+ }
} catch (err) {
problems.push(`check failed: ${err.message}`);
}