An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
fix(engine): tapWords names covered targets; paper vignette lets taps through
yzr2bcae4de1429
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js b/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.jsindex 9f86244..83d11af 100644--- a/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js+++ b/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js@@ -60,7 +60,7 @@ function paperCam(p, setName, v0 = {}, { after = null, stages = [] } = {}) {if (stages.includes(L.name)) layers.push({ g: stageAt[L.name] = mk('g', {}, world), k: L.k });if (L.name === after || (!after && L.k === 1 && !stage)) layers.push({ g: stage = mk('g', {}, world), k: 1 });}- mk('rect', { width: 1600, height: 900, fill: 'url(#vignette)' }, root);+ mk('rect', { width: 1600, height: 900, fill: 'url(#vignette)', 'pointer-events': 'none' }, root); // a tap goes through to the picture// Parallax is measured from the set's own framing (base), wherever the beat's first view is.const base = { x: 800, y: 450, z: 1 }, start = { ...base, ...v0 };function at(t, n = ops.length) {diff --git a/.claude/skills/papermorph/references/picture-books/stories.md b/.claude/skills/papermorph/references/picture-books/stories.mdindex 3b7ddcb..c1097d3 100644--- a/.claude/skills/papermorph/references/picture-books/stories.md+++ b/.claude/skills/papermorph/references/picture-books/stories.md@@ -106,7 +106,7 @@ A picture book for young children learning a language can stop once and let the**The words.** Six to eight concrete nouns the child can see in that one picture and probably half knows: tree, flower, basket, bird, mushroom, butterfly. Each should be a whole thing drawn clearly apart from the others, so the child finds it and the word plainly belongs to it; a part too small to find (a coat's button) or an idea (*quiet*) has nothing to point at. The word is the whole lesson: a tap shows the word and says it once, with no sentence and no translation. The beat's narration is one prompt line in the narrator's voice that tells the child what to do ("Little Red Riding Hood saw so many things in the woods. Touch them to hear their names!").-**The beat.** It is the episode's one `ask` beat, with `tapWords(things, done)` as its ask, so the chapter is a film with a question: `film: true` in `CHAPTER` keeps its music and effects, and `questionKeys: false` keeps a lesson's question keys out of the help ([core/engine.md](../core/engine.md#player)). The scene fills the list each time it builds the picture; `g` is what the child taps: a puppet's `g`, a `prop()`, or, for something painted into a baked set, a transparent shape laid over it:+**The beat.** It is the episode's one `ask` beat, with `tapWords(things, done)` as its ask, so the chapter is a film with a question: `film: true` in `CHAPTER` keeps its music and effects, and `questionKeys: false` keeps a lesson's question keys out of the help ([core/engine.md](../core/engine.md#player)). The scene fills the list each time it builds the picture; `g` is what the child taps: a puppet's `g`, a `prop()`, or, for something painted into a baked set, a transparent shape laid over it (a rectangle, or a path traced round an odd outline such as a winding path or a pond):```jslet WOODS = []; // the things to tap, filled by scene4w@@ -122,13 +122,13 @@ function scene4w(p, D) {['scene4w', 'In the woods', (m, D) => scene4w(panel(0), D), { lead: false, pre: PRE4W, ask: done => tapWords(WOODS, done) }],```-Once the prompt's narration is over the things turn tappable, each with a hit box at least 120 px square (a child's finger on a phone; smaller boxes lie on top of bigger ones). A tap hops the thing, shows its word beside it, above where there is room, and says the word with the music ducked; tapping again says it again. A counter and Continue (Enter) wait in the corner, and Continue lights up with a short praise once every thing has been heard; the child can go on at any time. ← and → move between the things and Enter or Space taps, and each thing is named by its word for a screen reader. While the page waits, the scene's `stopClock` runs on past the beat's end, so pose the puppets as a function of `q` that keeps living there: a breath, a blink every few seconds, a glance. A book with its own early-reader typeface sets `--word-font` in `lib/book.css`.+Once the prompt's narration is over the things turn tappable, each with a hit box at least 120 px square (a child's finger on a phone; smaller boxes lie on top of bigger ones) that follows its thing every frame, so a target may be a puppet that walks about or a bird that flies. A tap hops the thing (the hop adds to the transform the scene sets every frame, so a prop or puppet posed every frame hops in place), shows its word beside it, above where there is room, and says the word with the music ducked; tapping again says it again. A counter and Continue (Enter) wait in the corner, and Continue lights up with a short praise once every thing has been heard; the child can go on at any time. ← and → move between the things and Enter or Space taps, and each thing is named by its word for a screen reader. While the page waits, the scene's `stopClock` runs on past the beat's end, so pose the puppets as a function of `q` that keeps living there: a breath, a blink every few seconds, a glance. A book with its own early-reader typeface sets `--word-font` in `lib/book.css`.**The word clips** are plain narration entries, voiced by `tts.py` with the rest and in the same voice: `"w-basket": "basket"` in `narration.<lang>.json` makes `audio/<lang>/w-basket.mp3`. A thing's clip is `'w-' + its word` (lower case, spaces as hyphens: *ice cream* says `w-ice-cream`); `clip: 'w-red'` names another. They stay out of `join.py`'s list, since each plays alone; run `level.py` on them with the other clips.**The video.** `export.py` cannot tap, so it shows and says the words in turn, as if a child were tapping them ([core/publish.md](../core/publish.md#video-export)).-**Check it** as a child would. `?beat=N` opens the beat; play its prompt and wait: nothing is tappable until the narration ends. Then tap every thing in the browser, by mouse and with the arrows and Enter: is every word beside its thing and not over it, does every word sound, does the counter count, does Continue light up and go on once? Step back into the beat and out of it mid-wait and replay it: no box, card or word may stay behind. `lint.py` names a word whose clip file is missing (it reads the `word: '…'` written in the scene, so write words as literals), and the page warns in the console about a thing with no word, an element that is not on the stage or not in the picture, and a clip that will not load, which `check.py` lists.+**Check it** as a child would. `?beat=N` opens the beat; play its prompt and wait: nothing is tappable until the narration ends. Then tap every thing in the browser, by mouse and with the arrows and Enter: is every word beside its thing and not over it, does every word sound, does the counter count, does Continue light up and go on once? Step back into the beat and out of it mid-wait and replay it: no box, card or word may stay behind. `lint.py` names a word whose clip file is missing (it reads the `word: '…'` written in the scene, so write words as literals), and the page warns in the console about a thing with no word, an element that is not on the stage or not in the picture, a clip that will not load, and a thing a finger cannot reach because something lies over it (naming what: the counter's card in the bottom right corner, say), which `check.py` lists.## Teamdiff --git a/engine/check_tapwords.py b/engine/check_tapwords.pyindex 0ba3b9e..ec6fbe9 100644--- a/engine/check_tapwords.py+++ b/engine/check_tapwords.py@@ -34,9 +34,13 @@ function picture(p, D) {const ball = mk('circle', { cx: 300, cy: 500, r: 60, fill: '#c94a3c' }, p);const tree = mk('rect', { x: 700, y: 150, width: 200, height: 600, fill: '#3e7f4c' }, p);const bee = mk('circle', { cx: 800, cy: 400, r: 12, fill: '#f0b45a' }, p); // small, in front of the tree- const cup = mk('rect', { x: 1300, y: 40, width: 80, height: 60, fill: '#86c9e8' }, p); // at the top: its word goes below+ // a prop at the top (its word goes below) that the scene moves every frame through its own transform, as a puppet's is+ const cup = mk('g', {}, p);+ mk('rect', { width: 80, height: 60, fill: '#86c9e8' }, cup);+ clockRun(t => cup.setAttribute('transform', `translate(${(1300 + t * 20).toFixed(1)} 40)`), D, { tail: true });+ const box = mk('rect', { x: 1380, y: 795, width: 40, height: 20, fill: '#9aaba3' }, p); // under the counter's cardTHINGS = [{ g: ball, word: 'ball' }, { g: tree, word: 'tree' }, { g: bee, word: 'bee', clip: 'w-bee-2' }, { g: cup, word: 'Ice cream' },- { g: tree, word: '' }, { g: document.createElementNS(NS, 'g'), word: 'ghost' }];+ { g: box, word: 'box' }, { g: tree, word: '' }, { g: document.createElementNS(NS, 'g'), word: 'ghost' }];}music('audio/bgm/m.mp3', ['q', 'after', 'end'], .5);const BEATS = [@@ -94,23 +98,26 @@ async def main():await page.wait_for_timeout(200)assert await js("P.playing && !P.waiting"), "the film did not start"assert await js(f"{hits}.length") == 0 and await js(count) is None, "things were tappable during the narration"- await page.wait_for_function(f"P.waiting && {hits}.length === 4", timeout=5000)- assert sorted(await js(f"{hits}.map(g => g.getAttribute('aria-label'))")) == ["Ice cream", "ball", "bee", "tree"]+ await page.wait_for_function(f"P.waiting && {hits}.length === 5", timeout=5000)+ assert sorted(await js(f"{hits}.map(g => g.getAttribute('aria-label'))")) == ["Ice cream", "ball", "bee", "box", "tree"]assert await js(f"{hits}.every(g => g.getAttribute('role') === 'button' && g.tabIndex === 0)")assert await js("document.getElementById('stage').getAttribute('role')") == "group", "the things are hidden from screen readers"assert await js(f"{hits}.every(g => {{ const r = g.getBBox(); return r.width >= 120 && r.height >= 120; }})"), "a hit box under 120 px"assert {"w-ball.mp3", "w-tree.mp3", "w-bee-2.mp3", "w-ice-cream.mp3"} <= set(asked), f"word clips not requested: {asked}"- assert await js(count) == "0 / 4"+ assert await js(count) == "0 / 5"assert "Continue" in await js("document.querySelector('.card.words button').textContent")assert await js("document.querySelector('.card.words button').className") == "btn quiet"- print("PASS waiting: four things tappable after the narration, labelled, 120 px boxes, clips requested, 0 / 4, Continue")+ print("PASS waiting: five things tappable after the narration, labelled, 120 px boxes, clips requested, 0 / 5, Continue")cx = await js("+document.querySelector('#scene circle').getAttribute('cx')")+ ring = "+document.querySelector('#stage .tapw [aria-label=\"Ice cream\"] rect').getAttribute('x')"+ rx = await js(ring)await page.wait_for_timeout(500)+ assert await js(ring) > rx + 5, "the hit box did not follow a moving thing"assert await js("SND.duck") > .6, "the music did not come up while waiting"assert await js("+document.querySelector('#scene circle').getAttribute('cx')") > cx + 3, "the scene's motion stopped while waiting"await tap_at("THINGS[0].g")- assert await js(word) == "ball" and await js(count) == "1 / 4"+ assert await js(word) == "ball" and await js(count) == "1 / 5"assert "w-ball.mp3" in await js("PLAYED"), "the word was not said"assert await js("THINGS[0].g.getAnimations().length") > 0, "the thing did not hop"assert await js("""(() => { const a = document.querySelector('#ui .card.word').getBoundingClientRect(), b = THINGS[0].g.getBoundingClientRect();@@ -118,33 +125,43 @@ async def main():await page.wait_for_timeout(250)assert await js("SND.duck") < .5, "the music did not duck under the word"await tap_at("THINGS[2].g") # the bee, in front of the tree: the smaller box is on top- assert await js(word) == "bee" and await js(count) == "2 / 4"+ assert await js(word) == "bee" and await js(count) == "2 / 5"assert await js("PLAYED.at(-1)") == "w-bee-2.mp3"+ await tap_at("THINGS[3].g") # at the top: its word goes below+ assert await js("""(() => { const a = document.querySelector('#ui .card.word').getBoundingClientRect(), b = THINGS[3].g.getBoundingClientRect();+ return a.top >= b.bottom; })()"""), "a thing at the top did not get its word below"await tap_at("THINGS[0].g") # again: says it again, counts once- assert await js("PLAYED.at(-1)") == "w-ball.mp3" and await js(count) == "2 / 4"- print("PASS taps: motion runs on while waiting, word beside the thing, clip played, music ducked, hop, smaller thing on top, a second tap says it again")+ assert await js("PLAYED.at(-1)") == "w-ball.mp3" and await js(count) == "3 / 5"+ print("PASS taps: motion runs on while waiting, hit boxes follow, word beside the thing, clip played, music ducked, hop, smaller thing on top, a second tap says it again")- await page.keyboard.press("ArrowRight") # left to right: ball, tree, bee, ice cream+ await page.keyboard.press("ArrowRight") # left to right: ball, tree, bee, ice cream, boxawait page.keyboard.press("ArrowRight")assert await js("document.activeElement.getAttribute('aria-label')") == "tree"await page.keyboard.press("Enter")await page.wait_for_timeout(80)- assert await js(word) == "tree" and await js(count) == "3 / 4"+ assert await js(word) == "tree" and await js(count) == "4 / 5"await page.keyboard.press("ArrowRight")await page.keyboard.press("ArrowRight")await page.keyboard.press("Space")- await page.wait_for_timeout(80)+ await page.wait_for_timeout(120) # mid-hop: the scene's transform is kept, the hop adds to it+ hop = await js("""[THINGS[3].g.getAttribute('transform'), THINGS[3].g.getBoundingClientRect().top]""")assert await js(word) == "Ice cream" and await js("P.i === 0 && P.waiting"), "Space did not tap"- assert await js(count) == "You found them all!"+ assert await js(count) == "4 / 5"+ await page.wait_for_timeout(500)+ rest = await js("""[THINGS[3].g.getAttribute('transform'), THINGS[3].g.getBoundingClientRect().top]""")+ assert hop[0].startswith("translate(13") and rest[0].startswith("translate(13") and hop[1] < rest[1] - 4, f"the hop lost the scene's transform: {hop} {rest}"+ await page.keyboard.press("ArrowRight")+ await page.keyboard.press("Enter")+ await page.wait_for_timeout(80)+ assert await js(word) == "box" and await js(count) == "You found them all!"assert await js("document.querySelector('.card.words button').className") == "btn go"- assert await js("""(() => { const a = document.querySelector('#ui .card.word').getBoundingClientRect(), b = THINGS[3].g.getBoundingClientRect();- return a.top >= b.bottom; })()"""), "a thing at the top did not get its word below"- print("PASS keys: arrows move left to right, Enter and Space tap; all heard: praise and Continue lit")+ print("PASS keys: arrows move left to right, Enter and Space tap; a hop keeps the scene's own transform; all heard: praise and Continue lit")await page.wait_for_timeout(300)- for w in ('a thing has no word', '"ghost" is not an element on the stage', '"Ice cream" has no clip at audio/en/w-ice-cream.mp3'):+ for w in ('a thing has no word', '"ghost" is not an element on the stage', '"Ice cream" has no clip at audio/en/w-ice-cream.mp3',+ '"box" cannot be tapped: <'):assert any(w in x for x in warnings), f"no warning: {w}\n{warnings}"- print("PASS warnings: no word, not on the stage, missing clip")+ print("PASS warnings: no word, not on the stage, missing clip, covered by the counter")await js("seek(1, false)")await page.wait_for_timeout(100)@@ -154,8 +171,8 @@ async def main():for _ in range(2): # a replay, twice: one set of things, nothing counted from beforeawait js("seek(0, true)")await page.wait_for_timeout(50)- await page.wait_for_function(f"P.waiting && {hits}.length === 4", timeout=5000)- assert await js("document.querySelectorAll('#stage .tapw').length") == 1 and await js(count) == "0 / 4"+ await page.wait_for_function(f"P.waiting && {hits}.length === 5", timeout=5000)+ assert await js("document.querySelectorAll('#stage .tapw').length") == 1 and await js(count) == "0 / 5"print("PASS cleanup: a seek away clears hit boxes, cards, keys and the word; a replay starts afresh")await js("document.activeElement.blur()")@@ -168,14 +185,14 @@ async def main():await js("seek(0, false)")await page.wait_for_timeout(50)demo = await js("P.tapDemo && [P.tapDemo.clips, P.tapDemo.step]")- assert demo == [["w-ball", "w-tree", "w-bee-2", "w-ice-cream"], 2], demo+ assert demo == [["w-ball", "w-tree", "w-bee-2", "w-ice-cream", "w-box"], 2], demosaid = await js("PLAYED.length")await js("P.tapDemo.at(0)")assert await js(word) == "ball"await js("P.tapDemo.at(2.1)")- assert await js(word) == "tree" and await js(count) == "2 / 4"+ assert await js(word) == "tree" and await js(count) == "2 / 5"await js("P.tapDemo.at(99)")- assert await js(word) == "Ice cream" and await js(count) == "You found them all!"+ assert await js(word) == "box" and await js(count) == "You found them all!"assert await js("PLAYED.length") == said, "the video's words played sound"print("PASS video: P.tapDemo lists the clips and shows the words in turn, silently")missing = await js("['en', 'ru', 'zh', 'ja'].flatMap(l => ['wordsHeard', 'allWordsHeard'].filter(k => !TRANSLATIONS[l][k]).map(k => l + '.' + k))")diff --git a/engine/engine.js b/engine/engine.jsindex 8f8c9bd..692629b 100644--- a/engine/engine.js+++ b/engine/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/elementary-algebra/lib/engine.js+++ b/site/elementary-algebra/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/joke-collection/lib/engine.js b/site/joke-collection/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/joke-collection/lib/engine.js+++ b/site/joke-collection/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/little-red-riding-hood/lib/engine.js+++ b/site/little-red-riding-hood/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/madness-shorts/lib/engine.js b/site/madness-shorts/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/madness-shorts/lib/engine.js+++ b/site/madness-shorts/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/madness/lib/engine.js b/site/madness/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/madness/lib/engine.js+++ b/site/madness/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/math-notebook/lib/engine.js+++ b/site/math-notebook/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/pandemic-shorts/lib/engine.js b/site/pandemic-shorts/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/pandemic-shorts/lib/engine.js+++ b/site/pandemic-shorts/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/pandemic/lib/engine.js b/site/pandemic/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/pandemic/lib/engine.js+++ b/site/pandemic/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/physics-notebook/lib/engine.js b/site/physics-notebook/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/physics-notebook/lib/engine.js+++ b/site/physics-notebook/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/science/lib/engine.js b/site/science/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/science/lib/engine.js+++ b/site/science/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/shooting-an-elephant/lib/engine.js b/site/shooting-an-elephant/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/shooting-an-elephant/lib/engine.js+++ b/site/shooting-an-elephant/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;diff --git a/site/three-little-pigs/lib/engine.js b/site/three-little-pigs/lib/engine.jsindex 8f8c9bd..692629b 100644--- a/site/three-little-pigs/lib/engine.js+++ b/site/three-little-pigs/lib/engine.js@@ -1081,8 +1081,9 @@ function tapWords(things, done) {word = h('div', 'card word', t.word);word.setAttribute('aria-hidden', 'true'); // the thing's own label already says the word$('ui').append(word);- const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;- const spots = [[cx, b.y - hh - m], [cx, b.y + b.h + m], [b.x + b.w + m, cy], [b.x - w - m, cy]];+ // gap: clear of the thing's hop; m: the stage's margin+ const b = box(t), w = word.offsetWidth, hh = word.offsetHeight, gap = 30, m = 16, cx = b.x + (b.w - w) / 2, cy = b.y + (b.h - hh) / 2;+ const spots = [[cx, b.y - hh - gap], [cx, b.y + b.h + gap], [b.x + b.w + gap, cy], [b.x - w - gap, cy]];const [x, y] = spots.find(([x, y], k) => k < 2 ? y >= m && y + hh <= SH - m : x >= m && x + w <= SW - m) || spots[0];Object.assign(word.style, { left: Math.max(m, Math.min(SW - m - w, x)) + 'px', top: Math.max(m, Math.min(SH - m - hh, y)) + 'px' });if (quiet) { word.style.animation = go.style.animation = 'none'; return; } // a video's frame shows it at rest@@ -1091,6 +1092,7 @@ function tapWords(things, done) {t.a.volume = +($('volume')?.value ?? 1);t.a.play().catch(() => {});SND.word = t.a; // soundTick ducks the music under it+ // the hop is the CSS translate property, which adds to the transform the scene sets (a prop posed every frame keeps its place)t.g.animate([{ translate: '0 0' }, { translate: '0 -18px', offset: .3 }, { translate: '0 0' }], { duration: 450, easing: 'ease-out' });t.ring.animate([{ strokeOpacity: 1 }, { strokeOpacity: 0 }], { duration: 700, easing: 'ease-out' });};@@ -1114,6 +1116,18 @@ function tapWords(things, done) {go = h('button', 'btn quiet', [translate('continue'), kbd('Enter')]);go.onclick = finish;bar.append(h('div', 'acts', [count, go]));+ // a thing whose box is covered where a finger lands (a card, a layer over the stage) cannot be tapped: once the+ // counter's card has come in, try each box's middle and four points around it, and name what covers it+ setTimeout(() => { if (alive) for (const t of list) {+ const r = t.ring.getBoundingClientRect(), pts = [[.5, .5], [.3, .3], [.7, .3], [.3, .7], [.7, .7]];+ const tops = pts.map(([u, v]) => document.elementFromPoint(r.left + u * r.width, r.top + v * r.height));+ if (!tops.some(e => t.hit.contains(e))) {+ const e = tops[0], cls = e?.getAttribute('class')?.split(' ')[0];+ const what = !e ? 'it is off screen' : e.closest('.hit') ? `"${e.closest('.hit').getAttribute('aria-label')}" covers it`+ : `<${e.tagName.toLowerCase()}${e.id ? '#' + e.id : cls ? '.' + cls : ''}> covers it`;+ console.warn(`tapWords: "${t.word}" cannot be tapped: ${what}`);+ }+ } }, 600);};const cleanup = () => {alive = false;