@johnoscott/isometric-engine 0.17.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/iso-editor.js +103 -100
- package/iso-remotion.js +1 -1
- package/iso-render.js +80 -77
- package/iso-systems.js +66 -63
- package/isometric-diagram.js +91 -88
- package/js/iso-objects/timeline.js +4 -0
- package/js/iso-viewer/play.js +43 -8
- package/package.json +1 -1
- package/src/iso-objects/timeline.ts +2 -0
- package/src/iso-viewer/play.ts +37 -9
- package/types/iso-viewer/play.d.ts +2 -2
- package/types/remotion/frames.d.ts +3 -2
|
@@ -213,6 +213,10 @@ function bindMotion(drawing, doc, opts = {}) {
|
|
|
213
213
|
n.layers.forEach((x, i) => visit(x, `${path}/layers/${i}`, abs));
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
+
if ("assemble" in n || "disassemble" in n) {
|
|
217
|
+
nodeEnd(n, path);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
216
220
|
if ("travel" in n) n.travel.forEach((x, i) => (Array.isArray(x) ? x : [x]).forEach((id, j) => need(id.split(":")[0], `${path}/travel/${i}${Array.isArray(x) ? `/${j}` : ""}`, "route")));
|
|
217
221
|
else if ("pulse" in n) needAll(n.pulse, `${path}/pulse`, "thing");
|
|
218
222
|
else if ("ants" in n) {
|
package/js/iso-viewer/play.js
CHANGED
|
@@ -34,8 +34,8 @@ function mountPlayer(host, o) {
|
|
|
34
34
|
let scene = o.scene, svg = svgOf(scene.rendered.svg), frozen, stepTo, userPaused = false, gone = false;
|
|
35
35
|
const tr = transport(o.timeline ?? NOTHING, { loop: o.loop, rate: o.rate, ambient: o.ambient, clock: o.clock });
|
|
36
36
|
const controls = o.controls ?? true;
|
|
37
|
-
const
|
|
38
|
-
let resting = calm;
|
|
37
|
+
const asked = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, calm = asked && o.reducedMotion === "respect";
|
|
38
|
+
let resting = calm, off = false, inView = true;
|
|
39
39
|
const btn = (cls, label, text2, f) => h("button", { type: "button", class: `iso-play-btn ${cls}`, "aria-label": label, title: label, on: { click: f } }, text2);
|
|
40
40
|
const stage = h("div", { class: "iso-play-stage" }, svg);
|
|
41
41
|
const back = btn("back", "Back", "\u2039", () => byHand(() => step(Math.max(0, at() - 1))));
|
|
@@ -43,13 +43,16 @@ function mountPlayer(host, o) {
|
|
|
43
43
|
const next = btn("next", "Next", "\u203A", () => byHand(() => step(Math.min(tr.timeline.beats.length - 1, at() + 1))));
|
|
44
44
|
const again = btn("again", "Reset", "\u21BA", () => byHand(() => {
|
|
45
45
|
stop();
|
|
46
|
-
tr.
|
|
46
|
+
if (off) tr.seek(0);
|
|
47
|
+
else tr.restart();
|
|
47
48
|
}));
|
|
48
49
|
const amb = btn("ambient", "Ambient motion", "\u223F", () => {
|
|
49
50
|
wake();
|
|
50
51
|
tr.ambient = !tr.ambient;
|
|
51
52
|
show();
|
|
52
53
|
});
|
|
54
|
+
const still = btn("still", "Motion off", "Motion off", () => setOff(!off));
|
|
55
|
+
still.title = "Draw everything in place, with nothing moving";
|
|
53
56
|
const bar = h("input", { type: "range", class: "iso-play-bar", min: 0, step: 1, "aria-label": "Time", on: { input: (() => byHand(() => {
|
|
54
57
|
stop();
|
|
55
58
|
tr.seek(Number(bar.value));
|
|
@@ -60,12 +63,12 @@ function mountPlayer(host, o) {
|
|
|
60
63
|
const text = h("div", { class: "iso-play-text" }), code = h("pre", { class: "iso-play-code" }), facts = h("dl", { class: "iso-play-facts" });
|
|
61
64
|
const say = h("div", { class: "iso-play-say", "aria-live": "polite" }, h("div", { class: "iso-play-head" }, num, title, chapter, count), text, code, facts);
|
|
62
65
|
const list = h("details", { class: "iso-play-list" });
|
|
63
|
-
const row = h("div", { class: "iso-play-row" }, back, play, next, again, amb, bar, time);
|
|
66
|
+
const row = h("div", { class: "iso-play-row" }, back, play, next, again, amb, still, bar, time), alone = h("div", { class: "iso-play-row" });
|
|
64
67
|
const root = h(
|
|
65
68
|
"div",
|
|
66
69
|
{ class: "iso-play", role: "group", "aria-roledescription": "animated diagram", "aria-label": o.label ?? "Diagram", tabindex: controls ? 0 : void 0, "data-mode": o.mode ?? "light" },
|
|
67
70
|
stage,
|
|
68
|
-
controls
|
|
71
|
+
controls ? row : alone,
|
|
69
72
|
controls && dots,
|
|
70
73
|
controls && say,
|
|
71
74
|
controls && list
|
|
@@ -92,6 +95,9 @@ function mountPlayer(host, o) {
|
|
|
92
95
|
say.hidden = !said;
|
|
93
96
|
list.hidden = !said;
|
|
94
97
|
amb.hidden = !tr.timeline.loops;
|
|
98
|
+
still.hidden = !asked || calm || tr.duration <= 0 && !tr.timeline.loops || !controls && !o.autoplay && !tr.timeline.loops;
|
|
99
|
+
alone.hidden = still.hidden;
|
|
100
|
+
if (!controls && !still.hidden) alone.append(still);
|
|
95
101
|
bar.max = String(Math.round(tr.duration));
|
|
96
102
|
for (const el of [play, again, bar, time]) el.hidden = tr.duration <= 0;
|
|
97
103
|
told = void 0;
|
|
@@ -144,7 +150,7 @@ function mountPlayer(host, o) {
|
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
152
|
function show() {
|
|
147
|
-
const S = frozen !== void 0 ? tr.timeline.at(frozen, { ambient: frozen }) : resting ? lit(tr.timeline.at(tr.duration, { ambient: "off" })) : tr.state();
|
|
153
|
+
const S = frozen !== void 0 ? tr.timeline.at(frozen, { ambient: frozen }) : resting ? lit(tr.timeline.at(tr.duration, { ambient: "off" })) : off ? tr.timeline.at(tr.time, { ambient: "off" }) : tr.state();
|
|
148
154
|
paint(svg, S, scene.rendered, { styles: "cssom" });
|
|
149
155
|
root.dataset.time = String(Math.round(frozen ?? tr.time));
|
|
150
156
|
if (frozen !== void 0) marks(tr.timeline.beatAt(frozen));
|
|
@@ -162,6 +168,9 @@ function mountPlayer(host, o) {
|
|
|
162
168
|
amb.setAttribute("aria-pressed", String(tr.ambient));
|
|
163
169
|
say.setAttribute("aria-live", on ? "off" : "polite");
|
|
164
170
|
root.dataset.playing = String(on);
|
|
171
|
+
still.setAttribute("aria-pressed", String(off));
|
|
172
|
+
play.disabled = off;
|
|
173
|
+
amb.disabled = off;
|
|
165
174
|
}
|
|
166
175
|
const going = () => tr.playing && stepTo === void 0;
|
|
167
176
|
const at = () => tr.beat?.index ?? 0;
|
|
@@ -182,6 +191,21 @@ function mountPlayer(host, o) {
|
|
|
182
191
|
stepTo = void 0;
|
|
183
192
|
tr.pause();
|
|
184
193
|
}
|
|
194
|
+
function setOff(v) {
|
|
195
|
+
if (gone || v === off) return;
|
|
196
|
+
off = v;
|
|
197
|
+
resting = v;
|
|
198
|
+
told = void 0;
|
|
199
|
+
stop();
|
|
200
|
+
tr.active = inView && !off;
|
|
201
|
+
tr.seek(off ? tr.duration : 0);
|
|
202
|
+
if (off) list.open = true;
|
|
203
|
+
marks(tr.beat);
|
|
204
|
+
buttons();
|
|
205
|
+
show();
|
|
206
|
+
if (!off && o.autoplay === true && !userPaused) tr.play();
|
|
207
|
+
pick();
|
|
208
|
+
}
|
|
185
209
|
function step(i) {
|
|
186
210
|
const b = tr.timeline.beats[i];
|
|
187
211
|
if (!b || gone) return;
|
|
@@ -189,9 +213,16 @@ function mountPlayer(host, o) {
|
|
|
189
213
|
tr.seek(b.start, { join: true });
|
|
190
214
|
const nextStart = tr.timeline.beats[i + 1]?.start ?? Infinity;
|
|
191
215
|
stepTo = Math.max(b.start, Math.min(b.end, nextStart, tr.duration) - 1);
|
|
216
|
+
if (off) {
|
|
217
|
+
const to = stepTo;
|
|
218
|
+
stepTo = void 0;
|
|
219
|
+
tr.seek(to);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
192
222
|
tr.play({ until: stepTo });
|
|
193
223
|
}
|
|
194
224
|
function toggle() {
|
|
225
|
+
if (off) return;
|
|
195
226
|
wake();
|
|
196
227
|
if (going()) {
|
|
197
228
|
userPaused = true;
|
|
@@ -240,7 +271,7 @@ function mountPlayer(host, o) {
|
|
|
240
271
|
wants: o.autoplay === "visible" && !calm,
|
|
241
272
|
auto(on) {
|
|
242
273
|
if (on) {
|
|
243
|
-
if (!userPaused && !going()) {
|
|
274
|
+
if (!off && !userPaused && !going()) {
|
|
244
275
|
stepTo = void 0;
|
|
245
276
|
tr.play();
|
|
246
277
|
}
|
|
@@ -254,7 +285,8 @@ function mountPlayer(host, o) {
|
|
|
254
285
|
const io = typeof IntersectionObserver === "function" ? new IntersectionObserver((es) => {
|
|
255
286
|
for (const e of es) {
|
|
256
287
|
me.seen = e.isIntersecting ? e.intersectionRatio : 0;
|
|
257
|
-
|
|
288
|
+
inView = e.isIntersecting;
|
|
289
|
+
if (frozen === void 0) tr.active = inView && !off;
|
|
258
290
|
}
|
|
259
291
|
pick();
|
|
260
292
|
}, { threshold: [0, 0.2, 0.35, 0.5, 0.7, 0.9, 1] }) : void 0;
|
|
@@ -310,6 +342,9 @@ const PLAY_CSS = `
|
|
|
310
342
|
.iso-play-btn:hover{border-color:var(--ip-muted)}
|
|
311
343
|
.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}
|
|
312
344
|
.iso-play-btn.ambient[aria-pressed="false"]{color:var(--ip-muted);text-decoration:line-through}
|
|
345
|
+
.iso-play-btn.still{font-size:12px;white-space:nowrap}
|
|
346
|
+
.iso-play-btn.still[aria-pressed="true"]{background:var(--ip-ink);color:var(--ip-bg)}
|
|
347
|
+
.iso-play-btn:disabled{opacity:.4;cursor:default}
|
|
313
348
|
.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}
|
|
314
349
|
.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
315
350
|
.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}
|
package/package.json
CHANGED
|
@@ -217,6 +217,8 @@ export function bindMotion(drawing: CompiledScene | MotionSource, doc: MotionDoc
|
|
|
217
217
|
if ('sequence' in n) { seq(n.sequence, `${path}/sequence`, at(ms(n.sequence.from, 0)), false); return; }
|
|
218
218
|
if ('series' in n) { for (const p of layoutSeries(n.series, `${path}/series`).list) seq(p.s, p.path, at(p.start), false); return; }
|
|
219
219
|
if ('layers' in n) { n.layers.forEach((x, i) => visit(x, `${path}/layers/${i}`, abs)); return; }
|
|
220
|
+
// its plan, whether or not its length was asked for (a beat that says its own length doesn't ask)
|
|
221
|
+
if ('assemble' in n || 'disassemble' in n) { nodeEnd(n, path); return; }
|
|
220
222
|
if ('travel' in n) n.travel.forEach((x, i) => (Array.isArray(x) ? x : [x]).forEach((id, j) => need(id.split(':')[0], `${path}/travel/${i}${Array.isArray(x) ? `/${j}` : ''}`, 'route')));
|
|
221
223
|
else if ('pulse' in n) needAll(n.pulse, `${path}/pulse`, 'thing');
|
|
222
224
|
else if ('ants' in n) { if (n.ants !== true) needAll(n.ants, `${path}/ants`, 'route'); }
|
package/src/iso-viewer/play.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface PlayerOptions {
|
|
|
24
24
|
loop?: boolean;
|
|
25
25
|
rate?: number;
|
|
26
26
|
ambient?: 'on' | 'off';
|
|
27
|
-
/** a reader who asked for less motion (default 'ignore': motion plays). 'respect': the last state, everything lit, the ambient off, until they press Play */
|
|
27
|
+
/** a reader who asked for less motion (default 'ignore': motion plays, and they get a Motion off button). 'respect': the last state, everything lit, the ambient off, until they press Play */
|
|
28
28
|
reducedMotion?: 'ignore' | 'respect';
|
|
29
29
|
mode?: 'light' | 'dark';
|
|
30
30
|
/** the timeline is the drawing's own steps (motionOfSteps): its callouts and marks show at their step, and the other steps' numbers dim */
|
|
@@ -74,8 +74,9 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
74
74
|
let scene = o.scene, svg = svgOf(scene.rendered.svg), frozen: number | undefined, stepTo: number | undefined, userPaused = false, gone = false;
|
|
75
75
|
const tr = transport(o.timeline ?? NOTHING, { loop: o.loop, rate: o.rate, ambient: o.ambient, clock: o.clock });
|
|
76
76
|
const controls = o.controls ?? true;
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const asked = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches, calm = asked && o.reducedMotion === 'respect';
|
|
78
|
+
/** off: the reader pressed Motion off, and nothing moves, whoever asks it to */
|
|
79
|
+
let resting = calm, off = false, inView = true;
|
|
79
80
|
|
|
80
81
|
// ---- the parts ----
|
|
81
82
|
const btn = (cls: string, label: string, text: string, f: () => void) => h('button', { type: 'button', class: `iso-play-btn ${cls}`, 'aria-label': label, title: label, on: { click: f as EventListener } }, text);
|
|
@@ -83,8 +84,11 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
83
84
|
const back = btn('back', 'Back', '‹', () => byHand(() => step(Math.max(0, at() - 1))));
|
|
84
85
|
const play = btn('play', 'Play', '▶', () => toggle());
|
|
85
86
|
const next = btn('next', 'Next', '›', () => byHand(() => step(Math.min(tr.timeline.beats.length - 1, at() + 1))));
|
|
86
|
-
const again = btn('again', 'Reset', '↺', () => byHand(() => { stop(); tr.restart(); }));
|
|
87
|
+
const again = btn('again', 'Reset', '↺', () => byHand(() => { stop(); if (off) tr.seek(0); else tr.restart(); }));
|
|
87
88
|
const amb = btn('ambient', 'Ambient motion', '∿', () => { wake(); tr.ambient = !tr.ambient; show(); });
|
|
89
|
+
// a reader who asked their machine for less motion: it plays, as for anybody, and they get this (docs/design/MOTION.md, 6.2)
|
|
90
|
+
const still = btn('still', 'Motion off', 'Motion off', () => setOff(!off));
|
|
91
|
+
still.title = 'Draw everything in place, with nothing moving';
|
|
88
92
|
const bar = h('input', { type: 'range', class: 'iso-play-bar', min: 0, step: 1, 'aria-label': 'Time', on: { input: (() => byHand(() => { stop(); tr.seek(Number(bar.value)); })) as EventListener } });
|
|
89
93
|
const time = h('span', { class: 'iso-play-time' });
|
|
90
94
|
const dots = h('div', { class: 'iso-play-dots' });
|
|
@@ -92,9 +96,9 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
92
96
|
const text = h('div', { class: 'iso-play-text' }), code = h('pre', { class: 'iso-play-code' }), facts = h('dl', { class: 'iso-play-facts' });
|
|
93
97
|
const say = h('div', { class: 'iso-play-say', 'aria-live': 'polite' }, h('div', { class: 'iso-play-head' }, num, title, chapter, count), text, code, facts);
|
|
94
98
|
const list = h('details', { class: 'iso-play-list' });
|
|
95
|
-
const row = h('div', { class: 'iso-play-row' }, back, play, next, again, amb, bar, time);
|
|
99
|
+
const row = h('div', { class: 'iso-play-row' }, back, play, next, again, amb, still, bar, time), alone = h('div', { class: 'iso-play-row' });
|
|
96
100
|
const root = h('div', { class: 'iso-play', role: 'group', 'aria-roledescription': 'animated diagram', 'aria-label': o.label ?? 'Diagram', tabindex: controls ? 0 : undefined, 'data-mode': o.mode ?? 'light' },
|
|
97
|
-
stage, controls
|
|
101
|
+
stage, controls ? row : alone, controls && dots, controls && say, controls && list);
|
|
98
102
|
host.append(root);
|
|
99
103
|
|
|
100
104
|
// ---- what there is to show: the beats ----
|
|
@@ -113,6 +117,9 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
113
117
|
for (const el of [back, next, dots]) el.hidden = !some;
|
|
114
118
|
say.hidden = !said; list.hidden = !said;
|
|
115
119
|
amb.hidden = !tr.timeline.loops;
|
|
120
|
+
still.hidden = !asked || calm || (tr.duration <= 0 && !tr.timeline.loops) || (!controls && !o.autoplay && !tr.timeline.loops);
|
|
121
|
+
alone.hidden = still.hidden;
|
|
122
|
+
if (!controls && !still.hidden) alone.append(still);
|
|
116
123
|
bar.max = String(Math.round(tr.duration));
|
|
117
124
|
for (const el of [play, again, bar, time]) el.hidden = tr.duration <= 0;
|
|
118
125
|
told = undefined;
|
|
@@ -153,7 +160,7 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
153
160
|
dotOf.forEach((d, i) => { d.classList.toggle('on', i === b?.index); d.classList.toggle('done', b !== undefined && i < b.index); if (i === b?.index) d.setAttribute('aria-current', 'step'); else d.removeAttribute('aria-current'); });
|
|
154
161
|
}
|
|
155
162
|
function show() {
|
|
156
|
-
const S = frozen !== undefined ? tr.timeline.at(frozen, { ambient: frozen }) : resting ? lit(tr.timeline.at(tr.duration, { ambient: 'off' })) : tr.state();
|
|
163
|
+
const S = frozen !== undefined ? tr.timeline.at(frozen, { ambient: frozen }) : resting ? lit(tr.timeline.at(tr.duration, { ambient: 'off' })) : off ? tr.timeline.at(tr.time, { ambient: 'off' }) : tr.state();
|
|
157
164
|
paint(svg, S, scene.rendered, { styles: 'cssom' });
|
|
158
165
|
root.dataset.time = String(Math.round(frozen ?? tr.time));
|
|
159
166
|
if (frozen !== undefined) marks(tr.timeline.beatAt(frozen)); else caption();
|
|
@@ -169,6 +176,8 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
169
176
|
amb.setAttribute('aria-pressed', String(tr.ambient));
|
|
170
177
|
say.setAttribute('aria-live', on ? 'off' : 'polite');
|
|
171
178
|
root.dataset.playing = String(on);
|
|
179
|
+
still.setAttribute('aria-pressed', String(off));
|
|
180
|
+
play.disabled = off; amb.disabled = off;
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
// ---- playing ----
|
|
@@ -180,6 +189,19 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
180
189
|
/** the reader did it: an autoplay doesn't start again by itself */
|
|
181
190
|
function byHand(f: () => void) { wake(); userPaused = true; f(); buttons(); show(); }
|
|
182
191
|
function stop() { stepTo = undefined; tr.pause(); }
|
|
192
|
+
/** off: everything in place and lit, nothing moving, the steps open as text; on again: from the first step, playing if it began by itself */
|
|
193
|
+
function setOff(v: boolean) {
|
|
194
|
+
if (gone || v === off) return;
|
|
195
|
+
off = v; resting = v; told = undefined;
|
|
196
|
+
stop();
|
|
197
|
+
tr.active = inView && !off;
|
|
198
|
+
tr.seek(off ? tr.duration : 0);
|
|
199
|
+
if (off) list.open = true;
|
|
200
|
+
marks(tr.beat);
|
|
201
|
+
buttons(); show();
|
|
202
|
+
if (!off && o.autoplay === true && !userPaused) tr.play();
|
|
203
|
+
pick();
|
|
204
|
+
}
|
|
183
205
|
function step(i: number) {
|
|
184
206
|
const b = tr.timeline.beats[i];
|
|
185
207
|
if (!b || gone) return;
|
|
@@ -188,9 +210,12 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
188
210
|
const nextStart = tr.timeline.beats[i + 1]?.start ?? Infinity;
|
|
189
211
|
// through the beat, and to a stop within it (its end is the next one's start)
|
|
190
212
|
stepTo = Math.max(b.start, Math.min(b.end, nextStart, tr.duration) - 1);
|
|
213
|
+
// off: the step as it is when it is over, and no way there
|
|
214
|
+
if (off) { const to = stepTo; stepTo = undefined; tr.seek(to); return; }
|
|
191
215
|
tr.play({ until: stepTo });
|
|
192
216
|
}
|
|
193
217
|
function toggle() {
|
|
218
|
+
if (off) return;
|
|
194
219
|
wake();
|
|
195
220
|
if (going()) { userPaused = true; stop(); } else { userPaused = false; stepTo = undefined; tr.pause(); tr.play(); }
|
|
196
221
|
buttons(); show();
|
|
@@ -216,10 +241,10 @@ export function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): P
|
|
|
216
241
|
// ---- in view: neither clock moves for a player nobody can see; one that autoplays in view is one at a time ----
|
|
217
242
|
const me = {
|
|
218
243
|
seen: 0, wants: o.autoplay === 'visible' && !calm,
|
|
219
|
-
auto(on: boolean) { if (on) { if (!userPaused && !going()) { stepTo = undefined; tr.play(); } } else if (going()) { stepTo = undefined; tr.pause(); } },
|
|
244
|
+
auto(on: boolean) { if (on) { if (!off && !userPaused && !going()) { stepTo = undefined; tr.play(); } } else if (going()) { stepTo = undefined; tr.pause(); } },
|
|
220
245
|
};
|
|
221
246
|
mounted.set(root, me);
|
|
222
|
-
const io = typeof IntersectionObserver === 'function' ? new IntersectionObserver(es => { for (const e of es) { me.seen = e.isIntersecting ? e.intersectionRatio : 0; if (frozen === undefined) tr.active =
|
|
247
|
+
const io = typeof IntersectionObserver === 'function' ? new IntersectionObserver(es => { for (const e of es) { me.seen = e.isIntersecting ? e.intersectionRatio : 0; inView = e.isIntersecting; if (frozen === undefined) tr.active = inView && !off; } pick(); }, { threshold: [0, 0.2, 0.35, 0.5, 0.7, 0.9, 1] }) : undefined;
|
|
223
248
|
io?.observe(root);
|
|
224
249
|
|
|
225
250
|
beats(); buttons(); show();
|
|
@@ -254,6 +279,9 @@ export const PLAY_CSS = `
|
|
|
254
279
|
.iso-play-btn:hover{border-color:var(--ip-muted)}
|
|
255
280
|
.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}
|
|
256
281
|
.iso-play-btn.ambient[aria-pressed="false"]{color:var(--ip-muted);text-decoration:line-through}
|
|
282
|
+
.iso-play-btn.still{font-size:12px;white-space:nowrap}
|
|
283
|
+
.iso-play-btn.still[aria-pressed="true"]{background:var(--ip-ink);color:var(--ip-bg)}
|
|
284
|
+
.iso-play-btn:disabled{opacity:.4;cursor:default}
|
|
257
285
|
.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}
|
|
258
286
|
.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
259
287
|
.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}
|
|
@@ -14,7 +14,7 @@ export interface PlayerOptions {
|
|
|
14
14
|
loop?: boolean;
|
|
15
15
|
rate?: number;
|
|
16
16
|
ambient?: 'on' | 'off';
|
|
17
|
-
/** a reader who asked for less motion (default 'ignore': motion plays). 'respect': the last state, everything lit, the ambient off, until they press Play */
|
|
17
|
+
/** a reader who asked for less motion (default 'ignore': motion plays, and they get a Motion off button). 'respect': the last state, everything lit, the ambient off, until they press Play */
|
|
18
18
|
reducedMotion?: 'ignore' | 'respect';
|
|
19
19
|
mode?: 'light' | 'dark';
|
|
20
20
|
/** the timeline is the drawing's own steps (motionOfSteps): its callouts and marks show at their step, and the other steps' numbers dim */
|
|
@@ -34,4 +34,4 @@ export interface Player {
|
|
|
34
34
|
}
|
|
35
35
|
export declare function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): Player;
|
|
36
36
|
/** The player's stylesheet: its own, under one class; the colours are custom properties a host may set. */
|
|
37
|
-
export declare const PLAY_CSS = "\n.iso-play{--ip-ink:#1c2026;--ip-muted:#68707c;--ip-line:#dfe3e8;--ip-bg:#fff;--ip-code:#f2f4f7;--ip-focus:#2a64d6;container:iso-play/inline-size;display:block;color:var(--ip-ink);background:var(--ip-bg);font:14px/1.5 system-ui,-apple-system,\"Segoe UI\",sans-serif;border-radius:10px}\n.iso-play[data-mode=\"dark\"]{--ip-ink:#e6e9ee;--ip-muted:#98a1ae;--ip-line:#333a44;--ip-bg:#15181d;--ip-code:#1f242b;--ip-focus:#7aa7ff;color-scheme:dark}\n.iso-play:focus-visible,.iso-play button:focus-visible,.iso-play input:focus-visible,.iso-play summary:focus-visible{outline:2px solid var(--ip-focus);outline-offset:2px}\n.iso-play [hidden]{display:none}\n.iso-play-stage svg{display:block;width:100%;height:auto}\n.iso-play-stage [data-go]{cursor:pointer}\n.iso-play-row{display:flex;align-items:center;gap:6px;padding:8px 12px 4px}\n.iso-play-btn{font:inherit;min-width:32px;height:32px;padding:0 8px;border:1px solid var(--ip-line);border-radius:8px;background:none;color:inherit;cursor:pointer}\n.iso-play-btn:hover{border-color:var(--ip-muted)}\n.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}\n.iso-play-btn.ambient[aria-pressed=\"false\"]{color:var(--ip-muted);text-decoration:line-through}\n.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}\n.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}\n.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}\n.iso-play-group{display:inline-flex;gap:0}\n.iso-play-dot{width:24px;height:24px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center}\n.iso-play-dot::before{content:\"\";width:9px;height:9px;border-radius:50%;background:var(--ip-line)}\n.iso-play-dot.done::before{background:var(--ip-muted)}\n.iso-play-dot.on::before{background:var(--ip-ink);width:11px;height:11px}\n.iso-play-say{padding:4px 12px 10px;min-height:5.2em}\n.iso-play-head{display:flex;align-items:baseline;gap:8px;font-weight:700}\n.iso-play-num{flex:none;display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:11px;background:var(--ip-ink);color:var(--ip-bg);font-size:11px;align-self:center}\n.iso-play-chapter,.iso-play-count{color:var(--ip-muted);font-size:12px;font-weight:500}\n.iso-play-count{margin-left:auto;white-space:nowrap}\n.iso-play-text{max-width:80ch}\n.iso-play-text a{color:inherit}\n.iso-play-code{margin:6px 0 0;padding:6px 10px;border-radius:8px;background:var(--ip-code);font:12px/1.5 ui-monospace,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}\n.iso-play-facts{display:flex;flex-wrap:wrap;gap:2px 16px;margin:6px 0 0;font-size:12px}\n.iso-play-facts dt{color:var(--ip-muted)}\n.iso-play-facts dd{margin:0 8px 0 -10px;font-weight:600}\n.iso-play-list{padding:0 12px 10px;font-size:13px}\n.iso-play-list summary{color:var(--ip-muted);cursor:pointer}\n.iso-play.frozen>:not(.iso-play-stage){display:none}\n@container iso-play (max-width:420px){.iso-play-time{display:none}.iso-play-row{flex-wrap:wrap}.iso-play-bar{flex-basis:100%;order:9}}\n";
|
|
37
|
+
export declare const PLAY_CSS = "\n.iso-play{--ip-ink:#1c2026;--ip-muted:#68707c;--ip-line:#dfe3e8;--ip-bg:#fff;--ip-code:#f2f4f7;--ip-focus:#2a64d6;container:iso-play/inline-size;display:block;color:var(--ip-ink);background:var(--ip-bg);font:14px/1.5 system-ui,-apple-system,\"Segoe UI\",sans-serif;border-radius:10px}\n.iso-play[data-mode=\"dark\"]{--ip-ink:#e6e9ee;--ip-muted:#98a1ae;--ip-line:#333a44;--ip-bg:#15181d;--ip-code:#1f242b;--ip-focus:#7aa7ff;color-scheme:dark}\n.iso-play:focus-visible,.iso-play button:focus-visible,.iso-play input:focus-visible,.iso-play summary:focus-visible{outline:2px solid var(--ip-focus);outline-offset:2px}\n.iso-play [hidden]{display:none}\n.iso-play-stage svg{display:block;width:100%;height:auto}\n.iso-play-stage [data-go]{cursor:pointer}\n.iso-play-row{display:flex;align-items:center;gap:6px;padding:8px 12px 4px}\n.iso-play-btn{font:inherit;min-width:32px;height:32px;padding:0 8px;border:1px solid var(--ip-line);border-radius:8px;background:none;color:inherit;cursor:pointer}\n.iso-play-btn:hover{border-color:var(--ip-muted)}\n.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}\n.iso-play-btn.ambient[aria-pressed=\"false\"]{color:var(--ip-muted);text-decoration:line-through}\n.iso-play-btn.still{font-size:12px;white-space:nowrap}\n.iso-play-btn.still[aria-pressed=\"true\"]{background:var(--ip-ink);color:var(--ip-bg)}\n.iso-play-btn:disabled{opacity:.4;cursor:default}\n.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}\n.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}\n.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}\n.iso-play-group{display:inline-flex;gap:0}\n.iso-play-dot{width:24px;height:24px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center}\n.iso-play-dot::before{content:\"\";width:9px;height:9px;border-radius:50%;background:var(--ip-line)}\n.iso-play-dot.done::before{background:var(--ip-muted)}\n.iso-play-dot.on::before{background:var(--ip-ink);width:11px;height:11px}\n.iso-play-say{padding:4px 12px 10px;min-height:5.2em}\n.iso-play-head{display:flex;align-items:baseline;gap:8px;font-weight:700}\n.iso-play-num{flex:none;display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:11px;background:var(--ip-ink);color:var(--ip-bg);font-size:11px;align-self:center}\n.iso-play-chapter,.iso-play-count{color:var(--ip-muted);font-size:12px;font-weight:500}\n.iso-play-count{margin-left:auto;white-space:nowrap}\n.iso-play-text{max-width:80ch}\n.iso-play-text a{color:inherit}\n.iso-play-code{margin:6px 0 0;padding:6px 10px;border-radius:8px;background:var(--ip-code);font:12px/1.5 ui-monospace,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}\n.iso-play-facts{display:flex;flex-wrap:wrap;gap:2px 16px;margin:6px 0 0;font-size:12px}\n.iso-play-facts dt{color:var(--ip-muted)}\n.iso-play-facts dd{margin:0 8px 0 -10px;font-weight:600}\n.iso-play-list{padding:0 12px 10px;font-size:13px}\n.iso-play-list summary{color:var(--ip-muted);cursor:pointer}\n.iso-play.frozen>:not(.iso-play-stage){display:none}\n@container iso-play (max-width:420px){.iso-play-time{display:none}.iso-play-row{flex-wrap:wrap}.iso-play-bar{flex-basis:100%;order:9}}\n";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Compiled, type CompiledScene } from '../iso-systems/compile.js';
|
|
2
2
|
import { type Cue, type Timeline } from '../iso-objects/timeline.js';
|
|
3
3
|
import { type MotionDoc, type Transition } from '../iso-objects/motion-doc.js';
|
|
4
|
-
|
|
4
|
+
/** (a type, not an interface: Remotion's Composition takes props that are a record of unknowns, and an interface isn't one) */
|
|
5
|
+
export type DrawingProps = {
|
|
5
6
|
/** the drawing's text */
|
|
6
7
|
src: string;
|
|
7
8
|
/** the theme's text */
|
|
@@ -16,7 +17,7 @@ export interface DrawingProps {
|
|
|
16
17
|
font?: 'arimo';
|
|
17
18
|
/** the ambient clock: with the video (default), or 'off' */
|
|
18
19
|
ambient?: 'off';
|
|
19
|
-
}
|
|
20
|
+
};
|
|
20
21
|
export interface Drawing {
|
|
21
22
|
compiled: Compiled;
|
|
22
23
|
scene: CompiledScene;
|