@vectoriox/iox-ui 5.70.2 → 5.71.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/fesm2022/vectoriox-iox-ui-scene-core.mjs +240 -8
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/package.json +1 -1
- package/scene-core/index.d.ts +104 -3
- package/src/scene-core/public-api.ts +1 -0
- package/src/scene-core/scene-edit.ts +233 -0
- package/src/scene-core/scroll-driver.ts +62 -7
|
@@ -210,6 +210,196 @@ const SCENE_FLOW_RULES = `.iox-role-scene{height:auto!important}`
|
|
|
210
210
|
/** Under reduced motion the driver never starts, so the same rules hold for the whole visit. */
|
|
211
211
|
const SCENE_REDUCED_MOTION_CSS = `@media (prefers-reduced-motion: reduce){${SCENE_FLOW_RULES}}`;
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Authoring a Scene (premium-sites plan §5b, SC2): the decisions the builder's timeline and its panel share, so neither
|
|
215
|
+
* holds a second copy of what a key is. Pure, and every edit returns NEW tracks: the caller assigns them to the node, so
|
|
216
|
+
* undo's snapshot and the attribute the driver reads can never see a half-made edit.
|
|
217
|
+
*
|
|
218
|
+
* One rule to author by: one key holds, two keys move. A value edited at a scroll position sets a key there, so a layer
|
|
219
|
+
* is animated by scrolling to a moment and saying where it stands at that moment.
|
|
220
|
+
*/
|
|
221
|
+
/** Keys sit on whole percents of the scroll: finer than anyone can place by hand, and two keys never nearly coincide. */
|
|
222
|
+
const KEY_GRID = 100;
|
|
223
|
+
function sceneKeyPosition(p) {
|
|
224
|
+
return Math.round(Math.min(1, Math.max(0, p)) * KEY_GRID) / KEY_GRID;
|
|
225
|
+
}
|
|
226
|
+
const PERCENT = '%';
|
|
227
|
+
const DEGREES = '°';
|
|
228
|
+
/** The closed vocabulary, in the order the panel lists it. */
|
|
229
|
+
const SCENE_TRACK_DEFS = [
|
|
230
|
+
{ prop: SceneProp.X, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },
|
|
231
|
+
{ prop: SceneProp.Y, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },
|
|
232
|
+
{ prop: SceneProp.Scale, colour: false, rest: 1, min: 0, max: 2000, step: 1, factor: 100, unit: PERCENT },
|
|
233
|
+
{ prop: SceneProp.Rotate, colour: false, rest: 0, min: -720, max: 720, step: 1, factor: 1, unit: DEGREES },
|
|
234
|
+
{ prop: SceneProp.Opacity, colour: false, rest: 1, min: 0, max: 100, step: 1, factor: 100, unit: PERCENT },
|
|
235
|
+
{ prop: SceneProp.Clip, colour: false, rest: 0, min: 0, max: 50, step: 1, factor: 1, unit: PERCENT },
|
|
236
|
+
{ prop: SceneProp.Ground, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },
|
|
237
|
+
{ prop: SceneProp.Ink, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },
|
|
238
|
+
];
|
|
239
|
+
const DEF_BY_PROP = new Map(SCENE_TRACK_DEFS.map(def => [def.prop, def]));
|
|
240
|
+
function sceneTrackDef(prop) {
|
|
241
|
+
return DEF_BY_PROP.get(prop);
|
|
242
|
+
}
|
|
243
|
+
const trackOf = (tracks, prop) => tracks.find(t => t.prop === prop);
|
|
244
|
+
const samePosition = (a, b) => sceneKeyPosition(a) === sceneKeyPosition(b);
|
|
245
|
+
const roundTo = (value, places = 4) => Number(value.toFixed(places));
|
|
246
|
+
/** A number track's value at `p` in the author's units, or where the layer rests when it has no such track. */
|
|
247
|
+
function sceneDisplayValue(tracks, prop, p) {
|
|
248
|
+
const def = sceneTrackDef(prop);
|
|
249
|
+
const track = trackOf(tracks, prop);
|
|
250
|
+
return roundTo((track ? valueAt(track.keys, p) : def.rest) * def.factor, 2);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The colour to show for a colour track at `p`: the key at or before it, else the first. Between two keys the live value
|
|
254
|
+
* is a mix, which is no value a colour control can edit; the author sets keys, so the panel shows a key.
|
|
255
|
+
*/
|
|
256
|
+
function sceneColourKeyAt(tracks, prop, p) {
|
|
257
|
+
const keys = trackOf(tracks, prop)?.keys;
|
|
258
|
+
if (!keys?.length)
|
|
259
|
+
return '';
|
|
260
|
+
let held = keys[0];
|
|
261
|
+
for (const key of keys)
|
|
262
|
+
if (key[0] <= sceneKeyPosition(p))
|
|
263
|
+
held = key;
|
|
264
|
+
return String(held[1]);
|
|
265
|
+
}
|
|
266
|
+
function sceneHasKeyAt(tracks, prop, p) {
|
|
267
|
+
return !!trackOf(tracks, prop)?.keys.some(key => samePosition(key[0], p));
|
|
268
|
+
}
|
|
269
|
+
function storedValue(def, value) {
|
|
270
|
+
if (def.colour)
|
|
271
|
+
return value;
|
|
272
|
+
return roundTo(Math.min(def.max, Math.max(def.min, Number(value))) / def.factor);
|
|
273
|
+
}
|
|
274
|
+
function replaceTrack(tracks, prop, keys) {
|
|
275
|
+
const rest = tracks.filter(t => t.prop !== prop);
|
|
276
|
+
if (!keys.length)
|
|
277
|
+
return rest;
|
|
278
|
+
const at = tracks.findIndex(t => t.prop === prop);
|
|
279
|
+
const next = [...rest];
|
|
280
|
+
next.splice(at < 0 ? rest.length : at, 0, { prop, keys });
|
|
281
|
+
return next;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Set a key at `p`, in the author's units. A number is clamped to its bounds; a colour that is no colour changes nothing,
|
|
285
|
+
* because `normalizeTracks` would drop it anyway and the author's other keys must survive.
|
|
286
|
+
*/
|
|
287
|
+
function withSceneKey(tracks, prop, p, value) {
|
|
288
|
+
const def = sceneTrackDef(prop);
|
|
289
|
+
const at = sceneKeyPosition(p);
|
|
290
|
+
if (!def.colour && !Number.isFinite(Number(value)))
|
|
291
|
+
return [...tracks];
|
|
292
|
+
const key = [at, storedValue(def, value)];
|
|
293
|
+
const others = (trackOf(tracks, prop)?.keys ?? []).filter(k => !samePosition(k[0], at));
|
|
294
|
+
const keys = [...others, key].sort((a, b) => a[0] - b[0]);
|
|
295
|
+
const next = replaceTrack(tracks, prop, keys);
|
|
296
|
+
return trackOf(normalizeTracks(next), prop)?.keys.length === keys.length ? next : [...tracks];
|
|
297
|
+
}
|
|
298
|
+
/** Remove the key at `p`. The last key of a track takes the track with it. */
|
|
299
|
+
function withoutSceneKey(tracks, prop, p) {
|
|
300
|
+
const track = trackOf(tracks, prop);
|
|
301
|
+
if (!track)
|
|
302
|
+
return [...tracks];
|
|
303
|
+
return replaceTrack(tracks, prop, track.keys.filter(key => !samePosition(key[0], p)));
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Move a key from `from` toward `to`, stopping one grid step short of its neighbours: keys never swap, so a drag can
|
|
307
|
+
* never reverse a movement the author set. Returns where it landed, so a drag keeps following it.
|
|
308
|
+
*/
|
|
309
|
+
function movedSceneKey(tracks, prop, from, to) {
|
|
310
|
+
const track = trackOf(tracks, prop);
|
|
311
|
+
const index = track ? track.keys.findIndex(key => samePosition(key[0], from)) : -1;
|
|
312
|
+
if (!track || index < 0)
|
|
313
|
+
return { tracks: [...tracks], at: sceneKeyPosition(from) };
|
|
314
|
+
const step = 1 / KEY_GRID;
|
|
315
|
+
const low = index > 0 ? track.keys[index - 1][0] + step : 0;
|
|
316
|
+
const high = index < track.keys.length - 1 ? track.keys[index + 1][0] - step : 1;
|
|
317
|
+
const at = sceneKeyPosition(Math.min(high, Math.max(low, to)));
|
|
318
|
+
const keys = track.keys.map((key, i) => (i === index ? [at, key[1]] : key));
|
|
319
|
+
return { tracks: replaceTrack(tracks, prop, keys), at };
|
|
320
|
+
}
|
|
321
|
+
/** A track's bar on the timeline: from its first key to its last, as fractions of the scroll. */
|
|
322
|
+
function sceneTrackSpan(track) {
|
|
323
|
+
return { from: track.keys[0][0], to: track.keys[track.keys.length - 1][0] };
|
|
324
|
+
}
|
|
325
|
+
/** The Scene a selection sits in: the innermost Scene on its path from the top. */
|
|
326
|
+
function sceneRootOnPath(path) {
|
|
327
|
+
for (let i = path.length - 1; i >= 0; i--)
|
|
328
|
+
if (path[i].role === SceneRole.Scene)
|
|
329
|
+
return path[i];
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
/** Every Scene on a page, in document order, a Scene inside a Scene included. */
|
|
333
|
+
function scenesIn(nodes) {
|
|
334
|
+
const found = [];
|
|
335
|
+
for (const node of nodes ?? []) {
|
|
336
|
+
if (node.role === SceneRole.Scene)
|
|
337
|
+
found.push(node);
|
|
338
|
+
found.push(...scenesIn((node.children ?? [])));
|
|
339
|
+
}
|
|
340
|
+
return found;
|
|
341
|
+
}
|
|
342
|
+
const hasTracks = (node) => normalizeTracks(node.sceneTracks).length > 0 || normalizeTracks(node.scenePhoneTracks).length > 0;
|
|
343
|
+
/**
|
|
344
|
+
* What the timeline lists: the stage, everything standing on it, and anything deeper that carries tracks. A layer with
|
|
345
|
+
* none is listed too, or it could never be given its first. A Scene inside this one keeps its own timeline.
|
|
346
|
+
*/
|
|
347
|
+
function sceneLayersOf(root) {
|
|
348
|
+
const stage = (root?.children ?? []).find(child => child.role === SceneRole.Stage);
|
|
349
|
+
if (!stage)
|
|
350
|
+
return [];
|
|
351
|
+
const layers = [stage];
|
|
352
|
+
const deeper = (node) => {
|
|
353
|
+
for (const child of (node.children ?? [])) {
|
|
354
|
+
if (child.role === SceneRole.Scene)
|
|
355
|
+
continue;
|
|
356
|
+
if (hasTracks(child))
|
|
357
|
+
layers.push(child);
|
|
358
|
+
deeper(child);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
for (const child of (stage.children ?? [])) {
|
|
362
|
+
if (child.role === SceneRole.Scene)
|
|
363
|
+
continue;
|
|
364
|
+
layers.push(child);
|
|
365
|
+
deeper(child);
|
|
366
|
+
}
|
|
367
|
+
return layers;
|
|
368
|
+
}
|
|
369
|
+
/** How many screens of scrolling a Scene holds for, and the bounds the panel offers. */
|
|
370
|
+
const SCENE_MIN_SCREENS = 0.5;
|
|
371
|
+
const SCENE_MAX_SCREENS = 20;
|
|
372
|
+
const VIEWPORT_HEIGHT = /^([\d.]+)[sdl]?vh$/;
|
|
373
|
+
/**
|
|
374
|
+
* The root's height as screens of scrolling: the stage itself takes one screen, so 400vh holds for 3. Null for a height
|
|
375
|
+
* set in anything else (a hand-set px), which the panel then says it cannot express rather than overwriting it.
|
|
376
|
+
*/
|
|
377
|
+
function sceneScreensOf(height) {
|
|
378
|
+
const match = VIEWPORT_HEIGHT.exec(String(height ?? '').trim());
|
|
379
|
+
if (!match)
|
|
380
|
+
return null;
|
|
381
|
+
return Math.max(0, roundTo(Number(match[1]) / 100 - 1, 2));
|
|
382
|
+
}
|
|
383
|
+
function sceneHeightForScreens(screens) {
|
|
384
|
+
const held = Math.min(SCENE_MAX_SCREENS, Math.max(SCENE_MIN_SCREENS, screens));
|
|
385
|
+
return `${roundTo((held + 1) * 100, 1)}vh`;
|
|
386
|
+
}
|
|
387
|
+
/** Motion v2 §3d's limits for scroll-linked work on one page. */
|
|
388
|
+
const SCENE_BUDGET = { heldSections: 1, movingLayers: 8 };
|
|
389
|
+
/** What a page's Scenes cost. Advice to the author, never a refusal: the composer enforces it from SC6. */
|
|
390
|
+
function sceneBudget(nodes) {
|
|
391
|
+
const scenes = scenesIn(nodes);
|
|
392
|
+
const moving = scenes.flatMap(scene => sceneLayersOf(scene)).filter(hasTracks);
|
|
393
|
+
const movingLayers = new Set(moving).size;
|
|
394
|
+
const tracks = [...new Set(moving)].reduce((sum, node) => sum + normalizeTracks(node.sceneTracks).length, 0);
|
|
395
|
+
return {
|
|
396
|
+
tracks,
|
|
397
|
+
heldSections: scenes.length,
|
|
398
|
+
movingLayers,
|
|
399
|
+
within: scenes.length <= SCENE_BUDGET.heldSections && movingLayers <= SCENE_BUDGET.movingLayers,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
213
403
|
/** Generic words a fresh Scene starts with: the author's to replace. */
|
|
214
404
|
const SCENE_WORDS = {
|
|
215
405
|
title: 'One idea, held still',
|
|
@@ -337,8 +527,10 @@ class ScrollDriver {
|
|
|
337
527
|
const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);
|
|
338
528
|
const settled = Math.abs(next - target) < SETTLED;
|
|
339
529
|
scene.progress = settled ? target : next;
|
|
530
|
+
scene.target = target;
|
|
340
531
|
scene.fresh = false;
|
|
341
532
|
this.write(scene);
|
|
533
|
+
this.options.onFrame?.(scene.root, { target, progress: scene.progress });
|
|
342
534
|
moving = moving || !settled;
|
|
343
535
|
}
|
|
344
536
|
if (moving)
|
|
@@ -356,17 +548,17 @@ class ScrollDriver {
|
|
|
356
548
|
/** Drive a Scene's root. Idempotent: adding a root again re-reads it. */
|
|
357
549
|
add(root) {
|
|
358
550
|
this.remove(root);
|
|
359
|
-
const scene = { root, stage: null, layers: [], progress: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
551
|
+
const scene = { root, stage: null, layers: [], progress: 0, target: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
360
552
|
this.scenes.set(root, scene);
|
|
361
553
|
this.resize?.observe(root);
|
|
362
554
|
if (this.options.observe) {
|
|
363
555
|
const Observer = this.host.MutationObserver;
|
|
364
556
|
if (Observer) {
|
|
365
|
-
scene.mutations = new Observer(() => this.
|
|
557
|
+
scene.mutations = new Observer(() => this.readScene(scene));
|
|
366
558
|
scene.mutations.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: [SceneAttribute.Tracks, SceneAttribute.PhoneTracks] });
|
|
367
559
|
}
|
|
368
560
|
}
|
|
369
|
-
this.
|
|
561
|
+
this.readScene(scene);
|
|
370
562
|
}
|
|
371
563
|
remove(root) {
|
|
372
564
|
const scene = this.scenes.get(root);
|
|
@@ -380,10 +572,33 @@ class ScrollDriver {
|
|
|
380
572
|
layer.el.style.removeProperty('will-change');
|
|
381
573
|
this.scenes.delete(root);
|
|
382
574
|
}
|
|
575
|
+
/** Read a root's layers again now, keeping where it stands: an editor changed their tracks. */
|
|
576
|
+
reread(root) {
|
|
577
|
+
const scene = this.scenes.get(root);
|
|
578
|
+
if (scene)
|
|
579
|
+
this.readScene(scene);
|
|
580
|
+
}
|
|
383
581
|
/** The damped progress a root's layers stand at. */
|
|
384
582
|
progressOf(root) {
|
|
385
583
|
return this.scenes.get(root)?.progress ?? null;
|
|
386
584
|
}
|
|
585
|
+
/** Where the scroll stands in a root's travel, undamped. */
|
|
586
|
+
targetOf(root) {
|
|
587
|
+
return this.scenes.get(root)?.target ?? null;
|
|
588
|
+
}
|
|
589
|
+
/** Page px from the root's top to the scroll position that stands it at `p`. */
|
|
590
|
+
offsetFor(root, p) {
|
|
591
|
+
const scene = this.scenes.get(root);
|
|
592
|
+
return scene ? scene.travel * Math.min(1, Math.max(0, p)) : null;
|
|
593
|
+
}
|
|
594
|
+
/** Land on the next frame with no glide: a scrubber sets a position, and the author is waiting to see that moment. */
|
|
595
|
+
settle(root) {
|
|
596
|
+
const scene = this.scenes.get(root);
|
|
597
|
+
if (!scene)
|
|
598
|
+
return;
|
|
599
|
+
scene.fresh = true;
|
|
600
|
+
this.wake();
|
|
601
|
+
}
|
|
387
602
|
/** Something moved that no scroll or resize announces (the canvas's zoom). */
|
|
388
603
|
wake() {
|
|
389
604
|
if (this.frame)
|
|
@@ -401,19 +616,30 @@ class ScrollDriver {
|
|
|
401
616
|
this.resize?.disconnect();
|
|
402
617
|
}
|
|
403
618
|
/** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */
|
|
404
|
-
|
|
619
|
+
readScene(scene) {
|
|
405
620
|
scene.stage = scene.root.querySelector(STAGE_SELECTOR);
|
|
621
|
+
const previous = scene.layers;
|
|
406
622
|
scene.layers = Array.from(scene.root.querySelectorAll(`[${SceneAttribute.Tracks}], [${SceneAttribute.PhoneTracks}]`))
|
|
407
623
|
.filter(el => el === scene.root || el.parentElement?.closest(`[${SceneAttribute.Root}]`) === scene.root)
|
|
408
624
|
.map(el => this.readLayer(el, scene));
|
|
625
|
+
// A layer that lost its last track stands as its own styles say again, not at the frame it last held.
|
|
626
|
+
for (const layer of previous) {
|
|
627
|
+
if (!scene.layers.some(current => current.el === layer.el))
|
|
628
|
+
this.letGo(layer);
|
|
629
|
+
}
|
|
409
630
|
this.measure(scene);
|
|
410
631
|
scene.fresh = true;
|
|
411
632
|
this.wake();
|
|
412
633
|
}
|
|
634
|
+
letGo(layer) {
|
|
635
|
+
layer.el.style.removeProperty('will-change');
|
|
636
|
+
for (const key of Object.keys(layer.last))
|
|
637
|
+
layer.el.style[key] = '';
|
|
638
|
+
}
|
|
413
639
|
readLayer(el, scene) {
|
|
414
640
|
const previous = scene.layers.find(layer => layer.el === el);
|
|
415
641
|
el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);
|
|
416
|
-
return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {} };
|
|
642
|
+
return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {}, stale: true };
|
|
417
643
|
}
|
|
418
644
|
remeasureAll() {
|
|
419
645
|
for (const scene of this.scenes.values())
|
|
@@ -426,7 +652,7 @@ class ScrollDriver {
|
|
|
426
652
|
scene.phone = (scene.stage?.offsetWidth ?? Infinity) <= SCENE_PHONE_MAX_WIDTH;
|
|
427
653
|
scene.inlineSign = scene.stage && this.host.getComputedStyle(scene.stage).direction === 'rtl' ? -1 : 1;
|
|
428
654
|
for (const layer of scene.layers)
|
|
429
|
-
layer.
|
|
655
|
+
layer.stale = true;
|
|
430
656
|
}
|
|
431
657
|
read(scene) {
|
|
432
658
|
const rect = scene.root.getBoundingClientRect();
|
|
@@ -440,10 +666,16 @@ class ScrollDriver {
|
|
|
440
666
|
const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;
|
|
441
667
|
const frame = sceneFrame(tracks, scene.progress, { inlineSign: scene.inlineSign });
|
|
442
668
|
for (const key of Object.keys(frame)) {
|
|
443
|
-
if (frame[key] !== layer.last[key])
|
|
669
|
+
if (layer.stale || frame[key] !== layer.last[key])
|
|
444
670
|
layer.el.style[key] = frame[key] ?? '';
|
|
445
671
|
}
|
|
672
|
+
// A property whose track was deleted is no longer in the frame: it goes, or the layer holds it forever.
|
|
673
|
+
for (const key of Object.keys(layer.last)) {
|
|
674
|
+
if (!(key in frame))
|
|
675
|
+
layer.el.style[key] = '';
|
|
676
|
+
}
|
|
446
677
|
layer.last = frame;
|
|
678
|
+
layer.stale = false;
|
|
447
679
|
}
|
|
448
680
|
}
|
|
449
681
|
}
|
|
@@ -472,5 +704,5 @@ function attachScenes(container, options = {}) {
|
|
|
472
704
|
* Generated bundle index. Do not edit.
|
|
473
705
|
*/
|
|
474
706
|
|
|
475
|
-
export { SCENE_DAMPING, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_STAGE_HEIGHT, SCENE_WORDS, SceneAttribute, SceneProp, ScrollDriver, applySceneFirstFrame, attachScenes, buildSceneRecipe, colourAt, dampToward, normalizeTracks, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneNodeAttributes, sceneScrollState, syncSceneAttributes, valueAt };
|
|
707
|
+
export { SCENE_BUDGET, SCENE_DAMPING, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_WORDS, SceneAttribute, SceneProp, ScrollDriver, applySceneFirstFrame, attachScenes, buildSceneRecipe, colourAt, dampToward, movedSceneKey, normalizeTracks, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, sceneRootOnPath, sceneScreensOf, sceneScrollState, sceneTrackDef, sceneTrackSpan, scenesIn, syncSceneAttributes, valueAt, withSceneKey, withoutSceneKey };
|
|
476
708
|
//# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectoriox-iox-ui-scene-core.mjs","sources":["../../../projects/iox-ui/src/scene-core/scene.ts","../../../projects/iox-ui/src/scene-core/scene-recipe.ts","../../../projects/iox-ui/src/scene-core/scroll-driver.ts","../../../projects/iox-ui/src/scene-core/public-api.ts","../../../projects/iox-ui/src/scene-core/vectoriox-iox-ui-scene-core.ts"],"sourcesContent":["import { SceneRole } from '@vectoriox/iox-ui/composite-core';\n\n/**\n * A Scene's data and maths (premium-sites plan §5b). A Scene is a recipe of ordinary nodes — a tall Section, a pinned\n * stage inside it, ordinary nodes as layers — so every word stays real, bound and translatable, and all three render\n * paths already draw it. What moves a layer is its OWN `sceneTracks`, never a list on the root naming layer ids: a clone\n * copies them with the layer, a delete takes them with it, and there is no id to remap.\n *\n * The vocabulary is closed. Every property is one the compositor can run without layout (CLS stays 0): a saved value\n * outside it is dropped when read, so a page document can never write CSS through a track.\n */\n\nexport enum SceneProp {\n /** Along the inline axis, in % of the stage's width. Positive runs toward the inline END (mirrored in RTL). */\n X = 'x',\n /** Down, in % of the stage's height. */\n Y = 'y',\n Scale = 'scale',\n /** Degrees. */\n Rotate = 'rotate',\n /** 0–1. */\n Opacity = 'opacity',\n /** Inset from every side, in % of the layer (0 = whole, 50 = gone). */\n Clip = 'clip',\n /** The layer's background colour. */\n Ground = 'ground',\n /** The layer's text colour. */\n Ink = 'ink',\n}\n\n/** One key: at progress `[0]` (0–1) the property holds `[1]`: a number, or a colour for Ground and Ink. */\nexport type SceneKey = readonly [number, number | string];\n\nexport interface SceneTrack {\n prop: SceneProp;\n /** Ascending by progress. Between two keys the value eases (smoothstep); outside them it holds the nearest. */\n keys: ReadonlyArray<SceneKey>;\n}\n\n/** What a node carries (both a builder node and a saved one). */\nexport interface SceneNodeSource {\n role?: string | null;\n /** How this layer moves, from the wide layout down to the phone's. */\n sceneTracks?: ReadonlyArray<SceneTrack> | null;\n /** How it moves at phone width instead (`SCENE_PHONE_MAX_WIDTH`). Absent = the same tracks. */\n scenePhoneTracks?: ReadonlyArray<SceneTrack> | null;\n}\n\n/** A frame as inline-style properties (camelCase, as `CSSStyleDeclaration` and `Object.assign` take them). */\nexport interface SceneFrame {\n transform?: string;\n opacity?: string;\n clipPath?: string;\n backgroundColor?: string;\n color?: string;\n /** A layer faded right out takes no clicks: it would sit invisibly over what is under it. `''` clears it. */\n pointerEvents?: string;\n}\n\nexport enum SceneAttribute {\n Root = 'data-iox-scene',\n Tracks = 'data-iox-tracks',\n PhoneTracks = 'data-iox-tracks-phone',\n}\n\n/** At or under this stage width a layer plays its phone tracks. The `mobile` breakpoint's width. */\nexport const SCENE_PHONE_MAX_WIDTH = 767;\n\nconst DECIMALS = 10000;\nconst round = (v: number): number => Math.round(v * DECIMALS) / DECIMALS;\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v));\nconst smoothstep = (t: number): number => t * t * (3 - 2 * t);\n\n/** A colour a track may hold: a hex, an rgb()/hsl() literal, or a design token. Anything else could break out of the\n * inline style it lands in. */\nconst COLOUR = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\\([\\d\\s.,%/]+\\)|var\\(--iox-[\\w-]+\\))$/i;\nconst COLOUR_PROPS: ReadonlySet<SceneProp> = new Set([SceneProp.Ground, SceneProp.Ink]);\nconst ALL_PROPS: ReadonlySet<string> = new Set(Object.values(SceneProp));\n\nfunction validKey(key: unknown, colour: boolean): key is SceneKey {\n if (!Array.isArray(key) || key.length !== 2) return false;\n const [p, value] = key;\n if (typeof p !== 'number' || !Number.isFinite(p) || p < 0 || p > 1) return false;\n return colour ? typeof value === 'string' && COLOUR.test(value) : typeof value === 'number' && Number.isFinite(value);\n}\n\n/**\n * The tracks a saved value really holds: unknown properties, bad keys and colours that are not colours are dropped,\n * keys sorted by progress, a track left with no key dropped. Never throws on what a page document holds.\n */\nexport function normalizeTracks(tracks: unknown): SceneTrack[] {\n if (!Array.isArray(tracks)) return [];\n const out: SceneTrack[] = [];\n for (const track of tracks) {\n const prop = (track as SceneTrack | null)?.prop;\n if (!prop || !ALL_PROPS.has(prop) || !Array.isArray((track as SceneTrack).keys)) continue;\n const keys = (track as SceneTrack).keys\n .filter(key => validKey(key, COLOUR_PROPS.has(prop)))\n .slice()\n .sort((a, b) => a[0] - b[0]);\n if (keys.length) out.push({ prop, keys });\n }\n return out;\n}\n\n/** The two keys around `p` and how far between them it eases. */\nfunction span(keys: ReadonlyArray<SceneKey>, p: number): { a: SceneKey; b: SceneKey; f: number } {\n const at = clamp01(p);\n if (at <= keys[0][0]) return { a: keys[0], b: keys[0], f: 0 };\n for (let i = 1; i < keys.length; i++) {\n if (at <= keys[i][0]) {\n const a = keys[i - 1];\n const b = keys[i];\n const width = b[0] - a[0];\n return { a, b, f: width > 0 ? smoothstep((at - a[0]) / width) : 1 };\n }\n }\n const last = keys[keys.length - 1];\n return { a: last, b: last, f: 0 };\n}\n\n/** A numeric track's value at progress `p`. */\nexport function valueAt(keys: ReadonlyArray<SceneKey>, p: number): number {\n if (!keys.length) return 0;\n const { a, b, f } = span(keys, p);\n const from = Number(a[1]);\n return round(from + (Number(b[1]) - from) * f);\n}\n\n/**\n * A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live\n * reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.\n */\nexport function colourAt(keys: ReadonlyArray<SceneKey>, p: number): string {\n if (!keys.length) return '';\n const { a, b, f } = span(keys, p);\n if (f <= 0 || a === b) return String(a[1]);\n if (f >= 1) return String(b[1]);\n return `color-mix(in oklab, ${a[1]} ${round((1 - f) * 100)}%, ${b[1]})`;\n}\n\nexport interface SceneFrameOptions {\n /** -1 when the stage reads right-to-left: the inline axis mirrors. */\n inlineSign?: 1 | -1;\n}\n\n/** What the tracks' transform-family properties rest at when a layer has no track for one. */\nconst TRANSFORM_REST: Readonly<Partial<Record<SceneProp, number>>> = { [SceneProp.X]: 0, [SceneProp.Y]: 0, [SceneProp.Scale]: 1, [SceneProp.Rotate]: 0 };\n\n/**\n * A layer's frame at progress `p`. Lengths are container-query units, so one frame is right at any width, under any\n * canvas zoom, on the server and with no measuring: the stage is the size container (`iox-design.css`).\n */\nexport function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options: SceneFrameOptions = {}): SceneFrame {\n const frame: SceneFrame = {};\n const moves: Partial<Record<SceneProp, number>> = {};\n for (const { prop, keys } of tracks) {\n if (prop in TRANSFORM_REST) moves[prop] = valueAt(keys, p);\n else if (prop === SceneProp.Opacity) {\n const opacity = clamp01(valueAt(keys, p));\n frame.opacity = String(opacity);\n frame.pointerEvents = opacity > 0 ? '' : 'none';\n }\n else if (prop === SceneProp.Clip) frame.clipPath = `inset(${Math.min(50, Math.max(0, valueAt(keys, p)))}%)`;\n else if (prop === SceneProp.Ground) frame.backgroundColor = colourAt(keys, p);\n else if (prop === SceneProp.Ink) frame.color = colourAt(keys, p);\n }\n if (Object.keys(moves).length) {\n const value = (prop: SceneProp): number => moves[prop] ?? TRANSFORM_REST[prop]!;\n const x = round(value(SceneProp.X) * (options.inlineSign ?? 1));\n frame.transform = `translate3d(${x}cqw, ${value(SceneProp.Y)}cqh, 0) rotate(${value(SceneProp.Rotate)}deg) scale(${value(SceneProp.Scale)})`;\n }\n return frame;\n}\n\nconst CSS_NAME: Readonly<Record<keyof SceneFrame, string>> = {\n transform: 'transform',\n opacity: 'opacity',\n clipPath: 'clip-path',\n backgroundColor: 'background-color',\n color: 'color',\n pointerEvents: 'pointer-events',\n};\n\n/** A frame as kebab-case style declarations, for a string renderer. */\nexport function sceneFrameDeclarations(frame: SceneFrame): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(frame)) if (value) out[CSS_NAME[key as keyof SceneFrame]] = value;\n return out;\n}\n\n/** The attributes a node's own element carries — the same decision in all three render paths. The runtime reads them,\n * so it needs no node tree and is the same on every path. Empty for any node that is no part of a Scene. */\nexport function sceneNodeAttributes(node: SceneNodeSource | null | undefined): Record<string, string> {\n const attrs: Record<string, string> = {};\n if (node?.role === SceneRole.Scene) attrs[SceneAttribute.Root] = '';\n const tracks = normalizeTracks(node?.sceneTracks);\n const phone = normalizeTracks(node?.scenePhoneTracks);\n if (tracks.length) attrs[SceneAttribute.Tracks] = JSON.stringify(tracks);\n if (phone.length) attrs[SceneAttribute.PhoneTracks] = JSON.stringify(phone);\n return attrs;\n}\n\n/** The frame a layer ships in from the server: where it stands before anyone has scrolled. Without it the page would\n * paint every layer at once, and then jump when the script arrives. */\nexport function sceneFirstFrame(node: SceneNodeSource | null | undefined): SceneFrame {\n return sceneFrame(normalizeTracks(node?.sceneTracks), 0);\n}\n\n/**\n * Make an element carry its node's Scene attributes: the live sync on the canvas and the component path's stamp.\n * Removes stale ones, touches nothing else.\n */\nexport function syncSceneAttributes(el: HTMLElement | null | undefined, node: SceneNodeSource | null | undefined): void {\n if (!el?.setAttribute) return;\n const attrs = sceneNodeAttributes(node);\n for (const name of Object.values(SceneAttribute)) {\n if (name in attrs) el.setAttribute(name, attrs[name]);\n else el.removeAttribute(name);\n }\n}\n\n/** Stamp a layer's first frame on its element (the component path, on the server too). */\nexport function applySceneFirstFrame(el: HTMLElement | null | undefined, node: SceneNodeSource | null | undefined): void {\n if (!el?.style) return;\n for (const [name, value] of Object.entries(sceneFrameDeclarations(sceneFirstFrame(node)))) el.style.setProperty(name, value);\n}\n\n/**\n * Where nothing will drive it (reduced motion, no script) a Scene is ordinary content: it flows, every layer in its\n * place and in its own look, every word readable. `!important` because it must beat a node's compiled height and\n * position, and the inline first frame. The engine wraps it in a reduced-motion query and in `<noscript>`.\n */\nexport const SCENE_FLOW_RULES = `.iox-role-scene{height:auto!important}`\n + `.iox-role-scene-stage{position:relative!important;top:auto!important;height:auto!important;overflow:visible!important;container-type:normal!important}`\n + `[${SceneAttribute.Tracks}]{transform:none!important;opacity:1!important;clip-path:none!important;pointer-events:auto!important}`;\n\n/** Under reduced motion the driver never starts, so the same rules hold for the whole visit. */\nexport const SCENE_REDUCED_MOTION_CSS = `@media (prefers-reduced-motion: reduce){${SCENE_FLOW_RULES}}`;\n","import { CompositeNode, CompositeNodeFactory, makeCompositePart, NO_ELEMENT_STYLE, SceneRole, writeLayerStyles, writeStyles } from '@vectoriox/iox-ui/composite-core';\n\nimport { SceneNodeSource, SceneProp, SceneTrack } from './scene';\n\n/**\n * The SCENE recipe: ordinary nodes, no new type, so all three render paths and every panel already know it.\n *\n * Section role scene height = how long it plays (× the viewport)\n * └─ Container role scene.stage pinned, one viewport tall, clips its layers, the size container for their lengths\n * ├─ Heading a layer with its own tracks\n * └─ Text a layer with its own tracks\n *\n * How long it plays IS the root's height, so it follows the width system the way every other size does. The stage is a\n * track-carrying layer too: its Ground is the colour the whole Scene moves through.\n */\n\nexport type SceneLayerNode = CompositeNode & SceneNodeSource;\n\nexport interface SceneWords {\n title: string;\n line: string;\n}\n\n/** Generic words a fresh Scene starts with: the author's to replace. */\nexport const SCENE_WORDS: Readonly<SceneWords> = {\n title: 'One idea, held still',\n line: 'The page keeps moving. This stays until you have read it.',\n};\n\n/** How long a fresh Scene plays: 4 viewports wide, 3 on a phone (a thumb travels less). */\nexport const SCENE_LENGTH = '400vh';\nexport const SCENE_PHONE_LENGTH = '300vh';\n/** Small viewport height: a phone's toolbar never pushes the stage's bottom out of sight. */\nexport const SCENE_STAGE_HEIGHT = '100svh';\nconst PHONE_BREAKPOINT = 'mobile';\nconst TITLE_LEVEL = 'h2';\n\nenum Type {\n Section = 'Section',\n Container = 'Container',\n Heading = 'Heading',\n Text = 'Text',\n}\n\nconst ROOT_LAYOUT: Readonly<Record<string, string>> = {\n position: 'relative',\n display: 'block',\n width: '100%',\n height: SCENE_LENGTH,\n};\n\nconst STAGE_LAYOUT: Readonly<Record<string, string>> = {\n position: 'sticky',\n top: '0px',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: SCENE_STAGE_HEIGHT,\n overflow: 'hidden',\n};\n\nconst TITLE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Opacity, keys: [[0, 0], [0.2, 1], [0.75, 1], [1, 0]] },\n { prop: SceneProp.Y, keys: [[0, 8], [0.2, 0], [1, -6]] },\n { prop: SceneProp.Scale, keys: [[0, 0.96], [0.6, 1], [1, 1.04]] },\n];\n\nconst LINE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Opacity, keys: [[0.25, 0], [0.45, 1], [0.8, 1], [1, 0]] },\n { prop: SceneProp.Y, keys: [[0.25, 6], [0.45, 0], [1, -4]] },\n];\n\nconst STAGE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Ground, keys: [[0, 'var(--iox-surface-2)'], [0.6, 'var(--iox-page-bg)']] },\n];\n\nconst copyTracks = (tracks: ReadonlyArray<SceneTrack>): SceneTrack[] => tracks.map(t => ({ prop: t.prop, keys: t.keys.map(k => [k[0], k[1]] as const) }));\n\n/** A fresh Scene: it already moves, so the author sees what the thing is before touching it. */\nexport function buildSceneRecipe(create: CompositeNodeFactory, words: Partial<SceneWords> = {}): SceneLayerNode {\n const text = { ...SCENE_WORDS, ...words };\n const root = makeCompositePart(create, { key: 'root', type: Type.Section, elementStyle: NO_ELEMENT_STYLE }, SceneRole.Scene, 'Scene', ROOT_LAYOUT) as SceneLayerNode;\n writeLayerStyles(root, PHONE_BREAKPOINT, { height: SCENE_PHONE_LENGTH });\n\n const stage = makeCompositePart(create, { key: 'stage', type: Type.Container, elementStyle: NO_ELEMENT_STYLE }, SceneRole.Stage, 'Stage', STAGE_LAYOUT) as SceneLayerNode;\n stage.sceneTracks = copyTracks(STAGE_TRACKS);\n\n const title = makeCompositePart(create, { key: 'title', type: Type.Heading, props: { content: text.title, level: TITLE_LEVEL } }, null, 'Title') as SceneLayerNode;\n title.sceneTracks = copyTracks(TITLE_TRACKS);\n writeStyles(title, { textAlign: 'center' });\n\n const line = makeCompositePart(create, { key: 'line', type: Type.Text, props: { content: text.line, tag: 'p' } }, null, 'Line') as SceneLayerNode;\n line.sceneTracks = copyTracks(LINE_TRACKS);\n writeStyles(line, { textAlign: 'center' });\n\n stage.children = [title, line];\n root.children = [stage];\n return root;\n}\n","import { SceneRole } from '@vectoriox/iox-ui/composite-core';\n\nimport { normalizeTracks, SCENE_PHONE_MAX_WIDTH, SceneAttribute, sceneFrame, SceneFrame, SceneTrack } from './scene';\n\n/**\n * The ONE scroll loop (premium-sites plan §5b, SC0). Every Scene on a page reads one progress value from it, on the\n * canvas and on the live site alike. It reads where the root is and nothing else, so it has one code path: under the\n * canvas's zoom the same rectangle divides by the same zoom, and the answer is the same at any scale.\n *\n * - The value is DAMPED: the scroll stops and the page settles a moment later. This is much of the prototype's weight,\n * and why this is not a CSS scroll timeline, which cannot do it.\n * - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,\n * its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.\n * `translate`, not `transform`: a Stage may carry tracks of its own.\n * - It sleeps. No frame is asked for unless something moved, so a page holding a settled Scene costs nothing.\n * - Reads come first in a frame and writes after, and a write only ever touches compositor properties.\n */\n\nexport const SCENE_DAMPING = 9;\nconst SETTLED = 0.0005;\nconst MAX_FRAME_SECONDS = 0.1;\n/** The first frame after a sleep has no previous one to measure from: it counts as one frame, or a scroll would lose it. */\nconst WAKING_FRAME_SECONDS = 1 / 60;\nconst STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\\./g, '-')}`;\nconst TRANSFORM_WILL_CHANGE = 'transform, opacity';\n\n/** One frame of the damping: frame-rate independent, so 60 Hz and 120 Hz settle in the same time. */\nexport function dampToward(current: number, target: number, seconds: number, rate: number = SCENE_DAMPING): number {\n return current + (target - current) * (1 - Math.exp(-seconds * rate));\n}\n\n/** Where a root stands: scrolled `local` page px into its `travel`. `zoom` undoes the canvas's scale. */\nexport function sceneScrollState(rootTop: number, originTop: number, zoom: number, travel: number): { local: number; progress: number } {\n if (travel <= 0) return { local: 0, progress: 0 };\n const local = Math.min(travel, Math.max(0, -(rootTop - originTop) / (zoom || 1)));\n return { local, progress: local / travel };\n}\n\nexport interface ScrollDriverOptions {\n /** Hold the stage with `translate` (the canvas). The live site's stage is sticky and needs nothing. */\n pin?: boolean;\n /** The element a root scrolls under, when that is not the window (the canvas's frame, Preview's page). */\n originOf?: (root: HTMLElement) => HTMLElement | null;\n /** Follow what changes inside a root: tracks edited, layers added (the canvas). */\n observe?: boolean;\n damping?: number;\n /** The window, for a test. */\n host?: Window;\n}\n\ninterface Layer {\n el: HTMLElement;\n tracks: SceneTrack[];\n phoneTracks: SceneTrack[];\n last: SceneFrame;\n}\n\ninterface Scene {\n root: HTMLElement;\n stage: HTMLElement | null;\n layers: Layer[];\n progress: number;\n /** Page px and the stage's own width, measured when something resizes and never per frame. */\n height: number;\n travel: number;\n phone: boolean;\n inlineSign: 1 | -1;\n /** No frame written yet: the first one lands exactly where the scroll is, with no glide. */\n fresh: boolean;\n mutations: MutationObserver | null;\n}\n\nfunction parseTracks(raw: string | null): SceneTrack[] {\n if (!raw) return [];\n try { return normalizeTracks(JSON.parse(raw)); } catch { return []; }\n}\n\nexport class ScrollDriver {\n private readonly scenes = new Map<HTMLElement, Scene>();\n private readonly host: Window;\n private readonly resize: ResizeObserver | null;\n private frame = 0;\n private lastTime = 0;\n private readonly wakeUp = (): void => this.wake();\n\n constructor(private readonly options: ScrollDriverOptions = {}) {\n this.host = options.host ?? window;\n // In capture: a scroll does not bubble, and the canvas's Lenis scrolls an element, not the window.\n this.host.addEventListener('scroll', this.wakeUp, { capture: true, passive: true });\n this.host.addEventListener('resize', this.wakeUp, { passive: true });\n const Observer = (this.host as Window & { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;\n this.resize = Observer ? new Observer(() => this.remeasureAll()) : null;\n }\n\n /** Drive a Scene's root. Idempotent: adding a root again re-reads it. */\n add(root: HTMLElement): void {\n this.remove(root);\n const scene: Scene = { root, stage: null, layers: [], progress: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };\n this.scenes.set(root, scene);\n this.resize?.observe(root);\n if (this.options.observe) {\n const Observer = (this.host as Window & { MutationObserver?: typeof MutationObserver }).MutationObserver;\n if (Observer) {\n scene.mutations = new Observer(() => this.reread(scene));\n scene.mutations.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: [SceneAttribute.Tracks, SceneAttribute.PhoneTracks] });\n }\n }\n this.reread(scene);\n }\n\n remove(root: HTMLElement): void {\n const scene = this.scenes.get(root);\n if (!scene) return;\n scene.mutations?.disconnect();\n this.resize?.unobserve(root);\n if (scene.stage) scene.stage.style.removeProperty('translate');\n for (const layer of scene.layers) layer.el.style.removeProperty('will-change');\n this.scenes.delete(root);\n }\n\n /** The damped progress a root's layers stand at. */\n progressOf(root: HTMLElement): number | null {\n return this.scenes.get(root)?.progress ?? null;\n }\n\n /** Something moved that no scroll or resize announces (the canvas's zoom). */\n wake(): void {\n if (this.frame) return;\n this.frame = this.host.requestAnimationFrame(this.tick);\n }\n\n destroy(): void {\n if (this.frame) this.host.cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.host.removeEventListener('scroll', this.wakeUp, { capture: true });\n this.host.removeEventListener('resize', this.wakeUp);\n for (const root of [...this.scenes.keys()]) this.remove(root);\n this.resize?.disconnect();\n }\n\n /** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */\n private reread(scene: Scene): void {\n scene.stage = scene.root.querySelector<HTMLElement>(STAGE_SELECTOR);\n scene.layers = Array.from(scene.root.querySelectorAll<HTMLElement>(`[${SceneAttribute.Tracks}], [${SceneAttribute.PhoneTracks}]`))\n .filter(el => el === scene.root || el.parentElement?.closest(`[${SceneAttribute.Root}]`) === scene.root)\n .map(el => this.readLayer(el, scene));\n this.measure(scene);\n scene.fresh = true;\n this.wake();\n }\n\n private readLayer(el: HTMLElement, scene: Scene): Layer {\n const previous = scene.layers.find(layer => layer.el === el);\n el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);\n return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {} };\n }\n\n private remeasureAll(): void {\n for (const scene of this.scenes.values()) this.measure(scene);\n this.wake();\n }\n\n private measure(scene: Scene): void {\n scene.height = scene.root.offsetHeight;\n scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));\n scene.phone = (scene.stage?.offsetWidth ?? Infinity) <= SCENE_PHONE_MAX_WIDTH;\n scene.inlineSign = scene.stage && this.host.getComputedStyle(scene.stage).direction === 'rtl' ? -1 : 1;\n for (const layer of scene.layers) layer.last = {};\n }\n\n private readonly tick = (now: number): void => {\n this.frame = 0;\n const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;\n this.lastTime = now;\n const reads = [...this.scenes.values()].map(scene => this.read(scene));\n let moving = false;\n for (const { scene, local, target } of reads) {\n if (this.options.pin && scene.stage) scene.stage.style.setProperty('translate', `0 ${local}px`);\n const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);\n const settled = Math.abs(next - target) < SETTLED;\n scene.progress = settled ? target : next;\n scene.fresh = false;\n this.write(scene);\n moving = moving || !settled;\n }\n if (moving) this.wake();\n else this.lastTime = 0;\n };\n\n private read(scene: Scene): { scene: Scene; local: number; target: number } {\n const rect = scene.root.getBoundingClientRect();\n const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;\n const zoom = scene.height ? rect.height / scene.height : 1;\n const { local, progress } = sceneScrollState(rect.top, origin, zoom, scene.travel);\n return { scene, local, target: progress };\n }\n\n private write(scene: Scene): void {\n for (const layer of scene.layers) {\n const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;\n const frame = sceneFrame(tracks, scene.progress, { inlineSign: scene.inlineSign });\n for (const key of Object.keys(frame) as (keyof SceneFrame)[]) {\n if (frame[key] !== layer.last[key]) layer.el.style[key] = frame[key] ?? '';\n }\n layer.last = frame;\n }\n }\n}\n\n/** A page's Scenes, driven by one driver; null when it holds none, or when the visitor asked for less motion (the\n * page's own CSS then lets each Scene flow). The live site's door. */\nexport function attachScenes(container: HTMLElement, options: ScrollDriverOptions = {}): ScrollDriver | null {\n const roots = container.querySelectorAll<HTMLElement>(`[${SceneAttribute.Root}]`);\n if (!roots.length) return null;\n const host = options.host ?? window;\n if (host.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return null;\n const driver = new ScrollDriver(options);\n roots.forEach(root => driver.add(root));\n return driver;\n}\n","/**\n * @vectoriox/iox-ui/scene-core — a Scene: a stage that holds still while the page scrolls past it, its layers moving on\n * ONE progress value (premium-sites plan §5b). FRAMEWORK-FREE: the builder canvas, both engine paths and (from SC6) the\n * composer read the same tracks, frames and recipe; the driver is DOM-only and is the ONE scroll loop.\n * ⚠️ Consumers wire the usual trio — ng-package raw-ts assets, jest moduleNameMapper, tsconfig paths.\n */\nexport * from './scene';\nexport * from './scene-recipe';\nexport * from './scroll-driver';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;IAES;AAAZ,CAAA,UAAY,SAAS,EAAA;;AAEjB,IAAA,SAAA,CAAA,GAAA,CAAA,GAAA,GAAO;;AAEP,IAAA,SAAA,CAAA,GAAA,CAAA,GAAA,GAAO;AACP,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;;AAEf,IAAA,SAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;;AAE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I,CAAC,CAAC;AACvC,IAAA,OAAO,MAAM;AACjB;;AC3NA;;;;;AAKG;;ACLH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"vectoriox-iox-ui-scene-core.mjs","sources":["../../../projects/iox-ui/src/scene-core/scene.ts","../../../projects/iox-ui/src/scene-core/scene-edit.ts","../../../projects/iox-ui/src/scene-core/scene-recipe.ts","../../../projects/iox-ui/src/scene-core/scroll-driver.ts","../../../projects/iox-ui/src/scene-core/public-api.ts","../../../projects/iox-ui/src/scene-core/vectoriox-iox-ui-scene-core.ts"],"sourcesContent":["import { SceneRole } from '@vectoriox/iox-ui/composite-core';\n\n/**\n * A Scene's data and maths (premium-sites plan §5b). A Scene is a recipe of ordinary nodes — a tall Section, a pinned\n * stage inside it, ordinary nodes as layers — so every word stays real, bound and translatable, and all three render\n * paths already draw it. What moves a layer is its OWN `sceneTracks`, never a list on the root naming layer ids: a clone\n * copies them with the layer, a delete takes them with it, and there is no id to remap.\n *\n * The vocabulary is closed. Every property is one the compositor can run without layout (CLS stays 0): a saved value\n * outside it is dropped when read, so a page document can never write CSS through a track.\n */\n\nexport enum SceneProp {\n /** Along the inline axis, in % of the stage's width. Positive runs toward the inline END (mirrored in RTL). */\n X = 'x',\n /** Down, in % of the stage's height. */\n Y = 'y',\n Scale = 'scale',\n /** Degrees. */\n Rotate = 'rotate',\n /** 0–1. */\n Opacity = 'opacity',\n /** Inset from every side, in % of the layer (0 = whole, 50 = gone). */\n Clip = 'clip',\n /** The layer's background colour. */\n Ground = 'ground',\n /** The layer's text colour. */\n Ink = 'ink',\n}\n\n/** One key: at progress `[0]` (0–1) the property holds `[1]`: a number, or a colour for Ground and Ink. */\nexport type SceneKey = readonly [number, number | string];\n\nexport interface SceneTrack {\n prop: SceneProp;\n /** Ascending by progress. Between two keys the value eases (smoothstep); outside them it holds the nearest. */\n keys: ReadonlyArray<SceneKey>;\n}\n\n/** What a node carries (both a builder node and a saved one). */\nexport interface SceneNodeSource {\n role?: string | null;\n /** How this layer moves, from the wide layout down to the phone's. */\n sceneTracks?: ReadonlyArray<SceneTrack> | null;\n /** How it moves at phone width instead (`SCENE_PHONE_MAX_WIDTH`). Absent = the same tracks. */\n scenePhoneTracks?: ReadonlyArray<SceneTrack> | null;\n}\n\n/** A frame as inline-style properties (camelCase, as `CSSStyleDeclaration` and `Object.assign` take them). */\nexport interface SceneFrame {\n transform?: string;\n opacity?: string;\n clipPath?: string;\n backgroundColor?: string;\n color?: string;\n /** A layer faded right out takes no clicks: it would sit invisibly over what is under it. `''` clears it. */\n pointerEvents?: string;\n}\n\nexport enum SceneAttribute {\n Root = 'data-iox-scene',\n Tracks = 'data-iox-tracks',\n PhoneTracks = 'data-iox-tracks-phone',\n}\n\n/** At or under this stage width a layer plays its phone tracks. The `mobile` breakpoint's width. */\nexport const SCENE_PHONE_MAX_WIDTH = 767;\n\nconst DECIMALS = 10000;\nconst round = (v: number): number => Math.round(v * DECIMALS) / DECIMALS;\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v));\nconst smoothstep = (t: number): number => t * t * (3 - 2 * t);\n\n/** A colour a track may hold: a hex, an rgb()/hsl() literal, or a design token. Anything else could break out of the\n * inline style it lands in. */\nconst COLOUR = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\\([\\d\\s.,%/]+\\)|var\\(--iox-[\\w-]+\\))$/i;\nconst COLOUR_PROPS: ReadonlySet<SceneProp> = new Set([SceneProp.Ground, SceneProp.Ink]);\nconst ALL_PROPS: ReadonlySet<string> = new Set(Object.values(SceneProp));\n\nfunction validKey(key: unknown, colour: boolean): key is SceneKey {\n if (!Array.isArray(key) || key.length !== 2) return false;\n const [p, value] = key;\n if (typeof p !== 'number' || !Number.isFinite(p) || p < 0 || p > 1) return false;\n return colour ? typeof value === 'string' && COLOUR.test(value) : typeof value === 'number' && Number.isFinite(value);\n}\n\n/**\n * The tracks a saved value really holds: unknown properties, bad keys and colours that are not colours are dropped,\n * keys sorted by progress, a track left with no key dropped. Never throws on what a page document holds.\n */\nexport function normalizeTracks(tracks: unknown): SceneTrack[] {\n if (!Array.isArray(tracks)) return [];\n const out: SceneTrack[] = [];\n for (const track of tracks) {\n const prop = (track as SceneTrack | null)?.prop;\n if (!prop || !ALL_PROPS.has(prop) || !Array.isArray((track as SceneTrack).keys)) continue;\n const keys = (track as SceneTrack).keys\n .filter(key => validKey(key, COLOUR_PROPS.has(prop)))\n .slice()\n .sort((a, b) => a[0] - b[0]);\n if (keys.length) out.push({ prop, keys });\n }\n return out;\n}\n\n/** The two keys around `p` and how far between them it eases. */\nfunction span(keys: ReadonlyArray<SceneKey>, p: number): { a: SceneKey; b: SceneKey; f: number } {\n const at = clamp01(p);\n if (at <= keys[0][0]) return { a: keys[0], b: keys[0], f: 0 };\n for (let i = 1; i < keys.length; i++) {\n if (at <= keys[i][0]) {\n const a = keys[i - 1];\n const b = keys[i];\n const width = b[0] - a[0];\n return { a, b, f: width > 0 ? smoothstep((at - a[0]) / width) : 1 };\n }\n }\n const last = keys[keys.length - 1];\n return { a: last, b: last, f: 0 };\n}\n\n/** A numeric track's value at progress `p`. */\nexport function valueAt(keys: ReadonlyArray<SceneKey>, p: number): number {\n if (!keys.length) return 0;\n const { a, b, f } = span(keys, p);\n const from = Number(a[1]);\n return round(from + (Number(b[1]) - from) * f);\n}\n\n/**\n * A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live\n * reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.\n */\nexport function colourAt(keys: ReadonlyArray<SceneKey>, p: number): string {\n if (!keys.length) return '';\n const { a, b, f } = span(keys, p);\n if (f <= 0 || a === b) return String(a[1]);\n if (f >= 1) return String(b[1]);\n return `color-mix(in oklab, ${a[1]} ${round((1 - f) * 100)}%, ${b[1]})`;\n}\n\nexport interface SceneFrameOptions {\n /** -1 when the stage reads right-to-left: the inline axis mirrors. */\n inlineSign?: 1 | -1;\n}\n\n/** What the tracks' transform-family properties rest at when a layer has no track for one. */\nconst TRANSFORM_REST: Readonly<Partial<Record<SceneProp, number>>> = { [SceneProp.X]: 0, [SceneProp.Y]: 0, [SceneProp.Scale]: 1, [SceneProp.Rotate]: 0 };\n\n/**\n * A layer's frame at progress `p`. Lengths are container-query units, so one frame is right at any width, under any\n * canvas zoom, on the server and with no measuring: the stage is the size container (`iox-design.css`).\n */\nexport function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options: SceneFrameOptions = {}): SceneFrame {\n const frame: SceneFrame = {};\n const moves: Partial<Record<SceneProp, number>> = {};\n for (const { prop, keys } of tracks) {\n if (prop in TRANSFORM_REST) moves[prop] = valueAt(keys, p);\n else if (prop === SceneProp.Opacity) {\n const opacity = clamp01(valueAt(keys, p));\n frame.opacity = String(opacity);\n frame.pointerEvents = opacity > 0 ? '' : 'none';\n }\n else if (prop === SceneProp.Clip) frame.clipPath = `inset(${Math.min(50, Math.max(0, valueAt(keys, p)))}%)`;\n else if (prop === SceneProp.Ground) frame.backgroundColor = colourAt(keys, p);\n else if (prop === SceneProp.Ink) frame.color = colourAt(keys, p);\n }\n if (Object.keys(moves).length) {\n const value = (prop: SceneProp): number => moves[prop] ?? TRANSFORM_REST[prop]!;\n const x = round(value(SceneProp.X) * (options.inlineSign ?? 1));\n frame.transform = `translate3d(${x}cqw, ${value(SceneProp.Y)}cqh, 0) rotate(${value(SceneProp.Rotate)}deg) scale(${value(SceneProp.Scale)})`;\n }\n return frame;\n}\n\nconst CSS_NAME: Readonly<Record<keyof SceneFrame, string>> = {\n transform: 'transform',\n opacity: 'opacity',\n clipPath: 'clip-path',\n backgroundColor: 'background-color',\n color: 'color',\n pointerEvents: 'pointer-events',\n};\n\n/** A frame as kebab-case style declarations, for a string renderer. */\nexport function sceneFrameDeclarations(frame: SceneFrame): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(frame)) if (value) out[CSS_NAME[key as keyof SceneFrame]] = value;\n return out;\n}\n\n/** The attributes a node's own element carries — the same decision in all three render paths. The runtime reads them,\n * so it needs no node tree and is the same on every path. Empty for any node that is no part of a Scene. */\nexport function sceneNodeAttributes(node: SceneNodeSource | null | undefined): Record<string, string> {\n const attrs: Record<string, string> = {};\n if (node?.role === SceneRole.Scene) attrs[SceneAttribute.Root] = '';\n const tracks = normalizeTracks(node?.sceneTracks);\n const phone = normalizeTracks(node?.scenePhoneTracks);\n if (tracks.length) attrs[SceneAttribute.Tracks] = JSON.stringify(tracks);\n if (phone.length) attrs[SceneAttribute.PhoneTracks] = JSON.stringify(phone);\n return attrs;\n}\n\n/** The frame a layer ships in from the server: where it stands before anyone has scrolled. Without it the page would\n * paint every layer at once, and then jump when the script arrives. */\nexport function sceneFirstFrame(node: SceneNodeSource | null | undefined): SceneFrame {\n return sceneFrame(normalizeTracks(node?.sceneTracks), 0);\n}\n\n/**\n * Make an element carry its node's Scene attributes: the live sync on the canvas and the component path's stamp.\n * Removes stale ones, touches nothing else.\n */\nexport function syncSceneAttributes(el: HTMLElement | null | undefined, node: SceneNodeSource | null | undefined): void {\n if (!el?.setAttribute) return;\n const attrs = sceneNodeAttributes(node);\n for (const name of Object.values(SceneAttribute)) {\n if (name in attrs) el.setAttribute(name, attrs[name]);\n else el.removeAttribute(name);\n }\n}\n\n/** Stamp a layer's first frame on its element (the component path, on the server too). */\nexport function applySceneFirstFrame(el: HTMLElement | null | undefined, node: SceneNodeSource | null | undefined): void {\n if (!el?.style) return;\n for (const [name, value] of Object.entries(sceneFrameDeclarations(sceneFirstFrame(node)))) el.style.setProperty(name, value);\n}\n\n/**\n * Where nothing will drive it (reduced motion, no script) a Scene is ordinary content: it flows, every layer in its\n * place and in its own look, every word readable. `!important` because it must beat a node's compiled height and\n * position, and the inline first frame. The engine wraps it in a reduced-motion query and in `<noscript>`.\n */\nexport const SCENE_FLOW_RULES = `.iox-role-scene{height:auto!important}`\n + `.iox-role-scene-stage{position:relative!important;top:auto!important;height:auto!important;overflow:visible!important;container-type:normal!important}`\n + `[${SceneAttribute.Tracks}]{transform:none!important;opacity:1!important;clip-path:none!important;pointer-events:auto!important}`;\n\n/** Under reduced motion the driver never starts, so the same rules hold for the whole visit. */\nexport const SCENE_REDUCED_MOTION_CSS = `@media (prefers-reduced-motion: reduce){${SCENE_FLOW_RULES}}`;\n","import { SceneRole } from '@vectoriox/iox-ui/composite-core';\n\nimport { normalizeTracks, SceneKey, SceneNodeSource, SceneProp, SceneTrack, valueAt } from './scene';\n\n/**\n * Authoring a Scene (premium-sites plan §5b, SC2): the decisions the builder's timeline and its panel share, so neither\n * holds a second copy of what a key is. Pure, and every edit returns NEW tracks: the caller assigns them to the node, so\n * undo's snapshot and the attribute the driver reads can never see a half-made edit.\n *\n * One rule to author by: one key holds, two keys move. A value edited at a scroll position sets a key there, so a layer\n * is animated by scrolling to a moment and saying where it stands at that moment.\n */\n\n/** Keys sit on whole percents of the scroll: finer than anyone can place by hand, and two keys never nearly coincide. */\nconst KEY_GRID = 100;\n\nexport function sceneKeyPosition(p: number): number {\n return Math.round(Math.min(1, Math.max(0, p)) * KEY_GRID) / KEY_GRID;\n}\n\nexport interface SceneTrackDef {\n prop: SceneProp;\n /** Ground and Ink hold colours; everything else holds a number. */\n colour: boolean;\n /** What a layer with no track for this property stands at, in stored units. */\n rest: number;\n /** The bounds and the step, in the units the author sees. */\n min: number;\n max: number;\n step: number;\n /** Author's units per stored unit: scale 1.2 reads 120 %, opacity 0.5 reads 50 %. */\n factor: number;\n unit: string;\n}\n\nconst PERCENT = '%';\nconst DEGREES = '°';\n\n/** The closed vocabulary, in the order the panel lists it. */\nexport const SCENE_TRACK_DEFS: ReadonlyArray<SceneTrackDef> = [\n { prop: SceneProp.X, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },\n { prop: SceneProp.Y, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },\n { prop: SceneProp.Scale, colour: false, rest: 1, min: 0, max: 2000, step: 1, factor: 100, unit: PERCENT },\n { prop: SceneProp.Rotate, colour: false, rest: 0, min: -720, max: 720, step: 1, factor: 1, unit: DEGREES },\n { prop: SceneProp.Opacity, colour: false, rest: 1, min: 0, max: 100, step: 1, factor: 100, unit: PERCENT },\n { prop: SceneProp.Clip, colour: false, rest: 0, min: 0, max: 50, step: 1, factor: 1, unit: PERCENT },\n { prop: SceneProp.Ground, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },\n { prop: SceneProp.Ink, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },\n];\n\nconst DEF_BY_PROP = new Map(SCENE_TRACK_DEFS.map(def => [def.prop, def]));\n\nexport function sceneTrackDef(prop: SceneProp): SceneTrackDef {\n return DEF_BY_PROP.get(prop)!;\n}\n\nconst trackOf = (tracks: ReadonlyArray<SceneTrack>, prop: SceneProp): SceneTrack | undefined => tracks.find(t => t.prop === prop);\nconst samePosition = (a: number, b: number): boolean => sceneKeyPosition(a) === sceneKeyPosition(b);\nconst roundTo = (value: number, places = 4): number => Number(value.toFixed(places));\n\n/** A number track's value at `p` in the author's units, or where the layer rests when it has no such track. */\nexport function sceneDisplayValue(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): number {\n const def = sceneTrackDef(prop);\n const track = trackOf(tracks, prop);\n return roundTo((track ? valueAt(track.keys, p) : def.rest) * def.factor, 2);\n}\n\n/**\n * The colour to show for a colour track at `p`: the key at or before it, else the first. Between two keys the live value\n * is a mix, which is no value a colour control can edit; the author sets keys, so the panel shows a key.\n */\nexport function sceneColourKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): string {\n const keys = trackOf(tracks, prop)?.keys;\n if (!keys?.length) return '';\n let held = keys[0];\n for (const key of keys) if (key[0] <= sceneKeyPosition(p)) held = key;\n return String(held[1]);\n}\n\nexport function sceneHasKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): boolean {\n return !!trackOf(tracks, prop)?.keys.some(key => samePosition(key[0], p));\n}\n\nfunction storedValue(def: SceneTrackDef, value: number | string): number | string {\n if (def.colour) return value;\n return roundTo(Math.min(def.max, Math.max(def.min, Number(value))) / def.factor);\n}\n\nfunction replaceTrack(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, keys: ReadonlyArray<SceneKey>): SceneTrack[] {\n const rest = tracks.filter(t => t.prop !== prop);\n if (!keys.length) return rest;\n const at = tracks.findIndex(t => t.prop === prop);\n const next = [...rest];\n next.splice(at < 0 ? rest.length : at, 0, { prop, keys });\n return next;\n}\n\n/**\n * Set a key at `p`, in the author's units. A number is clamped to its bounds; a colour that is no colour changes nothing,\n * because `normalizeTracks` would drop it anyway and the author's other keys must survive.\n */\nexport function withSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number, value: number | string): SceneTrack[] {\n const def = sceneTrackDef(prop);\n const at = sceneKeyPosition(p);\n if (!def.colour && !Number.isFinite(Number(value))) return [...tracks];\n const key: SceneKey = [at, storedValue(def, value)];\n const others = (trackOf(tracks, prop)?.keys ?? []).filter(k => !samePosition(k[0], at));\n const keys = [...others, key].sort((a, b) => a[0] - b[0]);\n const next = replaceTrack(tracks, prop, keys);\n return trackOf(normalizeTracks(next), prop)?.keys.length === keys.length ? next : [...tracks];\n}\n\n/** Remove the key at `p`. The last key of a track takes the track with it. */\nexport function withoutSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): SceneTrack[] {\n const track = trackOf(tracks, prop);\n if (!track) return [...tracks];\n return replaceTrack(tracks, prop, track.keys.filter(key => !samePosition(key[0], p)));\n}\n\n/**\n * Move a key from `from` toward `to`, stopping one grid step short of its neighbours: keys never swap, so a drag can\n * never reverse a movement the author set. Returns where it landed, so a drag keeps following it.\n */\nexport function movedSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, from: number, to: number): { tracks: SceneTrack[]; at: number } {\n const track = trackOf(tracks, prop);\n const index = track ? track.keys.findIndex(key => samePosition(key[0], from)) : -1;\n if (!track || index < 0) return { tracks: [...tracks], at: sceneKeyPosition(from) };\n const step = 1 / KEY_GRID;\n const low = index > 0 ? track.keys[index - 1][0] + step : 0;\n const high = index < track.keys.length - 1 ? track.keys[index + 1][0] - step : 1;\n const at = sceneKeyPosition(Math.min(high, Math.max(low, to)));\n const keys = track.keys.map((key, i): SceneKey => (i === index ? [at, key[1]] : key));\n return { tracks: replaceTrack(tracks, prop, keys), at };\n}\n\n/** A track's bar on the timeline: from its first key to its last, as fractions of the scroll. */\nexport function sceneTrackSpan(track: SceneTrack): { from: number; to: number } {\n return { from: track.keys[0][0], to: track.keys[track.keys.length - 1][0] };\n}\n\n/** A node as these helpers read it: a builder node and a saved one both fit. */\nexport interface SceneTreeNode extends SceneNodeSource {\n id?: string;\n children?: ReadonlyArray<SceneTreeNode> | null;\n}\n\n/** The Scene a selection sits in: the innermost Scene on its path from the top. */\nexport function sceneRootOnPath<T extends SceneTreeNode>(path: ReadonlyArray<T>): T | null {\n for (let i = path.length - 1; i >= 0; i--) if (path[i].role === SceneRole.Scene) return path[i];\n return null;\n}\n\n/** Every Scene on a page, in document order, a Scene inside a Scene included. */\nexport function scenesIn<T extends SceneTreeNode>(nodes: ReadonlyArray<T> | null | undefined): T[] {\n const found: T[] = [];\n for (const node of nodes ?? []) {\n if (node.role === SceneRole.Scene) found.push(node);\n found.push(...scenesIn((node.children ?? []) as ReadonlyArray<T>));\n }\n return found;\n}\n\nconst hasTracks = (node: SceneTreeNode): boolean =>\n normalizeTracks(node.sceneTracks).length > 0 || normalizeTracks(node.scenePhoneTracks).length > 0;\n\n/**\n * What the timeline lists: the stage, everything standing on it, and anything deeper that carries tracks. A layer with\n * none is listed too, or it could never be given its first. A Scene inside this one keeps its own timeline.\n */\nexport function sceneLayersOf<T extends SceneTreeNode>(root: T | null | undefined): T[] {\n const stage = (root?.children ?? []).find(child => child.role === SceneRole.Stage) as T | undefined;\n if (!stage) return [];\n const layers: T[] = [stage];\n const deeper = (node: T): void => {\n for (const child of (node.children ?? []) as ReadonlyArray<T>) {\n if (child.role === SceneRole.Scene) continue;\n if (hasTracks(child)) layers.push(child);\n deeper(child);\n }\n };\n for (const child of (stage.children ?? []) as ReadonlyArray<T>) {\n if (child.role === SceneRole.Scene) continue;\n layers.push(child);\n deeper(child);\n }\n return layers;\n}\n\n/** How many screens of scrolling a Scene holds for, and the bounds the panel offers. */\nexport const SCENE_MIN_SCREENS = 0.5;\nexport const SCENE_MAX_SCREENS = 20;\n\nconst VIEWPORT_HEIGHT = /^([\\d.]+)[sdl]?vh$/;\n\n/**\n * The root's height as screens of scrolling: the stage itself takes one screen, so 400vh holds for 3. Null for a height\n * set in anything else (a hand-set px), which the panel then says it cannot express rather than overwriting it.\n */\nexport function sceneScreensOf(height: string | null | undefined): number | null {\n const match = VIEWPORT_HEIGHT.exec(String(height ?? '').trim());\n if (!match) return null;\n return Math.max(0, roundTo(Number(match[1]) / 100 - 1, 2));\n}\n\nexport function sceneHeightForScreens(screens: number): string {\n const held = Math.min(SCENE_MAX_SCREENS, Math.max(SCENE_MIN_SCREENS, screens));\n return `${roundTo((held + 1) * 100, 1)}vh`;\n}\n\n/** Motion v2 §3d's limits for scroll-linked work on one page. */\nexport const SCENE_BUDGET = { heldSections: 1, movingLayers: 8 } as const;\n\nexport interface SceneBudget {\n /** Every track on the page's Scenes. */\n tracks: number;\n heldSections: number;\n movingLayers: number;\n within: boolean;\n}\n\n/** What a page's Scenes cost. Advice to the author, never a refusal: the composer enforces it from SC6. */\nexport function sceneBudget(nodes: ReadonlyArray<SceneTreeNode> | null | undefined): SceneBudget {\n const scenes = scenesIn(nodes);\n const moving = scenes.flatMap(scene => sceneLayersOf(scene)).filter(hasTracks);\n const movingLayers = new Set(moving).size;\n const tracks = [...new Set(moving)].reduce((sum, node) => sum + normalizeTracks(node.sceneTracks).length, 0);\n return {\n tracks,\n heldSections: scenes.length,\n movingLayers,\n within: scenes.length <= SCENE_BUDGET.heldSections && movingLayers <= SCENE_BUDGET.movingLayers,\n };\n}\n","import { CompositeNode, CompositeNodeFactory, makeCompositePart, NO_ELEMENT_STYLE, SceneRole, writeLayerStyles, writeStyles } from '@vectoriox/iox-ui/composite-core';\n\nimport { SceneNodeSource, SceneProp, SceneTrack } from './scene';\n\n/**\n * The SCENE recipe: ordinary nodes, no new type, so all three render paths and every panel already know it.\n *\n * Section role scene height = how long it plays (× the viewport)\n * └─ Container role scene.stage pinned, one viewport tall, clips its layers, the size container for their lengths\n * ├─ Heading a layer with its own tracks\n * └─ Text a layer with its own tracks\n *\n * How long it plays IS the root's height, so it follows the width system the way every other size does. The stage is a\n * track-carrying layer too: its Ground is the colour the whole Scene moves through.\n */\n\nexport type SceneLayerNode = CompositeNode & SceneNodeSource;\n\nexport interface SceneWords {\n title: string;\n line: string;\n}\n\n/** Generic words a fresh Scene starts with: the author's to replace. */\nexport const SCENE_WORDS: Readonly<SceneWords> = {\n title: 'One idea, held still',\n line: 'The page keeps moving. This stays until you have read it.',\n};\n\n/** How long a fresh Scene plays: 4 viewports wide, 3 on a phone (a thumb travels less). */\nexport const SCENE_LENGTH = '400vh';\nexport const SCENE_PHONE_LENGTH = '300vh';\n/** Small viewport height: a phone's toolbar never pushes the stage's bottom out of sight. */\nexport const SCENE_STAGE_HEIGHT = '100svh';\nconst PHONE_BREAKPOINT = 'mobile';\nconst TITLE_LEVEL = 'h2';\n\nenum Type {\n Section = 'Section',\n Container = 'Container',\n Heading = 'Heading',\n Text = 'Text',\n}\n\nconst ROOT_LAYOUT: Readonly<Record<string, string>> = {\n position: 'relative',\n display: 'block',\n width: '100%',\n height: SCENE_LENGTH,\n};\n\nconst STAGE_LAYOUT: Readonly<Record<string, string>> = {\n position: 'sticky',\n top: '0px',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: SCENE_STAGE_HEIGHT,\n overflow: 'hidden',\n};\n\nconst TITLE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Opacity, keys: [[0, 0], [0.2, 1], [0.75, 1], [1, 0]] },\n { prop: SceneProp.Y, keys: [[0, 8], [0.2, 0], [1, -6]] },\n { prop: SceneProp.Scale, keys: [[0, 0.96], [0.6, 1], [1, 1.04]] },\n];\n\nconst LINE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Opacity, keys: [[0.25, 0], [0.45, 1], [0.8, 1], [1, 0]] },\n { prop: SceneProp.Y, keys: [[0.25, 6], [0.45, 0], [1, -4]] },\n];\n\nconst STAGE_TRACKS: ReadonlyArray<SceneTrack> = [\n { prop: SceneProp.Ground, keys: [[0, 'var(--iox-surface-2)'], [0.6, 'var(--iox-page-bg)']] },\n];\n\nconst copyTracks = (tracks: ReadonlyArray<SceneTrack>): SceneTrack[] => tracks.map(t => ({ prop: t.prop, keys: t.keys.map(k => [k[0], k[1]] as const) }));\n\n/** A fresh Scene: it already moves, so the author sees what the thing is before touching it. */\nexport function buildSceneRecipe(create: CompositeNodeFactory, words: Partial<SceneWords> = {}): SceneLayerNode {\n const text = { ...SCENE_WORDS, ...words };\n const root = makeCompositePart(create, { key: 'root', type: Type.Section, elementStyle: NO_ELEMENT_STYLE }, SceneRole.Scene, 'Scene', ROOT_LAYOUT) as SceneLayerNode;\n writeLayerStyles(root, PHONE_BREAKPOINT, { height: SCENE_PHONE_LENGTH });\n\n const stage = makeCompositePart(create, { key: 'stage', type: Type.Container, elementStyle: NO_ELEMENT_STYLE }, SceneRole.Stage, 'Stage', STAGE_LAYOUT) as SceneLayerNode;\n stage.sceneTracks = copyTracks(STAGE_TRACKS);\n\n const title = makeCompositePart(create, { key: 'title', type: Type.Heading, props: { content: text.title, level: TITLE_LEVEL } }, null, 'Title') as SceneLayerNode;\n title.sceneTracks = copyTracks(TITLE_TRACKS);\n writeStyles(title, { textAlign: 'center' });\n\n const line = makeCompositePart(create, { key: 'line', type: Type.Text, props: { content: text.line, tag: 'p' } }, null, 'Line') as SceneLayerNode;\n line.sceneTracks = copyTracks(LINE_TRACKS);\n writeStyles(line, { textAlign: 'center' });\n\n stage.children = [title, line];\n root.children = [stage];\n return root;\n}\n","import { SceneRole } from '@vectoriox/iox-ui/composite-core';\n\nimport { normalizeTracks, SCENE_PHONE_MAX_WIDTH, SceneAttribute, sceneFrame, SceneFrame, SceneTrack } from './scene';\n\n/**\n * The ONE scroll loop (premium-sites plan §5b, SC0). Every Scene on a page reads one progress value from it, on the\n * canvas and on the live site alike. It reads where the root is and nothing else, so it has one code path: under the\n * canvas's zoom the same rectangle divides by the same zoom, and the answer is the same at any scale.\n *\n * - The value is DAMPED: the scroll stops and the page settles a moment later. This is much of the prototype's weight,\n * and why this is not a CSS scroll timeline, which cannot do it.\n * - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,\n * its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.\n * `translate`, not `transform`: a Stage may carry tracks of its own.\n * - It sleeps. No frame is asked for unless something moved, so a page holding a settled Scene costs nothing.\n * - Reads come first in a frame and writes after, and a write only ever touches compositor properties.\n */\n\nexport const SCENE_DAMPING = 9;\nconst SETTLED = 0.0005;\nconst MAX_FRAME_SECONDS = 0.1;\n/** The first frame after a sleep has no previous one to measure from: it counts as one frame, or a scroll would lose it. */\nconst WAKING_FRAME_SECONDS = 1 / 60;\nconst STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\\./g, '-')}`;\nconst TRANSFORM_WILL_CHANGE = 'transform, opacity';\n\n/** One frame of the damping: frame-rate independent, so 60 Hz and 120 Hz settle in the same time. */\nexport function dampToward(current: number, target: number, seconds: number, rate: number = SCENE_DAMPING): number {\n return current + (target - current) * (1 - Math.exp(-seconds * rate));\n}\n\n/** Where a root stands: scrolled `local` page px into its `travel`. `zoom` undoes the canvas's scale. */\nexport function sceneScrollState(rootTop: number, originTop: number, zoom: number, travel: number): { local: number; progress: number } {\n if (travel <= 0) return { local: 0, progress: 0 };\n const local = Math.min(travel, Math.max(0, -(rootTop - originTop) / (zoom || 1)));\n return { local, progress: local / travel };\n}\n\nexport interface ScrollDriverOptions {\n /** Hold the stage with `translate` (the canvas). The live site's stage is sticky and needs nothing. */\n pin?: boolean;\n /** The element a root scrolls under, when that is not the window (the canvas's frame, Preview's page). */\n originOf?: (root: HTMLElement) => HTMLElement | null;\n /** Follow what changes inside a root: tracks edited, layers added (the canvas). */\n observe?: boolean;\n damping?: number;\n /** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */\n onFrame?: (root: HTMLElement, state: SceneFrameState) => void;\n /** The window, for a test. */\n host?: Window;\n}\n\nexport interface SceneFrameState {\n /** Where the scroll stands, undamped: what a scrubber shows. */\n target: number;\n /** Where the layers stand, damped: what is on screen. */\n progress: number;\n}\n\ninterface Layer {\n el: HTMLElement;\n tracks: SceneTrack[];\n phoneTracks: SceneTrack[];\n /** What this driver last wrote on the element, so a property whose track went can be cleared. */\n last: SceneFrame;\n /** Write every property on the next frame, changed or not: a measure may have moved what a frame resolves to. */\n stale: boolean;\n}\n\ninterface Scene {\n root: HTMLElement;\n stage: HTMLElement | null;\n layers: Layer[];\n progress: number;\n target: number;\n /** Page px and the stage's own width, measured when something resizes and never per frame. */\n height: number;\n travel: number;\n phone: boolean;\n inlineSign: 1 | -1;\n /** No frame written yet: the first one lands exactly where the scroll is, with no glide. */\n fresh: boolean;\n mutations: MutationObserver | null;\n}\n\nfunction parseTracks(raw: string | null): SceneTrack[] {\n if (!raw) return [];\n try { return normalizeTracks(JSON.parse(raw)); } catch { return []; }\n}\n\nexport class ScrollDriver {\n private readonly scenes = new Map<HTMLElement, Scene>();\n private readonly host: Window;\n private readonly resize: ResizeObserver | null;\n private frame = 0;\n private lastTime = 0;\n private readonly wakeUp = (): void => this.wake();\n\n constructor(private readonly options: ScrollDriverOptions = {}) {\n this.host = options.host ?? window;\n // In capture: a scroll does not bubble, and the canvas's Lenis scrolls an element, not the window.\n this.host.addEventListener('scroll', this.wakeUp, { capture: true, passive: true });\n this.host.addEventListener('resize', this.wakeUp, { passive: true });\n const Observer = (this.host as Window & { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;\n this.resize = Observer ? new Observer(() => this.remeasureAll()) : null;\n }\n\n /** Drive a Scene's root. Idempotent: adding a root again re-reads it. */\n add(root: HTMLElement): void {\n this.remove(root);\n const scene: Scene = { root, stage: null, layers: [], progress: 0, target: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };\n this.scenes.set(root, scene);\n this.resize?.observe(root);\n if (this.options.observe) {\n const Observer = (this.host as Window & { MutationObserver?: typeof MutationObserver }).MutationObserver;\n if (Observer) {\n scene.mutations = new Observer(() => this.readScene(scene));\n scene.mutations.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: [SceneAttribute.Tracks, SceneAttribute.PhoneTracks] });\n }\n }\n this.readScene(scene);\n }\n\n remove(root: HTMLElement): void {\n const scene = this.scenes.get(root);\n if (!scene) return;\n scene.mutations?.disconnect();\n this.resize?.unobserve(root);\n if (scene.stage) scene.stage.style.removeProperty('translate');\n for (const layer of scene.layers) layer.el.style.removeProperty('will-change');\n this.scenes.delete(root);\n }\n\n /** Read a root's layers again now, keeping where it stands: an editor changed their tracks. */\n reread(root: HTMLElement): void {\n const scene = this.scenes.get(root);\n if (scene) this.readScene(scene);\n }\n\n /** The damped progress a root's layers stand at. */\n progressOf(root: HTMLElement): number | null {\n return this.scenes.get(root)?.progress ?? null;\n }\n\n /** Where the scroll stands in a root's travel, undamped. */\n targetOf(root: HTMLElement): number | null {\n return this.scenes.get(root)?.target ?? null;\n }\n\n /** Page px from the root's top to the scroll position that stands it at `p`. */\n offsetFor(root: HTMLElement, p: number): number | null {\n const scene = this.scenes.get(root);\n return scene ? scene.travel * Math.min(1, Math.max(0, p)) : null;\n }\n\n /** Land on the next frame with no glide: a scrubber sets a position, and the author is waiting to see that moment. */\n settle(root: HTMLElement): void {\n const scene = this.scenes.get(root);\n if (!scene) return;\n scene.fresh = true;\n this.wake();\n }\n\n /** Something moved that no scroll or resize announces (the canvas's zoom). */\n wake(): void {\n if (this.frame) return;\n this.frame = this.host.requestAnimationFrame(this.tick);\n }\n\n destroy(): void {\n if (this.frame) this.host.cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.host.removeEventListener('scroll', this.wakeUp, { capture: true });\n this.host.removeEventListener('resize', this.wakeUp);\n for (const root of [...this.scenes.keys()]) this.remove(root);\n this.resize?.disconnect();\n }\n\n /** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */\n private readScene(scene: Scene): void {\n scene.stage = scene.root.querySelector<HTMLElement>(STAGE_SELECTOR);\n const previous = scene.layers;\n scene.layers = Array.from(scene.root.querySelectorAll<HTMLElement>(`[${SceneAttribute.Tracks}], [${SceneAttribute.PhoneTracks}]`))\n .filter(el => el === scene.root || el.parentElement?.closest(`[${SceneAttribute.Root}]`) === scene.root)\n .map(el => this.readLayer(el, scene));\n // A layer that lost its last track stands as its own styles say again, not at the frame it last held.\n for (const layer of previous) {\n if (!scene.layers.some(current => current.el === layer.el)) this.letGo(layer);\n }\n this.measure(scene);\n scene.fresh = true;\n this.wake();\n }\n\n private letGo(layer: Layer): void {\n layer.el.style.removeProperty('will-change');\n for (const key of Object.keys(layer.last) as (keyof SceneFrame)[]) layer.el.style[key] = '';\n }\n\n private readLayer(el: HTMLElement, scene: Scene): Layer {\n const previous = scene.layers.find(layer => layer.el === el);\n el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);\n return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {}, stale: true };\n }\n\n private remeasureAll(): void {\n for (const scene of this.scenes.values()) this.measure(scene);\n this.wake();\n }\n\n private measure(scene: Scene): void {\n scene.height = scene.root.offsetHeight;\n scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));\n scene.phone = (scene.stage?.offsetWidth ?? Infinity) <= SCENE_PHONE_MAX_WIDTH;\n scene.inlineSign = scene.stage && this.host.getComputedStyle(scene.stage).direction === 'rtl' ? -1 : 1;\n for (const layer of scene.layers) layer.stale = true;\n }\n\n private readonly tick = (now: number): void => {\n this.frame = 0;\n const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;\n this.lastTime = now;\n const reads = [...this.scenes.values()].map(scene => this.read(scene));\n let moving = false;\n for (const { scene, local, target } of reads) {\n if (this.options.pin && scene.stage) scene.stage.style.setProperty('translate', `0 ${local}px`);\n const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);\n const settled = Math.abs(next - target) < SETTLED;\n scene.progress = settled ? target : next;\n scene.target = target;\n scene.fresh = false;\n this.write(scene);\n this.options.onFrame?.(scene.root, { target, progress: scene.progress });\n moving = moving || !settled;\n }\n if (moving) this.wake();\n else this.lastTime = 0;\n };\n\n private read(scene: Scene): { scene: Scene; local: number; target: number } {\n const rect = scene.root.getBoundingClientRect();\n const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;\n const zoom = scene.height ? rect.height / scene.height : 1;\n const { local, progress } = sceneScrollState(rect.top, origin, zoom, scene.travel);\n return { scene, local, target: progress };\n }\n\n private write(scene: Scene): void {\n for (const layer of scene.layers) {\n const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;\n const frame = sceneFrame(tracks, scene.progress, { inlineSign: scene.inlineSign });\n for (const key of Object.keys(frame) as (keyof SceneFrame)[]) {\n if (layer.stale || frame[key] !== layer.last[key]) layer.el.style[key] = frame[key] ?? '';\n }\n // A property whose track was deleted is no longer in the frame: it goes, or the layer holds it forever.\n for (const key of Object.keys(layer.last) as (keyof SceneFrame)[]) {\n if (!(key in frame)) layer.el.style[key] = '';\n }\n layer.last = frame;\n layer.stale = false;\n }\n }\n}\n\n/** A page's Scenes, driven by one driver; null when it holds none, or when the visitor asked for less motion (the\n * page's own CSS then lets each Scene flow). The live site's door. */\nexport function attachScenes(container: HTMLElement, options: ScrollDriverOptions = {}): ScrollDriver | null {\n const roots = container.querySelectorAll<HTMLElement>(`[${SceneAttribute.Root}]`);\n if (!roots.length) return null;\n const host = options.host ?? window;\n if (host.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return null;\n const driver = new ScrollDriver(options);\n roots.forEach(root => driver.add(root));\n return driver;\n}\n","/**\n * @vectoriox/iox-ui/scene-core — a Scene: a stage that holds still while the page scrolls past it, its layers moving on\n * ONE progress value (premium-sites plan §5b). FRAMEWORK-FREE: the builder canvas, both engine paths and (from SC6) the\n * composer read the same tracks, frames and recipe; the driver is DOM-only and is the ONE scroll loop.\n * ⚠️ Consumers wire the usual trio — ng-package raw-ts assets, jest moduleNameMapper, tsconfig paths.\n */\nexport * from './scene';\nexport * from './scene-edit';\nexport * from './scene-recipe';\nexport * from './scroll-driver';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;IAES;AAAZ,CAAA,UAAY,SAAS,EAAA;;AAEjB,IAAA,SAAA,CAAA,GAAA,CAAA,GAAA,GAAO;;AAEP,IAAA,SAAA,CAAA,GAAA,CAAA,GAAA,GAAO;AACP,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe;;AAEf,IAAA,SAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;;AAEnB,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,SAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACf,CAAC,EAhBW,SAAS,KAAT,SAAS,GAAA,EAAA,CAAA,CAAA;IA+CT;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,gBAAuB;AACvB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,iBAA0B;AAC1B,IAAA,cAAA,CAAA,aAAA,CAAA,GAA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I,CAAC,CAAC;AACvC,IAAA,OAAO,MAAM;AACjB;;AClRA;;;;;AAKG;;ACLH;;AAEG;;;;"}
|
package/package.json
CHANGED
package/scene-core/index.d.ts
CHANGED
|
@@ -103,6 +103,90 @@ declare const SCENE_FLOW_RULES: string;
|
|
|
103
103
|
/** Under reduced motion the driver never starts, so the same rules hold for the whole visit. */
|
|
104
104
|
declare const SCENE_REDUCED_MOTION_CSS = "@media (prefers-reduced-motion: reduce){.iox-role-scene{height:auto!important}.iox-role-scene-stage{position:relative!important;top:auto!important;height:auto!important;overflow:visible!important;container-type:normal!important}[data-iox-tracks]{transform:none!important;opacity:1!important;clip-path:none!important;pointer-events:auto!important}}";
|
|
105
105
|
|
|
106
|
+
declare function sceneKeyPosition(p: number): number;
|
|
107
|
+
interface SceneTrackDef {
|
|
108
|
+
prop: SceneProp;
|
|
109
|
+
/** Ground and Ink hold colours; everything else holds a number. */
|
|
110
|
+
colour: boolean;
|
|
111
|
+
/** What a layer with no track for this property stands at, in stored units. */
|
|
112
|
+
rest: number;
|
|
113
|
+
/** The bounds and the step, in the units the author sees. */
|
|
114
|
+
min: number;
|
|
115
|
+
max: number;
|
|
116
|
+
step: number;
|
|
117
|
+
/** Author's units per stored unit: scale 1.2 reads 120 %, opacity 0.5 reads 50 %. */
|
|
118
|
+
factor: number;
|
|
119
|
+
unit: string;
|
|
120
|
+
}
|
|
121
|
+
/** The closed vocabulary, in the order the panel lists it. */
|
|
122
|
+
declare const SCENE_TRACK_DEFS: ReadonlyArray<SceneTrackDef>;
|
|
123
|
+
declare function sceneTrackDef(prop: SceneProp): SceneTrackDef;
|
|
124
|
+
/** A number track's value at `p` in the author's units, or where the layer rests when it has no such track. */
|
|
125
|
+
declare function sceneDisplayValue(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* The colour to show for a colour track at `p`: the key at or before it, else the first. Between two keys the live value
|
|
128
|
+
* is a mix, which is no value a colour control can edit; the author sets keys, so the panel shows a key.
|
|
129
|
+
*/
|
|
130
|
+
declare function sceneColourKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): string;
|
|
131
|
+
declare function sceneHasKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Set a key at `p`, in the author's units. A number is clamped to its bounds; a colour that is no colour changes nothing,
|
|
134
|
+
* because `normalizeTracks` would drop it anyway and the author's other keys must survive.
|
|
135
|
+
*/
|
|
136
|
+
declare function withSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number, value: number | string): SceneTrack[];
|
|
137
|
+
/** Remove the key at `p`. The last key of a track takes the track with it. */
|
|
138
|
+
declare function withoutSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): SceneTrack[];
|
|
139
|
+
/**
|
|
140
|
+
* Move a key from `from` toward `to`, stopping one grid step short of its neighbours: keys never swap, so a drag can
|
|
141
|
+
* never reverse a movement the author set. Returns where it landed, so a drag keeps following it.
|
|
142
|
+
*/
|
|
143
|
+
declare function movedSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, from: number, to: number): {
|
|
144
|
+
tracks: SceneTrack[];
|
|
145
|
+
at: number;
|
|
146
|
+
};
|
|
147
|
+
/** A track's bar on the timeline: from its first key to its last, as fractions of the scroll. */
|
|
148
|
+
declare function sceneTrackSpan(track: SceneTrack): {
|
|
149
|
+
from: number;
|
|
150
|
+
to: number;
|
|
151
|
+
};
|
|
152
|
+
/** A node as these helpers read it: a builder node and a saved one both fit. */
|
|
153
|
+
interface SceneTreeNode extends SceneNodeSource {
|
|
154
|
+
id?: string;
|
|
155
|
+
children?: ReadonlyArray<SceneTreeNode> | null;
|
|
156
|
+
}
|
|
157
|
+
/** The Scene a selection sits in: the innermost Scene on its path from the top. */
|
|
158
|
+
declare function sceneRootOnPath<T extends SceneTreeNode>(path: ReadonlyArray<T>): T | null;
|
|
159
|
+
/** Every Scene on a page, in document order, a Scene inside a Scene included. */
|
|
160
|
+
declare function scenesIn<T extends SceneTreeNode>(nodes: ReadonlyArray<T> | null | undefined): T[];
|
|
161
|
+
/**
|
|
162
|
+
* What the timeline lists: the stage, everything standing on it, and anything deeper that carries tracks. A layer with
|
|
163
|
+
* none is listed too, or it could never be given its first. A Scene inside this one keeps its own timeline.
|
|
164
|
+
*/
|
|
165
|
+
declare function sceneLayersOf<T extends SceneTreeNode>(root: T | null | undefined): T[];
|
|
166
|
+
/** How many screens of scrolling a Scene holds for, and the bounds the panel offers. */
|
|
167
|
+
declare const SCENE_MIN_SCREENS = 0.5;
|
|
168
|
+
declare const SCENE_MAX_SCREENS = 20;
|
|
169
|
+
/**
|
|
170
|
+
* The root's height as screens of scrolling: the stage itself takes one screen, so 400vh holds for 3. Null for a height
|
|
171
|
+
* set in anything else (a hand-set px), which the panel then says it cannot express rather than overwriting it.
|
|
172
|
+
*/
|
|
173
|
+
declare function sceneScreensOf(height: string | null | undefined): number | null;
|
|
174
|
+
declare function sceneHeightForScreens(screens: number): string;
|
|
175
|
+
/** Motion v2 §3d's limits for scroll-linked work on one page. */
|
|
176
|
+
declare const SCENE_BUDGET: {
|
|
177
|
+
readonly heldSections: 1;
|
|
178
|
+
readonly movingLayers: 8;
|
|
179
|
+
};
|
|
180
|
+
interface SceneBudget {
|
|
181
|
+
/** Every track on the page's Scenes. */
|
|
182
|
+
tracks: number;
|
|
183
|
+
heldSections: number;
|
|
184
|
+
movingLayers: number;
|
|
185
|
+
within: boolean;
|
|
186
|
+
}
|
|
187
|
+
/** What a page's Scenes cost. Advice to the author, never a refusal: the composer enforces it from SC6. */
|
|
188
|
+
declare function sceneBudget(nodes: ReadonlyArray<SceneTreeNode> | null | undefined): SceneBudget;
|
|
189
|
+
|
|
106
190
|
/**
|
|
107
191
|
* The SCENE recipe: ordinary nodes, no new type, so all three render paths and every panel already know it.
|
|
108
192
|
*
|
|
@@ -158,9 +242,17 @@ interface ScrollDriverOptions {
|
|
|
158
242
|
/** Follow what changes inside a root: tracks edited, layers added (the canvas). */
|
|
159
243
|
observe?: boolean;
|
|
160
244
|
damping?: number;
|
|
245
|
+
/** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */
|
|
246
|
+
onFrame?: (root: HTMLElement, state: SceneFrameState) => void;
|
|
161
247
|
/** The window, for a test. */
|
|
162
248
|
host?: Window;
|
|
163
249
|
}
|
|
250
|
+
interface SceneFrameState {
|
|
251
|
+
/** Where the scroll stands, undamped: what a scrubber shows. */
|
|
252
|
+
target: number;
|
|
253
|
+
/** Where the layers stand, damped: what is on screen. */
|
|
254
|
+
progress: number;
|
|
255
|
+
}
|
|
164
256
|
declare class ScrollDriver {
|
|
165
257
|
private readonly options;
|
|
166
258
|
private readonly scenes;
|
|
@@ -173,13 +265,22 @@ declare class ScrollDriver {
|
|
|
173
265
|
/** Drive a Scene's root. Idempotent: adding a root again re-reads it. */
|
|
174
266
|
add(root: HTMLElement): void;
|
|
175
267
|
remove(root: HTMLElement): void;
|
|
268
|
+
/** Read a root's layers again now, keeping where it stands: an editor changed their tracks. */
|
|
269
|
+
reread(root: HTMLElement): void;
|
|
176
270
|
/** The damped progress a root's layers stand at. */
|
|
177
271
|
progressOf(root: HTMLElement): number | null;
|
|
272
|
+
/** Where the scroll stands in a root's travel, undamped. */
|
|
273
|
+
targetOf(root: HTMLElement): number | null;
|
|
274
|
+
/** Page px from the root's top to the scroll position that stands it at `p`. */
|
|
275
|
+
offsetFor(root: HTMLElement, p: number): number | null;
|
|
276
|
+
/** Land on the next frame with no glide: a scrubber sets a position, and the author is waiting to see that moment. */
|
|
277
|
+
settle(root: HTMLElement): void;
|
|
178
278
|
/** Something moved that no scroll or resize announces (the canvas's zoom). */
|
|
179
279
|
wake(): void;
|
|
180
280
|
destroy(): void;
|
|
181
281
|
/** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */
|
|
182
|
-
private
|
|
282
|
+
private readScene;
|
|
283
|
+
private letGo;
|
|
183
284
|
private readLayer;
|
|
184
285
|
private remeasureAll;
|
|
185
286
|
private measure;
|
|
@@ -191,5 +292,5 @@ declare class ScrollDriver {
|
|
|
191
292
|
* page's own CSS then lets each Scene flow). The live site's door. */
|
|
192
293
|
declare function attachScenes(container: HTMLElement, options?: ScrollDriverOptions): ScrollDriver | null;
|
|
193
294
|
|
|
194
|
-
export { SCENE_DAMPING, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_STAGE_HEIGHT, SCENE_WORDS, SceneAttribute, SceneProp, ScrollDriver, applySceneFirstFrame, attachScenes, buildSceneRecipe, colourAt, dampToward, normalizeTracks, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneNodeAttributes, sceneScrollState, syncSceneAttributes, valueAt };
|
|
195
|
-
export type { SceneFrame, SceneFrameOptions, SceneKey, SceneLayerNode, SceneNodeSource, SceneTrack, SceneWords, ScrollDriverOptions };
|
|
295
|
+
export { SCENE_BUDGET, SCENE_DAMPING, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_WORDS, SceneAttribute, SceneProp, ScrollDriver, applySceneFirstFrame, attachScenes, buildSceneRecipe, colourAt, dampToward, movedSceneKey, normalizeTracks, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, sceneRootOnPath, sceneScreensOf, sceneScrollState, sceneTrackDef, sceneTrackSpan, scenesIn, syncSceneAttributes, valueAt, withSceneKey, withoutSceneKey };
|
|
296
|
+
export type { SceneBudget, SceneFrame, SceneFrameOptions, SceneFrameState, SceneKey, SceneLayerNode, SceneNodeSource, SceneTrack, SceneTrackDef, SceneTreeNode, SceneWords, ScrollDriverOptions };
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { SceneRole } from '@vectoriox/iox-ui/composite-core';
|
|
2
|
+
|
|
3
|
+
import { normalizeTracks, SceneKey, SceneNodeSource, SceneProp, SceneTrack, valueAt } from './scene';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Authoring a Scene (premium-sites plan §5b, SC2): the decisions the builder's timeline and its panel share, so neither
|
|
7
|
+
* holds a second copy of what a key is. Pure, and every edit returns NEW tracks: the caller assigns them to the node, so
|
|
8
|
+
* undo's snapshot and the attribute the driver reads can never see a half-made edit.
|
|
9
|
+
*
|
|
10
|
+
* One rule to author by: one key holds, two keys move. A value edited at a scroll position sets a key there, so a layer
|
|
11
|
+
* is animated by scrolling to a moment and saying where it stands at that moment.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Keys sit on whole percents of the scroll: finer than anyone can place by hand, and two keys never nearly coincide. */
|
|
15
|
+
const KEY_GRID = 100;
|
|
16
|
+
|
|
17
|
+
export function sceneKeyPosition(p: number): number {
|
|
18
|
+
return Math.round(Math.min(1, Math.max(0, p)) * KEY_GRID) / KEY_GRID;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SceneTrackDef {
|
|
22
|
+
prop: SceneProp;
|
|
23
|
+
/** Ground and Ink hold colours; everything else holds a number. */
|
|
24
|
+
colour: boolean;
|
|
25
|
+
/** What a layer with no track for this property stands at, in stored units. */
|
|
26
|
+
rest: number;
|
|
27
|
+
/** The bounds and the step, in the units the author sees. */
|
|
28
|
+
min: number;
|
|
29
|
+
max: number;
|
|
30
|
+
step: number;
|
|
31
|
+
/** Author's units per stored unit: scale 1.2 reads 120 %, opacity 0.5 reads 50 %. */
|
|
32
|
+
factor: number;
|
|
33
|
+
unit: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PERCENT = '%';
|
|
37
|
+
const DEGREES = '°';
|
|
38
|
+
|
|
39
|
+
/** The closed vocabulary, in the order the panel lists it. */
|
|
40
|
+
export const SCENE_TRACK_DEFS: ReadonlyArray<SceneTrackDef> = [
|
|
41
|
+
{ prop: SceneProp.X, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },
|
|
42
|
+
{ prop: SceneProp.Y, colour: false, rest: 0, min: -300, max: 300, step: 1, factor: 1, unit: PERCENT },
|
|
43
|
+
{ prop: SceneProp.Scale, colour: false, rest: 1, min: 0, max: 2000, step: 1, factor: 100, unit: PERCENT },
|
|
44
|
+
{ prop: SceneProp.Rotate, colour: false, rest: 0, min: -720, max: 720, step: 1, factor: 1, unit: DEGREES },
|
|
45
|
+
{ prop: SceneProp.Opacity, colour: false, rest: 1, min: 0, max: 100, step: 1, factor: 100, unit: PERCENT },
|
|
46
|
+
{ prop: SceneProp.Clip, colour: false, rest: 0, min: 0, max: 50, step: 1, factor: 1, unit: PERCENT },
|
|
47
|
+
{ prop: SceneProp.Ground, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },
|
|
48
|
+
{ prop: SceneProp.Ink, colour: true, rest: 0, min: 0, max: 0, step: 0, factor: 1, unit: '' },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const DEF_BY_PROP = new Map(SCENE_TRACK_DEFS.map(def => [def.prop, def]));
|
|
52
|
+
|
|
53
|
+
export function sceneTrackDef(prop: SceneProp): SceneTrackDef {
|
|
54
|
+
return DEF_BY_PROP.get(prop)!;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const trackOf = (tracks: ReadonlyArray<SceneTrack>, prop: SceneProp): SceneTrack | undefined => tracks.find(t => t.prop === prop);
|
|
58
|
+
const samePosition = (a: number, b: number): boolean => sceneKeyPosition(a) === sceneKeyPosition(b);
|
|
59
|
+
const roundTo = (value: number, places = 4): number => Number(value.toFixed(places));
|
|
60
|
+
|
|
61
|
+
/** A number track's value at `p` in the author's units, or where the layer rests when it has no such track. */
|
|
62
|
+
export function sceneDisplayValue(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): number {
|
|
63
|
+
const def = sceneTrackDef(prop);
|
|
64
|
+
const track = trackOf(tracks, prop);
|
|
65
|
+
return roundTo((track ? valueAt(track.keys, p) : def.rest) * def.factor, 2);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The colour to show for a colour track at `p`: the key at or before it, else the first. Between two keys the live value
|
|
70
|
+
* is a mix, which is no value a colour control can edit; the author sets keys, so the panel shows a key.
|
|
71
|
+
*/
|
|
72
|
+
export function sceneColourKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): string {
|
|
73
|
+
const keys = trackOf(tracks, prop)?.keys;
|
|
74
|
+
if (!keys?.length) return '';
|
|
75
|
+
let held = keys[0];
|
|
76
|
+
for (const key of keys) if (key[0] <= sceneKeyPosition(p)) held = key;
|
|
77
|
+
return String(held[1]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function sceneHasKeyAt(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): boolean {
|
|
81
|
+
return !!trackOf(tracks, prop)?.keys.some(key => samePosition(key[0], p));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function storedValue(def: SceneTrackDef, value: number | string): number | string {
|
|
85
|
+
if (def.colour) return value;
|
|
86
|
+
return roundTo(Math.min(def.max, Math.max(def.min, Number(value))) / def.factor);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function replaceTrack(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, keys: ReadonlyArray<SceneKey>): SceneTrack[] {
|
|
90
|
+
const rest = tracks.filter(t => t.prop !== prop);
|
|
91
|
+
if (!keys.length) return rest;
|
|
92
|
+
const at = tracks.findIndex(t => t.prop === prop);
|
|
93
|
+
const next = [...rest];
|
|
94
|
+
next.splice(at < 0 ? rest.length : at, 0, { prop, keys });
|
|
95
|
+
return next;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set a key at `p`, in the author's units. A number is clamped to its bounds; a colour that is no colour changes nothing,
|
|
100
|
+
* because `normalizeTracks` would drop it anyway and the author's other keys must survive.
|
|
101
|
+
*/
|
|
102
|
+
export function withSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number, value: number | string): SceneTrack[] {
|
|
103
|
+
const def = sceneTrackDef(prop);
|
|
104
|
+
const at = sceneKeyPosition(p);
|
|
105
|
+
if (!def.colour && !Number.isFinite(Number(value))) return [...tracks];
|
|
106
|
+
const key: SceneKey = [at, storedValue(def, value)];
|
|
107
|
+
const others = (trackOf(tracks, prop)?.keys ?? []).filter(k => !samePosition(k[0], at));
|
|
108
|
+
const keys = [...others, key].sort((a, b) => a[0] - b[0]);
|
|
109
|
+
const next = replaceTrack(tracks, prop, keys);
|
|
110
|
+
return trackOf(normalizeTracks(next), prop)?.keys.length === keys.length ? next : [...tracks];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Remove the key at `p`. The last key of a track takes the track with it. */
|
|
114
|
+
export function withoutSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): SceneTrack[] {
|
|
115
|
+
const track = trackOf(tracks, prop);
|
|
116
|
+
if (!track) return [...tracks];
|
|
117
|
+
return replaceTrack(tracks, prop, track.keys.filter(key => !samePosition(key[0], p)));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Move a key from `from` toward `to`, stopping one grid step short of its neighbours: keys never swap, so a drag can
|
|
122
|
+
* never reverse a movement the author set. Returns where it landed, so a drag keeps following it.
|
|
123
|
+
*/
|
|
124
|
+
export function movedSceneKey(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, from: number, to: number): { tracks: SceneTrack[]; at: number } {
|
|
125
|
+
const track = trackOf(tracks, prop);
|
|
126
|
+
const index = track ? track.keys.findIndex(key => samePosition(key[0], from)) : -1;
|
|
127
|
+
if (!track || index < 0) return { tracks: [...tracks], at: sceneKeyPosition(from) };
|
|
128
|
+
const step = 1 / KEY_GRID;
|
|
129
|
+
const low = index > 0 ? track.keys[index - 1][0] + step : 0;
|
|
130
|
+
const high = index < track.keys.length - 1 ? track.keys[index + 1][0] - step : 1;
|
|
131
|
+
const at = sceneKeyPosition(Math.min(high, Math.max(low, to)));
|
|
132
|
+
const keys = track.keys.map((key, i): SceneKey => (i === index ? [at, key[1]] : key));
|
|
133
|
+
return { tracks: replaceTrack(tracks, prop, keys), at };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A track's bar on the timeline: from its first key to its last, as fractions of the scroll. */
|
|
137
|
+
export function sceneTrackSpan(track: SceneTrack): { from: number; to: number } {
|
|
138
|
+
return { from: track.keys[0][0], to: track.keys[track.keys.length - 1][0] };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A node as these helpers read it: a builder node and a saved one both fit. */
|
|
142
|
+
export interface SceneTreeNode extends SceneNodeSource {
|
|
143
|
+
id?: string;
|
|
144
|
+
children?: ReadonlyArray<SceneTreeNode> | null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The Scene a selection sits in: the innermost Scene on its path from the top. */
|
|
148
|
+
export function sceneRootOnPath<T extends SceneTreeNode>(path: ReadonlyArray<T>): T | null {
|
|
149
|
+
for (let i = path.length - 1; i >= 0; i--) if (path[i].role === SceneRole.Scene) return path[i];
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Every Scene on a page, in document order, a Scene inside a Scene included. */
|
|
154
|
+
export function scenesIn<T extends SceneTreeNode>(nodes: ReadonlyArray<T> | null | undefined): T[] {
|
|
155
|
+
const found: T[] = [];
|
|
156
|
+
for (const node of nodes ?? []) {
|
|
157
|
+
if (node.role === SceneRole.Scene) found.push(node);
|
|
158
|
+
found.push(...scenesIn((node.children ?? []) as ReadonlyArray<T>));
|
|
159
|
+
}
|
|
160
|
+
return found;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const hasTracks = (node: SceneTreeNode): boolean =>
|
|
164
|
+
normalizeTracks(node.sceneTracks).length > 0 || normalizeTracks(node.scenePhoneTracks).length > 0;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* What the timeline lists: the stage, everything standing on it, and anything deeper that carries tracks. A layer with
|
|
168
|
+
* none is listed too, or it could never be given its first. A Scene inside this one keeps its own timeline.
|
|
169
|
+
*/
|
|
170
|
+
export function sceneLayersOf<T extends SceneTreeNode>(root: T | null | undefined): T[] {
|
|
171
|
+
const stage = (root?.children ?? []).find(child => child.role === SceneRole.Stage) as T | undefined;
|
|
172
|
+
if (!stage) return [];
|
|
173
|
+
const layers: T[] = [stage];
|
|
174
|
+
const deeper = (node: T): void => {
|
|
175
|
+
for (const child of (node.children ?? []) as ReadonlyArray<T>) {
|
|
176
|
+
if (child.role === SceneRole.Scene) continue;
|
|
177
|
+
if (hasTracks(child)) layers.push(child);
|
|
178
|
+
deeper(child);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
for (const child of (stage.children ?? []) as ReadonlyArray<T>) {
|
|
182
|
+
if (child.role === SceneRole.Scene) continue;
|
|
183
|
+
layers.push(child);
|
|
184
|
+
deeper(child);
|
|
185
|
+
}
|
|
186
|
+
return layers;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** How many screens of scrolling a Scene holds for, and the bounds the panel offers. */
|
|
190
|
+
export const SCENE_MIN_SCREENS = 0.5;
|
|
191
|
+
export const SCENE_MAX_SCREENS = 20;
|
|
192
|
+
|
|
193
|
+
const VIEWPORT_HEIGHT = /^([\d.]+)[sdl]?vh$/;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The root's height as screens of scrolling: the stage itself takes one screen, so 400vh holds for 3. Null for a height
|
|
197
|
+
* set in anything else (a hand-set px), which the panel then says it cannot express rather than overwriting it.
|
|
198
|
+
*/
|
|
199
|
+
export function sceneScreensOf(height: string | null | undefined): number | null {
|
|
200
|
+
const match = VIEWPORT_HEIGHT.exec(String(height ?? '').trim());
|
|
201
|
+
if (!match) return null;
|
|
202
|
+
return Math.max(0, roundTo(Number(match[1]) / 100 - 1, 2));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function sceneHeightForScreens(screens: number): string {
|
|
206
|
+
const held = Math.min(SCENE_MAX_SCREENS, Math.max(SCENE_MIN_SCREENS, screens));
|
|
207
|
+
return `${roundTo((held + 1) * 100, 1)}vh`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Motion v2 §3d's limits for scroll-linked work on one page. */
|
|
211
|
+
export const SCENE_BUDGET = { heldSections: 1, movingLayers: 8 } as const;
|
|
212
|
+
|
|
213
|
+
export interface SceneBudget {
|
|
214
|
+
/** Every track on the page's Scenes. */
|
|
215
|
+
tracks: number;
|
|
216
|
+
heldSections: number;
|
|
217
|
+
movingLayers: number;
|
|
218
|
+
within: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** What a page's Scenes cost. Advice to the author, never a refusal: the composer enforces it from SC6. */
|
|
222
|
+
export function sceneBudget(nodes: ReadonlyArray<SceneTreeNode> | null | undefined): SceneBudget {
|
|
223
|
+
const scenes = scenesIn(nodes);
|
|
224
|
+
const moving = scenes.flatMap(scene => sceneLayersOf(scene)).filter(hasTracks);
|
|
225
|
+
const movingLayers = new Set(moving).size;
|
|
226
|
+
const tracks = [...new Set(moving)].reduce((sum, node) => sum + normalizeTracks(node.sceneTracks).length, 0);
|
|
227
|
+
return {
|
|
228
|
+
tracks,
|
|
229
|
+
heldSections: scenes.length,
|
|
230
|
+
movingLayers,
|
|
231
|
+
within: scenes.length <= SCENE_BUDGET.heldSections && movingLayers <= SCENE_BUDGET.movingLayers,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
@@ -44,15 +44,27 @@ export interface ScrollDriverOptions {
|
|
|
44
44
|
/** Follow what changes inside a root: tracks edited, layers added (the canvas). */
|
|
45
45
|
observe?: boolean;
|
|
46
46
|
damping?: number;
|
|
47
|
+
/** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */
|
|
48
|
+
onFrame?: (root: HTMLElement, state: SceneFrameState) => void;
|
|
47
49
|
/** The window, for a test. */
|
|
48
50
|
host?: Window;
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
export interface SceneFrameState {
|
|
54
|
+
/** Where the scroll stands, undamped: what a scrubber shows. */
|
|
55
|
+
target: number;
|
|
56
|
+
/** Where the layers stand, damped: what is on screen. */
|
|
57
|
+
progress: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
interface Layer {
|
|
52
61
|
el: HTMLElement;
|
|
53
62
|
tracks: SceneTrack[];
|
|
54
63
|
phoneTracks: SceneTrack[];
|
|
64
|
+
/** What this driver last wrote on the element, so a property whose track went can be cleared. */
|
|
55
65
|
last: SceneFrame;
|
|
66
|
+
/** Write every property on the next frame, changed or not: a measure may have moved what a frame resolves to. */
|
|
67
|
+
stale: boolean;
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
interface Scene {
|
|
@@ -60,6 +72,7 @@ interface Scene {
|
|
|
60
72
|
stage: HTMLElement | null;
|
|
61
73
|
layers: Layer[];
|
|
62
74
|
progress: number;
|
|
75
|
+
target: number;
|
|
63
76
|
/** Page px and the stage's own width, measured when something resizes and never per frame. */
|
|
64
77
|
height: number;
|
|
65
78
|
travel: number;
|
|
@@ -95,17 +108,17 @@ export class ScrollDriver {
|
|
|
95
108
|
/** Drive a Scene's root. Idempotent: adding a root again re-reads it. */
|
|
96
109
|
add(root: HTMLElement): void {
|
|
97
110
|
this.remove(root);
|
|
98
|
-
const scene: Scene = { root, stage: null, layers: [], progress: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
111
|
+
const scene: Scene = { root, stage: null, layers: [], progress: 0, target: 0, height: 0, travel: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
99
112
|
this.scenes.set(root, scene);
|
|
100
113
|
this.resize?.observe(root);
|
|
101
114
|
if (this.options.observe) {
|
|
102
115
|
const Observer = (this.host as Window & { MutationObserver?: typeof MutationObserver }).MutationObserver;
|
|
103
116
|
if (Observer) {
|
|
104
|
-
scene.mutations = new Observer(() => this.
|
|
117
|
+
scene.mutations = new Observer(() => this.readScene(scene));
|
|
105
118
|
scene.mutations.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: [SceneAttribute.Tracks, SceneAttribute.PhoneTracks] });
|
|
106
119
|
}
|
|
107
120
|
}
|
|
108
|
-
this.
|
|
121
|
+
this.readScene(scene);
|
|
109
122
|
}
|
|
110
123
|
|
|
111
124
|
remove(root: HTMLElement): void {
|
|
@@ -118,11 +131,36 @@ export class ScrollDriver {
|
|
|
118
131
|
this.scenes.delete(root);
|
|
119
132
|
}
|
|
120
133
|
|
|
134
|
+
/** Read a root's layers again now, keeping where it stands: an editor changed their tracks. */
|
|
135
|
+
reread(root: HTMLElement): void {
|
|
136
|
+
const scene = this.scenes.get(root);
|
|
137
|
+
if (scene) this.readScene(scene);
|
|
138
|
+
}
|
|
139
|
+
|
|
121
140
|
/** The damped progress a root's layers stand at. */
|
|
122
141
|
progressOf(root: HTMLElement): number | null {
|
|
123
142
|
return this.scenes.get(root)?.progress ?? null;
|
|
124
143
|
}
|
|
125
144
|
|
|
145
|
+
/** Where the scroll stands in a root's travel, undamped. */
|
|
146
|
+
targetOf(root: HTMLElement): number | null {
|
|
147
|
+
return this.scenes.get(root)?.target ?? null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Page px from the root's top to the scroll position that stands it at `p`. */
|
|
151
|
+
offsetFor(root: HTMLElement, p: number): number | null {
|
|
152
|
+
const scene = this.scenes.get(root);
|
|
153
|
+
return scene ? scene.travel * Math.min(1, Math.max(0, p)) : null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Land on the next frame with no glide: a scrubber sets a position, and the author is waiting to see that moment. */
|
|
157
|
+
settle(root: HTMLElement): void {
|
|
158
|
+
const scene = this.scenes.get(root);
|
|
159
|
+
if (!scene) return;
|
|
160
|
+
scene.fresh = true;
|
|
161
|
+
this.wake();
|
|
162
|
+
}
|
|
163
|
+
|
|
126
164
|
/** Something moved that no scroll or resize announces (the canvas's zoom). */
|
|
127
165
|
wake(): void {
|
|
128
166
|
if (this.frame) return;
|
|
@@ -139,20 +177,30 @@ export class ScrollDriver {
|
|
|
139
177
|
}
|
|
140
178
|
|
|
141
179
|
/** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */
|
|
142
|
-
private
|
|
180
|
+
private readScene(scene: Scene): void {
|
|
143
181
|
scene.stage = scene.root.querySelector<HTMLElement>(STAGE_SELECTOR);
|
|
182
|
+
const previous = scene.layers;
|
|
144
183
|
scene.layers = Array.from(scene.root.querySelectorAll<HTMLElement>(`[${SceneAttribute.Tracks}], [${SceneAttribute.PhoneTracks}]`))
|
|
145
184
|
.filter(el => el === scene.root || el.parentElement?.closest(`[${SceneAttribute.Root}]`) === scene.root)
|
|
146
185
|
.map(el => this.readLayer(el, scene));
|
|
186
|
+
// A layer that lost its last track stands as its own styles say again, not at the frame it last held.
|
|
187
|
+
for (const layer of previous) {
|
|
188
|
+
if (!scene.layers.some(current => current.el === layer.el)) this.letGo(layer);
|
|
189
|
+
}
|
|
147
190
|
this.measure(scene);
|
|
148
191
|
scene.fresh = true;
|
|
149
192
|
this.wake();
|
|
150
193
|
}
|
|
151
194
|
|
|
195
|
+
private letGo(layer: Layer): void {
|
|
196
|
+
layer.el.style.removeProperty('will-change');
|
|
197
|
+
for (const key of Object.keys(layer.last) as (keyof SceneFrame)[]) layer.el.style[key] = '';
|
|
198
|
+
}
|
|
199
|
+
|
|
152
200
|
private readLayer(el: HTMLElement, scene: Scene): Layer {
|
|
153
201
|
const previous = scene.layers.find(layer => layer.el === el);
|
|
154
202
|
el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);
|
|
155
|
-
return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {} };
|
|
203
|
+
return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {}, stale: true };
|
|
156
204
|
}
|
|
157
205
|
|
|
158
206
|
private remeasureAll(): void {
|
|
@@ -165,7 +213,7 @@ export class ScrollDriver {
|
|
|
165
213
|
scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));
|
|
166
214
|
scene.phone = (scene.stage?.offsetWidth ?? Infinity) <= SCENE_PHONE_MAX_WIDTH;
|
|
167
215
|
scene.inlineSign = scene.stage && this.host.getComputedStyle(scene.stage).direction === 'rtl' ? -1 : 1;
|
|
168
|
-
for (const layer of scene.layers) layer.
|
|
216
|
+
for (const layer of scene.layers) layer.stale = true;
|
|
169
217
|
}
|
|
170
218
|
|
|
171
219
|
private readonly tick = (now: number): void => {
|
|
@@ -179,8 +227,10 @@ export class ScrollDriver {
|
|
|
179
227
|
const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);
|
|
180
228
|
const settled = Math.abs(next - target) < SETTLED;
|
|
181
229
|
scene.progress = settled ? target : next;
|
|
230
|
+
scene.target = target;
|
|
182
231
|
scene.fresh = false;
|
|
183
232
|
this.write(scene);
|
|
233
|
+
this.options.onFrame?.(scene.root, { target, progress: scene.progress });
|
|
184
234
|
moving = moving || !settled;
|
|
185
235
|
}
|
|
186
236
|
if (moving) this.wake();
|
|
@@ -200,9 +250,14 @@ export class ScrollDriver {
|
|
|
200
250
|
const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;
|
|
201
251
|
const frame = sceneFrame(tracks, scene.progress, { inlineSign: scene.inlineSign });
|
|
202
252
|
for (const key of Object.keys(frame) as (keyof SceneFrame)[]) {
|
|
203
|
-
if (frame[key] !== layer.last[key]) layer.el.style[key] = frame[key] ?? '';
|
|
253
|
+
if (layer.stale || frame[key] !== layer.last[key]) layer.el.style[key] = frame[key] ?? '';
|
|
254
|
+
}
|
|
255
|
+
// A property whose track was deleted is no longer in the frame: it goes, or the layer holds it forever.
|
|
256
|
+
for (const key of Object.keys(layer.last) as (keyof SceneFrame)[]) {
|
|
257
|
+
if (!(key in frame)) layer.el.style[key] = '';
|
|
204
258
|
}
|
|
205
259
|
layer.last = frame;
|
|
260
|
+
layer.stale = false;
|
|
206
261
|
}
|
|
207
262
|
}
|
|
208
263
|
}
|