Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(engine): v2.5, full screen fills the screen; controls hide until needed

yzrc6877654a89f
diff --git a/.claude/skills/papermorph/assets/templates/documentary/style.json b/.claude/skills/papermorph/assets/templates/documentary/style.json
index 85163c7..405db82 100644
--- a/.claude/skills/papermorph/assets/templates/documentary/style.json
+++ b/.claude/skills/papermorph/assets/templates/documentary/style.json
@@ -15,7 +15,7 @@
"voice": { "engine": "edge", "voice": "en-GB-RyanNeural", "rate": "-4%" },
"music": "public-domain classical recordings, one per part of the film, changing at the turns",
"pacing": { "minutes": 10, "turns": "one argument with five or six turns; one idea or picture every two to four seconds" },
- "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.4.2" },
+ "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.5" },
"models": { "script": "claude-opus-5-5", "pictures": "claude-sonnet-5-5", "beats": "claude-sonnet-5-5", "checks": "claude-haiku-5-5", "director": "claude-opus-5-5" },
"approved": [{ "chapter": "ch01", "why": "close-ups on what is named; few words on screen" }]
}
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/style.json b/.claude/skills/papermorph/assets/templates/picture-book/style.json
index a9c9419..894e011 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/style.json
+++ b/.claude/skills/papermorph/assets/templates/picture-book/style.json
@@ -17,7 +17,7 @@
"budget": "under $1 of pictures per episode",
"cast": [{ "name": "Bo", "look": "round face, school uniform", "file": "site/jokes/lib/cast.js" }]
},
- "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.4.2" },
+ "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.5" },
"models": { "script": "claude-opus-5-5", "kit": "claude-opus-5-5", "scenes": "claude-sonnet-5-5", "sound": "claude-haiku-5-5", "director": "claude-opus-5-5", "reviewers": "claude-sonnet-5-5" },
"approved": [{ "chapter": "ch01", "why": "set-up before the punchline; a close-up on whoever speaks" }]
}
diff --git a/.claude/skills/papermorph/assets/templates/shorts/style.json b/.claude/skills/papermorph/assets/templates/shorts/style.json
index 49b3193..04e1196 100644
--- a/.claude/skills/papermorph/assets/templates/shorts/style.json
+++ b/.claude/skills/papermorph/assets/templates/shorts/style.json
@@ -23,7 +23,7 @@
"voice": { "engine": "edge", "voice": "en-US-AndrewNeural", "rate": "+4%", "level": "-14 LUFS, peak -1.5" },
"music": { "ch01": "one track under the whole episode, and where it came from" },
"sources": "which numbers and quotes need a source on screen, and how strict to be about anonymous reports",
- "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.4.2" },
+ "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.5" },
"models": { "script": "claude-opus-5-5", "pictures": "claude-sonnet-5-5", "beats": "claude-sonnet-5-5", "checks": "claude-haiku-5-5", "director": "claude-opus-5-5" },
"approved": [{ "chapter": "ch01", "why": "what the user liked: the hook's first frame, the pace, the ending" }]
}
diff --git a/.claude/skills/papermorph/assets/templates/style.json b/.claude/skills/papermorph/assets/templates/style.json
index dc1cda8..f069d41 100644
--- a/.claude/skills/papermorph/assets/templates/style.json
+++ b/.claude/skills/papermorph/assets/templates/style.json
@@ -14,7 +14,7 @@
},
"voice": { "engine": "edge", "voice": "en-US-AndrewNeural", "rate": "-4%" },
"pacing": { "minutes": [6, 10], "checks": "one or two quick checks inside the lesson, practice at the end" },
- "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.4.2" },
+ "engine": { "source": "DozenTwelve/Papermorph", "ref": "engine-v2.5" },
"models": { "extract": "claude-haiku-5-5", "narration": "claude-sonnet-5-5", "picture": "claude-opus-5-5", "checks": "claude-haiku-5-5", "review": "claude-sonnet-5-5", "rework": "claude-opus-5-5", "register": "claude-haiku-5-5" },
"scenes": {
"art": "pixel scenes on a dark board, characters about a third of the stage tall",
diff --git a/.claude/skills/papermorph/references/engine.md b/.claude/skills/papermorph/references/engine.md
index a0d7be9..ad70534 100644
--- a/.claude/skills/papermorph/references/engine.md
+++ b/.claude/skills/papermorph/references/engine.md
@@ -2,7 +2,7 @@
A chapter page loads the engine and its `audio/<lang>/timings.js`, defines `CHAPTER` (including `language` when different from `en`: the audio folder), drawing helpers, `BEATS` and questions, then calls `boot()`. The engine provides the stage, drawing, timeline, question types, guide and player. Use the code's signatures if they differ from this reference. The interface text (buttons, help, cover, finish card) follows `<html lang>`: English, Russian, Chinese and Japanese are in the engine's `TRANSLATIONS`; another language needs a block there.
-Every book keeps a copy of the shared engine in `lib/` (`engine.*`, `math.js`, `volume.*`, `contents.*`, `units.*`), so the book runs on its own. The engine is not part of this skill: it lives in the `engine/` folder of the Papermorph repository (or a fork). `python3 SKILL/scripts/engine.py site` copies it into every book from the repository's `engine/` when it is at hand, otherwise from GitHub (`--check` lists copies that differ, `--from DIR|OWNER/REPO@REF` picks the source, by default the latest compatible release, `engine-v2.4.2`; `@main` takes the newest, a tag or commit pins it, and `engine-v1` is the last engine with the maths helpers inside `engine.js`); a book's copy is not edited by hand. This reference describes `engine-v2.4.2`; what an older copy lacks is marked *(v2.1)*, *(v2.2)*, *(v2.3)*, *(v2.4)*, *(v2.4.1)* or *(v2.4.2)*, and syncing the book brings it. An engine bug is fixed at the source, then synced. The book's own settings and style overrides live in `lib/book.css`, imported by `engine.css` and never overwritten: `--math-font` for numbers and formulas, `--progress-key` when the cover uses a key other than the default.
+Every book keeps a copy of the shared engine in `lib/` (`engine.*`, `math.js`, `volume.*`, `contents.*`, `units.*`), so the book runs on its own. The engine is not part of this skill: it lives in the `engine/` folder of the Papermorph repository (or a fork). `python3 SKILL/scripts/engine.py site` copies it into every book from the repository's `engine/` when it is at hand, otherwise from GitHub (`--check` lists copies that differ, `--from DIR|OWNER/REPO@REF` picks the source, by default the latest compatible release, `engine-v2.5`; `@main` takes the newest, a tag or commit pins it, and `engine-v1` is the last engine with the maths helpers inside `engine.js`); a book's copy is not edited by hand. This reference describes `engine-v2.5`; what an older copy lacks is marked *(v2.1)*, *(v2.2)*, *(v2.3)*, *(v2.4)*, *(v2.4.1)*, *(v2.4.2)* or *(v2.5)*, and syncing the book brings it. An engine bug is fixed at the source, then synced. The book's own settings and style overrides live in `lib/book.css`, imported by `engine.css` and never overwritten: `--math-font` for numbers and formulas, `--progress-key` when the cover uses a key other than the default.
The maths helpers (number lines, tiles, fraction rows, planes, chance objects, the number-set diagram, `pickPoint`, `sorter`) are in `lib/math.js`. A chapter that uses one loads `<script src="../lib/math.js"></script>` right after `engine.js`: it reads the engine's globals as it loads, so never before it and never `async`. `lint.py` names a chapter that uses one without loading it. Use the helpers that fit; draw the rest in the chapter, and move what several chapters use into the book's element library (`lib/<name>.js`, [assets.md](assets.md)) rather than into the engine copy.
@@ -112,7 +112,7 @@ quiz(position, [{ id: 'c-mean', prompt: ['Find the mean of ', $m('7, 3, 9'), '.'
## Player
-Space play/pause, and once the chapter has ended replay *(v2.1)*, ←/→ previous/next beat (Shift+←/→ during a question), Home restart, C captions (a question's narration is captioned too, above its band or beside its corner card, until the narration ends); a beat's last caption clears a second after its narration, so it does not sit on a closing title *(v2.4.2)*; a line in another language with a `sub` (`tts.py`, `eleven.py`) shows its subtitle even with captions off *(v2.4.1)*, `<`/`>` speed (0.75–1.5×, remembered), volume (remembered, except muted), F full screen (which also turns the screen to the stage's orientation where the browser can lock it: Android, not iOS; on a phone held across the stage, starting the chapter goes full screen that way, so a landscape lesson is not a strip on an upright phone), ? help. Clicking a step segment jumps to that point of the beat (`seekInto(i, frac)`); the next beat's clip preloads while one plays. `seek(i, play)` rebuilds and jumps; `start(i, play)` begins a beat from the current picture. While audio plays, the beat clock follows `audio.currentTime`. In a hidden tab (another tab or window in front) a timer keeps the clock going, so the chapter plays on from beat to beat *(v2.3.1; an older engine stops at the end of the beat until the tab is shown again)*. `?beat=N&t=S` in the URL opens a frozen frame for review, without captions (N is kept within the chapter's steps); on a question step the answer box takes focus only once Space starts the lesson. With `?review` in the URL, N pauses and asks for a note on the current moment and Shift+N copies the chapter's notes, one line each with the `?beat=N&t=S` that reopens it, so a reviewer can collect notes while watching and hand them over at once. After the end, on the finish card or a film's last frame, Enter opens `CHAPTER.next` (replays when there is none) and R replays.
+Space play/pause, and once the chapter has ended replay *(v2.1)*, ←/→ previous/next beat (Shift+←/→ during a question), Home restart, C captions (a question's narration is captioned too, above its band or beside its corner card, until the narration ends); a beat's last caption clears a second after its narration, so it does not sit on a closing title *(v2.4.2)*; a line in another language with a `sub` (`tts.py`, `eleven.py`) shows its subtitle even with captions off *(v2.4.1)*, `<`/`>` speed (0.75–1.5×, remembered), volume (remembered, except muted), F full screen *(v2.5)*: the stage fills the screen, and the controls lie over its foot, showing while the pointer moves or a key is pressed, while paused and while the pointer is on them (a touch screen, with no hover, keeps them under the stage); full screen also turns the screen to the stage's orientation where the browser can lock it (Android, not iOS), and on a phone held across the stage, starting the chapter goes full screen that way, so a landscape lesson is not a strip on an upright phone, ? help. Clicking a step segment jumps to that point of the beat (`seekInto(i, frac)`); the next beat's clip preloads while one plays. `seek(i, play)` rebuilds and jumps; `start(i, play)` begins a beat from the current picture. While audio plays, the beat clock follows `audio.currentTime`. In a hidden tab (another tab or window in front) a timer keeps the clock going, so the chapter plays on from beat to beat *(v2.3.1; an older engine stops at the end of the beat until the tab is shown again)*. `?beat=N&t=S` in the URL opens a frozen frame for review, without captions (N is kept within the chapter's steps); on a question step the answer box takes focus only once Space starts the lesson. With `?review` in the URL, N pauses and asks for a note on the current moment and Shift+N copies the chapter's notes, one line each with the `?beat=N&t=S` that reopens it, so a reviewer can collect notes while watching and hand them over at once. After the end, on the finish card or a film's last frame, Enter opens `CHAPTER.next` (replays when there is none) and R replays.
**Sound effects and music** *(v2.2)*, in films only: in a chapter with a question, `sfx()` and `music()` are silent, unless the chapter sets `CHAPTER.film = true` *(v2.3)*: a film with interactive moments (a documentary where the reader fires a rifle). There, while a question beat waits for the reader after its narration, the music plays on (it rises to 70 %, as in a lead-in) and is not pulled back for the time it ran on, and a click on its step bar seeks into it like any other beat; the next beat's tracks take over as usual (`fade` 0 is a cut). `sfx(beat, t, name, vol)` plays `audio/sfx/<name>.mp3` when that beat's clock passes `t` in normal playback (a seek past it fires nothing), at half volume (vol 2 is full); one still loading when it is due plays late, from its start, for up to a second. A long ambience listed in `SFX_BED` with its length (`SFX_BED.birds = 10`) is joined part-way after a seek. `music(file, beats, gain, fade)` is a looping track under the listed beats (all of them by default). Its place is the length of its earlier beats as they really ran plus the clock; a beat under music gives back from its closing hold the time the clock stood still (a clip getting going), so the film keeps the music's time *(v2.4)*. It ducks to 30 % for the whole beat, voice or not, and rises to 70 % only in the `pre` lead-in of the beats in `window.MUSIC_UP_IN_PRE` (`true` for all); it crossfades over `fade` s (0.8; 0 is a cut), and `window.MUSIC_OFF = { beat: t => true }` fades it out for a moment. Both go through one Web Audio graph started by the reader's first touch, click or key, so ducks, fades and the volume slider reach them on phones too (on iOS the slider does not reach the narration). A pause holds the music's level and a seek stops the effects. When a clip loading or buffering holds the clock, the music runs on, then eases back (5 % slower or faster), or jumps back once if it is more than a second out. Safari and every iOS browser stall a media element at each speed change, so there the music keeps the film's speed and is put back by a seek once it is a quarter second out, aimed ahead by the lag it showed after the last one *(v2.4.1)*. `export.py` reads `SFX`, `BGM` and these settings and mixes the film by the same rules.
diff --git a/.claude/skills/papermorph/scripts/engine.py b/.claude/skills/papermorph/scripts/engine.py
index d5f1d24..f44ac51 100644
--- a/.claude/skills/papermorph/scripts/engine.py
+++ b/.claude/skills/papermorph/scripts/engine.py
@@ -20,7 +20,7 @@ with lib/mathjax.js keeps it in step like the rest.
import argparse, filecmp, io, shutil, sys, tarfile, tempfile, urllib.request
from pathlib import Path
-DEFAULT = 'DozenTwelve/[email protected]' # follows the latest compatible release
+DEFAULT = 'DozenTwelve/[email protected]' # follows the latest compatible release
OWN = 'book.css'
LATEX = {'vendor/mathjax/tex-svg-full.js': 'mathjax.js', 'vendor/mathjax/LICENSE': 'mathjax-LICENSE.txt'}
diff --git a/README.md b/README.md
index ac9a831..37e2cdf 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,7 @@ python3 .claude/skills/papermorph/scripts/engine.py site
python3 .claude/skills/papermorph/scripts/engine.py site --from you/your-fork@main
```
-Engine versions are tags (`engine-v2`, `engine-v2.1`, …); a new major number means a book may need a change, described in its [release notes](https://github.com/DozenTwelve/Papermorph/releases). Outside this repository, `engine.py` syncs from the latest compatible release, now `engine-v2.4.2`. Since `engine-v2` the maths helpers (number lines, tiles, planes, the number-set diagram) are in `lib/math.js`: a chapter that uses them loads `../lib/math.js` right after `engine.js`, and `lint.py` names the chapters that need it. `--from DozenTwelve/Papermorph@engine-v1` keeps the earlier engine.
+Engine versions are tags (`engine-v2`, `engine-v2.1`, …); a new major number means a book may need a change, described in its [release notes](https://github.com/DozenTwelve/Papermorph/releases). Outside this repository, `engine.py` syncs from the latest compatible release, now `engine-v2.5`. Since `engine-v2` the maths helpers (number lines, tiles, planes, the number-set diagram) are in `lib/math.js`: a chapter that uses them loads `../lib/math.js` right after `engine.js`, and `lint.py` names the chapters that need it. `--from DozenTwelve/Papermorph@engine-v1` keeps the earlier engine.
## Video and LMS export
diff --git a/engine/engine.css b/engine/engine.css
index f1c8281..7fc7cc5 100644
--- a/engine/engine.css
+++ b/engine/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/engine/engine.js b/engine/engine.js
index 3afaa8a..98477ba 100644
--- a/engine/engine.js
+++ b/engine/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1594,7 +1595,16 @@ function turnPhone() {
if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
}
const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
-document.addEventListener('fullscreenchange', () => { if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {} });
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1650,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/elementary-algebra/lib/engine.css b/site/elementary-algebra/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/elementary-algebra/lib/engine.css
+++ b/site/elementary-algebra/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/elementary-algebra/lib/engine.js
+++ b/site/elementary-algebra/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/joke-collection/lib/engine.css b/site/joke-collection/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/joke-collection/lib/engine.css
+++ b/site/joke-collection/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/joke-collection/lib/engine.js b/site/joke-collection/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/joke-collection/lib/engine.js
+++ b/site/joke-collection/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/little-red-riding-hood/lib/engine.css b/site/little-red-riding-hood/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/little-red-riding-hood/lib/engine.css
+++ b/site/little-red-riding-hood/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/little-red-riding-hood/lib/engine.js
+++ b/site/little-red-riding-hood/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/madness-shorts/lib/engine.css b/site/madness-shorts/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/madness-shorts/lib/engine.css
+++ b/site/madness-shorts/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/madness-shorts/lib/engine.js b/site/madness-shorts/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/madness-shorts/lib/engine.js
+++ b/site/madness-shorts/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/madness/lib/engine.css b/site/madness/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/madness/lib/engine.css
+++ b/site/madness/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/madness/lib/engine.js b/site/madness/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/madness/lib/engine.js
+++ b/site/madness/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/math-notebook/lib/engine.css b/site/math-notebook/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/math-notebook/lib/engine.css
+++ b/site/math-notebook/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/math-notebook/lib/engine.js
+++ b/site/math-notebook/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/physics-notebook/lib/engine.css b/site/physics-notebook/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/physics-notebook/lib/engine.css
+++ b/site/physics-notebook/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/physics-notebook/lib/engine.js b/site/physics-notebook/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/physics-notebook/lib/engine.js
+++ b/site/physics-notebook/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/science/lib/engine.css b/site/science/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/science/lib/engine.css
+++ b/site/science/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/science/lib/engine.js b/site/science/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/science/lib/engine.js
+++ b/site/science/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/shooting-an-elephant/lib/engine.css b/site/shooting-an-elephant/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/shooting-an-elephant/lib/engine.css
+++ b/site/shooting-an-elephant/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/shooting-an-elephant/lib/engine.js b/site/shooting-an-elephant/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/shooting-an-elephant/lib/engine.js
+++ b/site/shooting-an-elephant/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();
diff --git a/site/three-little-pigs/lib/engine.css b/site/three-little-pigs/lib/engine.css
index f1c8281..7fc7cc5 100644
--- a/site/three-little-pigs/lib/engine.css
+++ b/site/three-little-pigs/lib/engine.css
@@ -130,7 +130,27 @@ button[hidden] { display: none; }
#bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
.segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
+ :root.full #bar { transform-origin: left bottom; border-radius: 0; }
}
+/* Full screen: the stage fills the screen and the controls lie over its foot, out of sight until the pointer moves
+ (engine.js wake(): .awake), while paused or ended (.held) and while the pointer is on them. */
+:root.full #frame { top: 50%; height: var(--sh, 900px); border-radius: 0; box-shadow: none; }
+:root.full #bar { top: auto; bottom: 0; transition: opacity .3s; border-top: 0;
+ background: linear-gradient(transparent, color-mix(in srgb, var(--page) 85%, transparent)); }
+:root.full #frame:not(.awake):not(.held) #bar:not(:hover):not(:focus-within) { opacity: 0; pointer-events: none; }
+:root.full #frame:not(.awake):not(.held):not(:has(#bar:hover)) { cursor: none; }
+/* A touch screen has no hover to bring the controls back, and a tap that answers a question would cover the card with
+ them: there full screen keeps them, full size, under the stage (fit() leaves them room). */
+@media (pointer: coarse) {
+ :root.full #frame { top: calc(50% - 30px); overflow: visible; }
+ :root.full #frame #bar { top: var(--sh, 900px); bottom: auto; width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap;
+ gap: 6px; padding: 8px; transform: scale(calc(1 / var(--k))); transform-origin: left top; background: none; opacity: 1 !important; pointer-events: auto !important; }
+ :root.full #bar .icon { width: 40px; height: 40px; }
+ :root.full .step, :root.full #bHelp { display: none; }
+ :root.full .segs { order: 1; min-width: 80px; margin: 0; }
+}
+@media (pointer: coarse) and (max-width: 700px) { :root.full #frame { top: calc(50% - 55px); } }
+
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 19px; }
.sound-note[hidden] { display: none; }
.blanks .brow { padding: 8px 0; border-bottom: 1px solid var(--rule); }
diff --git a/site/three-little-pigs/lib/engine.js b/site/three-little-pigs/lib/engine.js
index ea0e600..98477ba 100644
--- a/site/three-little-pigs/lib/engine.js
+++ b/site/three-little-pigs/lib/engine.js
@@ -1511,6 +1511,7 @@ function ui() {
segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
const fr = $('frame');
fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('held', P.started && (!P.playing || P.done)); // paused or ended: full screen keeps the controls
fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
@@ -1559,7 +1560,7 @@ function hideCover() {
if (BEATS[P.i].ask) $('ui').querySelector('input.box:not(:disabled)')?.focus({ preventScroll: true });
}
function togglePlay() {
- if (!P.started) { hideCover(); return setPlaying(true); }
+ if (!P.started) { turnPhone(); hideCover(); return setPlaying(true); }
if (P.done) return restart(); // the end of a film (or of a chapter whose last step is a question): play again
if (P.waiting) return;
setPlaying(!P.playing);
@@ -1582,7 +1583,28 @@ $('bCC').onclick = () => setCaptions(!captions);
$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
$('bFull').onclick = () => toggleFull();
-const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+// Full screen also turns the screen to the stage's orientation where the browser allows it (Android browsers lock
+// orientation only in full screen; iOS has no lock, so there the reader turns the phone). On a phone held across the
+// stage's orientation, starting the lesson goes full screen the same way, since the stage would otherwise be a strip.
+function goFull() {
+ return document.documentElement.requestFullscreen?.({ navigationUI: 'hide' })
+ .then(() => screen.orientation?.lock?.(PORTRAIT ? 'portrait' : 'landscape')).catch(() => {});
+}
+function turnPhone() {
+ const phone = matchMedia('(pointer: coarse)').matches && Math.min(screen.width, screen.height) <= 600;
+ if (phone && !document.fullscreenElement && (innerHeight > innerWidth) !== PORTRAIT) goFull();
+}
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : goFull();
+// In full screen the stage fills the screen and the controls lie over its foot: they show while the pointer moves (a
+// tap on a phone) or a key is pressed, for 2.5 s after, while paused and while the pointer is on them.
+document.addEventListener('fullscreenchange', () => {
+ document.documentElement.classList.toggle('full', !!document.fullscreenElement);
+ fit(); wake();
+ if (!document.fullscreenElement) try { screen.orientation?.unlock?.(); } catch {}
+});
+let wakeT = 0;
+function wake() { $('frame').classList.add('awake'); clearTimeout(wakeT); wakeT = setTimeout(() => $('frame').classList.remove('awake'), 2500); }
+for (const type of ['pointermove', 'pointerdown', 'keydown']) addEventListener(type, wake, true);
let helpResume = false;
function toggleHelp() {
const open = $('help').hidden;
@@ -1638,7 +1660,10 @@ document.addEventListener('keydown', e => {
// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".
$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });
$('bHelp').onclick = toggleHelp;
-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
+// full screen: the stage alone, except that a touch screen keeps the controls under it (engine.css)
+const fit = () => document.documentElement.style.setProperty('--k', document.fullscreenElement
+ ? Math.min(innerWidth / SW, (innerHeight - (matchMedia('(pointer: coarse)').matches ? innerWidth <= 700 ? 110 : 60 : 0)) / SH)
+ : Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));
addEventListener('resize', fit);
fit();