@vectoriox/iox-ui 5.164.0 → 5.165.0
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/composite-core/index.d.ts +5 -0
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +5 -0
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +51 -16
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +304 -6
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +22 -3
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +7 -1
- package/index.d.ts +3 -0
- package/package.json +1 -1
- package/scene-core/index.d.ts +107 -6
- package/src/composite-core/composite-kinds.ts +5 -0
- package/src/generation-core/carry-fill.ts +1 -1
- package/src/generation-core/check-layout.ts +1 -1
- package/src/generation-core/compose-layout.ts +51 -12
- package/src/scene-core/scene.ts +5 -0
- package/src/scene-core/scroll-driver.ts +286 -2
- package/src/scene-core/split-text.ts +17 -4
- package/styles/iox-design.css +9 -2
|
@@ -91,6 +91,8 @@ var SceneAttribute;
|
|
|
91
91
|
SceneAttribute["PhoneTracks"] = "data-iox-tracks-phone";
|
|
92
92
|
/** A root's stage that is not a Scene's `scene.stage` part: the slider a scroll plays (premium M4). */
|
|
93
93
|
SceneAttribute["Stage"] = "data-iox-scene-stage";
|
|
94
|
+
/** On a layer whose hold move has ended — it has LANDED (AW10, `sceneLand`). Written by the driver, read by `onSceneLand`. */
|
|
95
|
+
SceneAttribute["Landed"] = "data-iox-landed";
|
|
94
96
|
})(SceneAttribute || (SceneAttribute = {}));
|
|
95
97
|
/**
|
|
96
98
|
* A SLIDER THE SCROLL PLAYS (premium components M4 — M1.3's held gallery). Its progress rests on each picture and changes
|
|
@@ -394,6 +396,9 @@ const SCENE_FLOW_RULES = `.iox-role-scene{height:auto!important}`
|
|
|
394
396
|
+ `[${SceneAttribute.Tracks}]{max-width:100%!important;flex-wrap:wrap!important}`
|
|
395
397
|
// Drawers (AW9) flow as the phone draws them: each step full width, its spine a label above its words.
|
|
396
398
|
+ `.iox-role-scene-drawer{width:100%!important;height:auto!important;flex-direction:column!important}`
|
|
399
|
+
// …one band after another, edge to edge: each step is its own ground, so the stage's padding and gap would show the
|
|
400
|
+
// section's ground between them and around them (a phone's stack draws none).
|
|
401
|
+
+ `.iox-role-scene-stage:has(>.iox-role-scene-drawer,>[class*="iox-outer-"]>.iox-role-scene-drawer){padding:0!important;gap:0!important}`
|
|
397
402
|
+ `.iox-role-scene-drawer-spine{writing-mode:horizontal-tb!important;rotate:none!important;width:auto!important;height:auto!important}`
|
|
398
403
|
// A Video the scroll plays stands as its poster, at the poster's own height: a percent of a stage that now flows is nothing.
|
|
399
404
|
+ `[${VideoAttribute.Frames}]{height:auto!important}`
|
|
@@ -1145,8 +1150,18 @@ const STAGGER_MS = {
|
|
|
1145
1150
|
[TextRevealBy.Word]: WORD_STAGGER_MS,
|
|
1146
1151
|
[TextRevealBy.Letter]: LETTER_STAGGER_MS,
|
|
1147
1152
|
};
|
|
1148
|
-
|
|
1149
|
-
|
|
1153
|
+
/** The most a reveal may ask between two pieces (`params.stagger`): past it a heading is spelled out, not assembled. */
|
|
1154
|
+
const REVEAL_STAGGER_MAX_MS = 300;
|
|
1155
|
+
/**
|
|
1156
|
+
* A reveal's own step between pieces, in ms (`params.stagger`; AW10 — a drawer's letters ~20 ms, its lines ~150 ms), or
|
|
1157
|
+
* undefined for the step its kind of piece takes. Clamped to 0–`REVEAL_STAGGER_MAX_MS`; anything not a number is undefined.
|
|
1158
|
+
*/
|
|
1159
|
+
function textRevealStaggerOf(value) {
|
|
1160
|
+
const ms = typeof value === 'number' ? value : typeof value === 'string' && value.trim() ? Number(value) : NaN;
|
|
1161
|
+
return Number.isFinite(ms) ? Math.min(REVEAL_STAGGER_MAX_MS, Math.max(0, Math.round(ms))) : undefined;
|
|
1162
|
+
}
|
|
1163
|
+
function revealStagger(groups, by, stagger) {
|
|
1164
|
+
return groups > 1 ? Math.min(stagger ?? STAGGER_MS[by], STAGGER_BUDGET_MS / (groups - 1)) : 0;
|
|
1150
1165
|
}
|
|
1151
1166
|
/** Past the mask's negative inset, so nothing shows before a piece's turn. */
|
|
1152
1167
|
const PIECE_FRAMES = [{ transform: 'translateY(120%)' }, { transform: 'translateY(0)' }];
|
|
@@ -1180,13 +1195,14 @@ const playing = new WeakMap();
|
|
|
1180
1195
|
* nothing to re-split on a resize. Null when there is nothing to split or it is being edited: the caller plays its plain
|
|
1181
1196
|
* fade.
|
|
1182
1197
|
*/
|
|
1183
|
-
function playTextReveal(el, by, timing, look = TextRevealLook.Rise) {
|
|
1198
|
+
function playTextReveal(el, by, timing, look = TextRevealLook.Rise, stagger) {
|
|
1184
1199
|
playing.get(el)?.cancel();
|
|
1185
1200
|
const planned = splitForReveal(el, by, look);
|
|
1186
1201
|
if (!planned)
|
|
1187
1202
|
return null;
|
|
1188
1203
|
const { split, order, groups } = planned;
|
|
1189
|
-
|
|
1204
|
+
// An asked step is for the pieces it asked for: a letter step on a text that fell to words takes the words' own.
|
|
1205
|
+
const step = revealStagger(groups, planned.by, planned.by === by ? stagger : undefined);
|
|
1190
1206
|
const duration = Number(timing.duration) || DEFAULT_PIECE_MS;
|
|
1191
1207
|
const delay = timing.delay ?? 0;
|
|
1192
1208
|
const frames = look === TextRevealLook.Light ? LIGHT_FRAMES : PIECE_FRAMES;
|
|
@@ -1291,6 +1307,8 @@ const MAX_FRAME_SECONDS = 0.1;
|
|
|
1291
1307
|
const WAKING_FRAME_SECONDS = 1 / 60;
|
|
1292
1308
|
const STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\./g, '-')}, [${SceneAttribute.Stage}]`;
|
|
1293
1309
|
const TRANSFORM_WILL_CHANGE = 'transform, opacity';
|
|
1310
|
+
/** The steps of a Scene that slide over one another (a `drawers` signature): a later one covers the one before. */
|
|
1311
|
+
const STEP_SELECTOR = `.iox-role-${SceneRole.Drawer.replace(/\./g, '-')}`;
|
|
1294
1312
|
/** The class Lenis keeps on the element it scrolls only while it is SMOOTHING a scroll (a jump, the keyboard and the scroll
|
|
1295
1313
|
* bar are not smoothed): what a driver with no named scroller reads. */
|
|
1296
1314
|
const LENIS_SMOOTH_CLASS = 'lenis-smooth';
|
|
@@ -1350,6 +1368,91 @@ function sliderOf(stage) {
|
|
|
1350
1368
|
const swiper = holder?.swiper;
|
|
1351
1369
|
return swiper && typeof swiper.setProgress === 'function' && !swiper.destroyed ? swiper : null;
|
|
1352
1370
|
}
|
|
1371
|
+
/** The hold moves a layer travels by: they say where it lands. */
|
|
1372
|
+
const LANDING_PROPS = new Set([SceneProp.X, SceneProp.Y]);
|
|
1373
|
+
/**
|
|
1374
|
+
* Where a layer that travels onto the stage has LANDED, as hold progress: the last key of its hold-range X / Y move (the
|
|
1375
|
+
* later, when it has both). A layer with no such move (the first drawer, a phone's stacked panels) is on the stage from the
|
|
1376
|
+
* start: 0.
|
|
1377
|
+
*/
|
|
1378
|
+
function stepLanding(tracks) {
|
|
1379
|
+
return tracks
|
|
1380
|
+
.filter(track => LANDING_PROPS.has(track.prop) && isHoldTrack(track) && new Set(track.keys.map(([, value]) => value)).size > 1)
|
|
1381
|
+
.reduce((at, move) => Math.max(at, move.keys[move.keys.length - 1][0]), 0);
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* AW10 (award plan "drawers" row): the trigger of an entrance played when its layer LANDS — the moment the Scene's progress
|
|
1385
|
+
* reaches the last key of the layer's travel (`stepLanding`). Both interaction runtimes run it through `onSceneLand`.
|
|
1386
|
+
*/
|
|
1387
|
+
const SCENE_LAND_TRIGGER = 'sceneLand';
|
|
1388
|
+
/** Dispatched (not bubbling) on a layer as it lands. Never a DOM `scroll` (SC2). */
|
|
1389
|
+
const SCENE_LAND_EVENT = 'iox-scene-land';
|
|
1390
|
+
/** Progress short of a landing that still counts as landed: the damping settles onto the scroll, never past it. */
|
|
1391
|
+
const LANDED_SLACK = 1e-4;
|
|
1392
|
+
/** How much of an element must show before a word with no landing to wait for arrives (the runtimes' viewport entry). */
|
|
1393
|
+
const ARRIVE_THRESHOLD = 0.1;
|
|
1394
|
+
/**
|
|
1395
|
+
* Where a Scene of steps (each covering the one before once it lands) must stand for step `index` to be in FRONT, or null
|
|
1396
|
+
* when it already is — or when no step moves (nothing covers anything; a phone stacks them). Step i is in front from its
|
|
1397
|
+
* landing until the next one lands. vectoriox/iox-ui#139: focus must never sit on a covered or waiting step (WCAG 2.4.11).
|
|
1398
|
+
*/
|
|
1399
|
+
function progressShowingStep(landings, index, progress) {
|
|
1400
|
+
if (index < 0 || index >= landings.length || landings.every(at => at === 0))
|
|
1401
|
+
return null;
|
|
1402
|
+
const from = landings[index];
|
|
1403
|
+
const until = landings.slice(index + 1).find(at => at > from) ?? Infinity;
|
|
1404
|
+
return progress >= from && progress < until ? null : from;
|
|
1405
|
+
}
|
|
1406
|
+
/** Where a layer's hold tracks stand at hold progress `p`: its move in % of the stage (x of its width, unmirrored; y of its
|
|
1407
|
+
* height) and its opacity — the last hold track of each, as `sceneFrame` reads them. Other ranges do not follow the hold. */
|
|
1408
|
+
function holdLookAt(tracks, p) {
|
|
1409
|
+
const last = (prop) => [...tracks].reverse().find(t => t.prop === prop && isHoldTrack(t));
|
|
1410
|
+
const x = last(SceneProp.X);
|
|
1411
|
+
const y = last(SceneProp.Y);
|
|
1412
|
+
const opacity = last(SceneProp.Opacity);
|
|
1413
|
+
return {
|
|
1414
|
+
x: x ? trackValueAt(x, p) : 0,
|
|
1415
|
+
y: y ? trackValueAt(y, p) : 0,
|
|
1416
|
+
opacity: opacity ? Math.min(1, Math.max(0, trackValueAt(opacity, p))) : 1,
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
/** Px of rounding a box may stand past the frame and still count as inside it. */
|
|
1420
|
+
const INSIDE_SLACK = 1;
|
|
1421
|
+
/**
|
|
1422
|
+
* True when `box`, moved by `dx`/`dy`, stands inside `frame` on both axes. Along an axis on which the box is the larger,
|
|
1423
|
+
* it must cover the frame instead: as much of it as can be seen is seen.
|
|
1424
|
+
*/
|
|
1425
|
+
function boxInside(box, frame, dx = 0, dy = 0) {
|
|
1426
|
+
const along = (a, b, from, to) => (b - a <= to - from
|
|
1427
|
+
? a >= from - INSIDE_SLACK && b <= to + INSIDE_SLACK
|
|
1428
|
+
: a <= from + INSIDE_SLACK && b >= to - INSIDE_SLACK);
|
|
1429
|
+
return along(box.left + dx, box.right + dx, frame.left, frame.right) && along(box.top + dy, box.bottom + dy, frame.top, frame.bottom);
|
|
1430
|
+
}
|
|
1431
|
+
/** How finely the hold is searched for where a focused control shows: 1/400 of the travel is under a px a screen. */
|
|
1432
|
+
const SHOWING_SAMPLES = 400;
|
|
1433
|
+
/**
|
|
1434
|
+
* Where on the hold (0–1) a focused control shows, or null when it shows already at `current` — or nowhere. The nearest
|
|
1435
|
+
* moment it shows (ahead first, in reading order), then the middle of the stretch it stays showing from there: a walk's card
|
|
1436
|
+
* is brought to the middle of the screen, never left on the stage's edge. vectoriox/iox-ui#141 (WCAG 2.4.11).
|
|
1437
|
+
*/
|
|
1438
|
+
function progressShowingFocus(current, shows, samples = SHOWING_SAMPLES) {
|
|
1439
|
+
const at = Math.min(1, Math.max(0, current));
|
|
1440
|
+
if (shows(at))
|
|
1441
|
+
return null;
|
|
1442
|
+
for (let k = 1; k <= samples; k++) {
|
|
1443
|
+
for (const sign of [1, -1]) {
|
|
1444
|
+
const p = at + sign * (k / samples);
|
|
1445
|
+
if (p < 0 || p > 1 || !shows(p))
|
|
1446
|
+
continue;
|
|
1447
|
+
// The stretch it shows over, away from `current`: it ends where it stops showing (or at the hold's end).
|
|
1448
|
+
let end = p;
|
|
1449
|
+
while (end + sign / samples >= 0 && end + sign / samples <= 1 && shows(end + sign / samples))
|
|
1450
|
+
end += sign / samples;
|
|
1451
|
+
return Math.round(((p + end) / 2) * 1e6) / 1e6;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return null;
|
|
1455
|
+
}
|
|
1353
1456
|
/** One frame of the damping: frame-rate independent, so 60 Hz and 120 Hz settle in the same time. */
|
|
1354
1457
|
function dampToward(current, target, seconds, rate = SCENE_DAMPING) {
|
|
1355
1458
|
return current + (target - current) * (1 - Math.exp(-seconds * rate));
|
|
@@ -1441,6 +1544,13 @@ class ScrollDriver {
|
|
|
1441
1544
|
this.frame = 0;
|
|
1442
1545
|
this.lastTime = 0;
|
|
1443
1546
|
this.wakeUp = () => this.wake();
|
|
1547
|
+
/** Focus moving onto a control the Scene does not show now brings the scroll to where it does (#139, #141). */
|
|
1548
|
+
this.onFocusIn = (e) => {
|
|
1549
|
+
const root = e.currentTarget;
|
|
1550
|
+
const scene = this.scenes.get(root);
|
|
1551
|
+
if (scene)
|
|
1552
|
+
this.showFocused(scene, e.target);
|
|
1553
|
+
};
|
|
1444
1554
|
this.onWakeEvent = (e) => {
|
|
1445
1555
|
// What arrived may be the stage itself (a played slider marks its stage when it boots): read the root again.
|
|
1446
1556
|
const scene = [...this.scenes.values()].find(s => s.root.contains(e.target));
|
|
@@ -1522,6 +1632,9 @@ class ScrollDriver {
|
|
|
1522
1632
|
const scene = { root, stage: null, layers: [], progress: 0, target: 0, position: 0, along: 0, height: 0, travel: 0, exit: 0, stick: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
1523
1633
|
this.scenes.set(root, scene);
|
|
1524
1634
|
this.resize?.observe(root);
|
|
1635
|
+
// The canvas (it pins) is the author's: it is never scrolled for them.
|
|
1636
|
+
if (!this.options.pin)
|
|
1637
|
+
root.addEventListener('focusin', this.onFocusIn);
|
|
1525
1638
|
if (this.options.observe) {
|
|
1526
1639
|
const Observer = this.host.MutationObserver;
|
|
1527
1640
|
if (Observer) {
|
|
@@ -1543,11 +1656,13 @@ class ScrollDriver {
|
|
|
1543
1656
|
if (HELD.get(root) === this)
|
|
1544
1657
|
HELD.delete(root);
|
|
1545
1658
|
scene.mutations?.disconnect();
|
|
1659
|
+
root.removeEventListener('focusin', this.onFocusIn);
|
|
1546
1660
|
this.resize?.unobserve(root);
|
|
1547
1661
|
if (scene.stage)
|
|
1548
1662
|
scene.stage.style.removeProperty('translate');
|
|
1549
1663
|
for (const layer of scene.layers) {
|
|
1550
1664
|
layer.el.style.removeProperty('will-change');
|
|
1665
|
+
layer.el.removeAttribute(SceneAttribute.Landed);
|
|
1551
1666
|
this.restoreWords(layer);
|
|
1552
1667
|
this.stopPlayer(layer);
|
|
1553
1668
|
}
|
|
@@ -1625,6 +1740,91 @@ class ScrollDriver {
|
|
|
1625
1740
|
this.links.clear();
|
|
1626
1741
|
this.resize?.disconnect();
|
|
1627
1742
|
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Focus moved onto a control inside a Scene: the Scene is scrolled to where it shows it, and the frame lands at once.
|
|
1745
|
+
* - The browser scrolls a clipping stage to reveal a focused control it holds off view (`overflow: hidden` is
|
|
1746
|
+
* scrollable from script), and every layer would then stand shifted by that scroll until a reload. The driver alone
|
|
1747
|
+
* decides what the stage shows: the offset goes now, and again after the browser's own focus scrolling, which may
|
|
1748
|
+
* come after this event (vectoriox/iox-ui#139, #141).
|
|
1749
|
+
* - On a step another covers, or one still waiting off the stage (drawers): to where that step has landed (#139).
|
|
1750
|
+
* - Anywhere else (a card a walk has not brought in, a layer still flying in): to the nearest moment the control stands
|
|
1751
|
+
* inside the stage, its moving layers' hold tracks read at each moment (#141).
|
|
1752
|
+
* The canvas never listens (it pins: the author is never scrolled), and a phone, whose Scenes flow, is left alone.
|
|
1753
|
+
*/
|
|
1754
|
+
showFocused(scene, focused) {
|
|
1755
|
+
if (!scene.travel || !scene.stage)
|
|
1756
|
+
return;
|
|
1757
|
+
this.unscrollStage(scene.stage);
|
|
1758
|
+
this.host.requestAnimationFrame(() => this.unscrollStage(scene.stage));
|
|
1759
|
+
const rect = scene.root.getBoundingClientRect();
|
|
1760
|
+
const zoom = scene.height ? rect.height / scene.height : 1;
|
|
1761
|
+
const scrolled = (scene.stick * zoom - rect.top) / (zoom || 1);
|
|
1762
|
+
const step = this.stepShowing(scene, focused, scrolled);
|
|
1763
|
+
const at = step === undefined ? this.progressShowing(scene, focused) : step;
|
|
1764
|
+
if (at === null)
|
|
1765
|
+
return;
|
|
1766
|
+
this.host.scrollBy({ top: Math.min(scene.travel, at * scene.travel + 1) - scrolled, behavior: 'instant' });
|
|
1767
|
+
scene.fresh = true;
|
|
1768
|
+
this.wake();
|
|
1769
|
+
}
|
|
1770
|
+
/** The tracks a layer plays at the Scene's width. */
|
|
1771
|
+
tracksOf(scene, layer) {
|
|
1772
|
+
return scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Where a drawers Scene must stand for the focused control's step to be in front: null when it is, undefined when the
|
|
1776
|
+
* control is on no step (the general rule decides).
|
|
1777
|
+
*/
|
|
1778
|
+
stepShowing(scene, focused, scrolled) {
|
|
1779
|
+
const steps = Array.from(scene.stage.querySelectorAll(STEP_SELECTOR))
|
|
1780
|
+
.filter(step => step.closest(`[${SceneAttribute.Root}]`) === scene.root);
|
|
1781
|
+
const index = steps.findIndex(step => step.contains(focused));
|
|
1782
|
+
if (index < 0)
|
|
1783
|
+
return undefined;
|
|
1784
|
+
const landings = steps.map(step => {
|
|
1785
|
+
const layer = scene.layers.find(l => l.el === step);
|
|
1786
|
+
return stepLanding(layer ? this.tracksOf(scene, layer) : []);
|
|
1787
|
+
});
|
|
1788
|
+
return progressShowingStep(landings, index, scrolled / scene.travel);
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Where on the hold the focused control stands inside the stage, seen (its moving layers at least half opaque), or null
|
|
1792
|
+
* when it does already, or never does. Its box is read where it is drawn now (at the damped progress) and moved by what
|
|
1793
|
+
* its layers' hold moves would add at each other moment. Scale and rotation are not followed: a Scene moves a control
|
|
1794
|
+
* into view by travel.
|
|
1795
|
+
*/
|
|
1796
|
+
progressShowing(scene, focused) {
|
|
1797
|
+
if (scene.phone)
|
|
1798
|
+
return null;
|
|
1799
|
+
const stage = scene.stage;
|
|
1800
|
+
const moving = scene.layers.filter(layer => layer.el !== stage && layer.el.contains(focused)).map(layer => this.tracksOf(scene, layer));
|
|
1801
|
+
if (!moving.length)
|
|
1802
|
+
return null;
|
|
1803
|
+
const box = focused.getBoundingClientRect();
|
|
1804
|
+
if (!box.width && !box.height)
|
|
1805
|
+
return null;
|
|
1806
|
+
const frame = stage.getBoundingClientRect();
|
|
1807
|
+
// cqw / cqh are the stage's own px; on screen they are drawn at the stage's scale.
|
|
1808
|
+
const pxX = (frame.width || 0) / 100;
|
|
1809
|
+
const pxY = (frame.height || 0) / 100;
|
|
1810
|
+
const look = (p) => moving.reduce((sum, tracks) => {
|
|
1811
|
+
const at = holdLookAt(tracks, p);
|
|
1812
|
+
return { x: sum.x + at.x, y: sum.y + at.y, opacity: sum.opacity * at.opacity };
|
|
1813
|
+
}, { x: 0, y: 0, opacity: 1 });
|
|
1814
|
+
const now = look(scene.progress);
|
|
1815
|
+
return progressShowingFocus(scene.progress, p => {
|
|
1816
|
+
const then = look(p);
|
|
1817
|
+
return then.opacity >= 0.5 && boxInside(box, frame, (then.x - now.x) * pxX * scene.inlineSign, (then.y - now.y) * pxY);
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
unscrollStage(stage) {
|
|
1821
|
+
if (!stage)
|
|
1822
|
+
return;
|
|
1823
|
+
if (stage.scrollLeft)
|
|
1824
|
+
stage.scrollLeft = 0;
|
|
1825
|
+
if (stage.scrollTop)
|
|
1826
|
+
stage.scrollTop = 0;
|
|
1827
|
+
}
|
|
1628
1828
|
/** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */
|
|
1629
1829
|
readScene(scene) {
|
|
1630
1830
|
scene.stage = scene.root.querySelector(STAGE_SELECTOR);
|
|
@@ -1643,6 +1843,7 @@ class ScrollDriver {
|
|
|
1643
1843
|
}
|
|
1644
1844
|
letGo(layer) {
|
|
1645
1845
|
layer.el.style.removeProperty('will-change');
|
|
1846
|
+
layer.el.removeAttribute(SceneAttribute.Landed);
|
|
1646
1847
|
for (const key of Object.keys(layer.last))
|
|
1647
1848
|
layer.el.style[key] = '';
|
|
1648
1849
|
this.restoreWords(layer);
|
|
@@ -1666,6 +1867,7 @@ class ScrollDriver {
|
|
|
1666
1867
|
el, tracks, phoneTracks, last: previous?.last ?? {}, stale: true, words: previous?.words ?? null, wordsRefused: false,
|
|
1667
1868
|
player: previous?.player ?? null, playerKey: previous?.playerKey ?? '',
|
|
1668
1869
|
crosses: crossesStage(tracks) || crossesStage(phoneTracks), crossInline: previous?.crossInline ?? 0, crossBlock: previous?.crossBlock ?? 0,
|
|
1870
|
+
landing: 0, landed: previous?.landed ?? false,
|
|
1669
1871
|
};
|
|
1670
1872
|
}
|
|
1671
1873
|
remeasureAll() {
|
|
@@ -1682,8 +1884,10 @@ class ScrollDriver {
|
|
|
1682
1884
|
scene.stick = scene.stage ? (parseFloat(this.host.getComputedStyle(scene.stage).top) || 0) : 0;
|
|
1683
1885
|
scene.phone = (scene.stage?.offsetWidth ?? Infinity) <= SCENE_PHONE_MAX_WIDTH;
|
|
1684
1886
|
scene.inlineSign = scene.stage && this.host.getComputedStyle(scene.stage).direction === 'rtl' ? -1 : 1;
|
|
1685
|
-
for (const layer of scene.layers)
|
|
1887
|
+
for (const layer of scene.layers) {
|
|
1686
1888
|
layer.stale = true;
|
|
1889
|
+
layer.landing = stepLanding(this.tracksOf(scene, layer));
|
|
1890
|
+
}
|
|
1687
1891
|
}
|
|
1688
1892
|
/** True when the scroll the driver reads is being smoothed right now: it follows it (RT-D2). */
|
|
1689
1893
|
following() {
|
|
@@ -1779,7 +1983,32 @@ class ScrollDriver {
|
|
|
1779
1983
|
}
|
|
1780
1984
|
layer.last = frame;
|
|
1781
1985
|
layer.stale = false;
|
|
1986
|
+
this.writeLanded(layer, scene.progress);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* A layer that travels lands when what is on screen (the damped progress) reaches the end of its travel: it is marked,
|
|
1991
|
+
* and told once (`SCENE_LAND_EVENT`) — its words arrive then (AW10). Back before its landing it is unmarked, so a later
|
|
1992
|
+
* listener does not run for a layer the visitor scrolled back away from.
|
|
1993
|
+
*/
|
|
1994
|
+
writeLanded(layer, progress) {
|
|
1995
|
+
const landed = layer.landing > 0 && progress >= layer.landing - LANDED_SLACK;
|
|
1996
|
+
if (landed === layer.landed)
|
|
1997
|
+
return;
|
|
1998
|
+
layer.landed = landed;
|
|
1999
|
+
if (!landed) {
|
|
2000
|
+
layer.el.removeAttribute(SceneAttribute.Landed);
|
|
2001
|
+
return;
|
|
1782
2002
|
}
|
|
2003
|
+
layer.el.setAttribute(SceneAttribute.Landed, '');
|
|
2004
|
+
const Event = this.host.CustomEvent ?? CustomEvent;
|
|
2005
|
+
layer.el.dispatchEvent(new Event(SCENE_LAND_EVENT));
|
|
2006
|
+
}
|
|
2007
|
+
/** True when this driver tells `layer` it has landed: it holds its Scene and the layer travels at this width. */
|
|
2008
|
+
landsOnScroll(layer) {
|
|
2009
|
+
const root = layer.closest(`[${SceneAttribute.Root}]`);
|
|
2010
|
+
const scene = root ? this.scenes.get(root) : undefined;
|
|
2011
|
+
return !!scene?.layers.find(l => l.el === layer && l.landing > 0);
|
|
1783
2012
|
}
|
|
1784
2013
|
/**
|
|
1785
2014
|
* The picture this moment asks for. The attribute sits on the Video's own root, which is the layer on the string path
|
|
@@ -1874,6 +2103,75 @@ function attachSceneRoots(roots, options = {}) {
|
|
|
1874
2103
|
driver.destroy();
|
|
1875
2104
|
return null;
|
|
1876
2105
|
}
|
|
2106
|
+
/** The layer `el` travels onto the stage with: the nearest one (itself or above it, inside its Scene) whose wide tracks
|
|
2107
|
+
* land (`stepLanding` > 0). Null when nothing carries it in. */
|
|
2108
|
+
function travellingLayerOf(el) {
|
|
2109
|
+
for (let node = el; node; node = node.parentElement) {
|
|
2110
|
+
if (node.hasAttribute(SceneAttribute.Root))
|
|
2111
|
+
return null;
|
|
2112
|
+
if (node.hasAttribute(SceneAttribute.Tracks) && stepLanding(parseTracks(node.getAttribute(SceneAttribute.Tracks))) > 0)
|
|
2113
|
+
return node;
|
|
2114
|
+
}
|
|
2115
|
+
return null;
|
|
2116
|
+
}
|
|
2117
|
+
/** The driver that tells `layer` it has landed, at this width — null when none plays its travel (reduced motion, a phone). */
|
|
2118
|
+
function landingDriverOf(layer) {
|
|
2119
|
+
const root = layer.closest(`[${SceneAttribute.Root}]`);
|
|
2120
|
+
const driver = root ? HELD.get(root) : undefined;
|
|
2121
|
+
return driver?.landsOnScroll(layer) ? driver : null;
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Run `run` ONCE when `el`'s words are to arrive (AW10, `SCENE_LAND_TRIGGER`): as the layer that carries it onto the stage
|
|
2125
|
+
* LANDS (`SCENE_LAND_EVENT`; at once when it already has), wherever a driver plays that travel. Where none does — the layer
|
|
2126
|
+
* does not travel at this width (a phone's stacked Scene), the visitor asked for less motion (no driver; the Scene flows),
|
|
2127
|
+
* nothing carries it (the first drawer, a node outside a Scene) — it arrives as it comes into view, as a viewport entrance
|
|
2128
|
+
* does. Focus reaching it first makes it arrive at once. Both interaction runtimes call this. Returns the way to let go.
|
|
2129
|
+
*/
|
|
2130
|
+
function onSceneLand(el, run, host = window) {
|
|
2131
|
+
let done = false;
|
|
2132
|
+
const offs = [];
|
|
2133
|
+
const letGo = () => { offs.splice(0).forEach(off => off()); };
|
|
2134
|
+
const go = () => {
|
|
2135
|
+
if (done)
|
|
2136
|
+
return;
|
|
2137
|
+
done = true;
|
|
2138
|
+
letGo();
|
|
2139
|
+
run();
|
|
2140
|
+
};
|
|
2141
|
+
const layer = travellingLayerOf(el);
|
|
2142
|
+
// A keyboard that reaches it first never focuses something still waiting to arrive (WCAG 2.4.7): it arrives now.
|
|
2143
|
+
const focused = () => go();
|
|
2144
|
+
el.addEventListener('focusin', focused);
|
|
2145
|
+
offs.push(() => el.removeEventListener('focusin', focused));
|
|
2146
|
+
if (layer) {
|
|
2147
|
+
const heard = () => go();
|
|
2148
|
+
layer.addEventListener(SCENE_LAND_EVENT, heard);
|
|
2149
|
+
offs.push(() => layer.removeEventListener(SCENE_LAND_EVENT, heard));
|
|
2150
|
+
}
|
|
2151
|
+
const Observer = host.IntersectionObserver;
|
|
2152
|
+
if (Observer) {
|
|
2153
|
+
const io = new Observer(entries => {
|
|
2154
|
+
// Where a driver plays the travel it decides; the viewport only stands in where none does.
|
|
2155
|
+
if (entries.some(entry => entry.isIntersecting) && !(layer && landingDriverOf(layer)))
|
|
2156
|
+
go();
|
|
2157
|
+
}, { threshold: ARRIVE_THRESHOLD });
|
|
2158
|
+
io.observe(el);
|
|
2159
|
+
offs.push(() => io.disconnect());
|
|
2160
|
+
}
|
|
2161
|
+
else {
|
|
2162
|
+
// No observer to ask (an old browser): it stands in place on the next frame unless a driver will land it.
|
|
2163
|
+
const frame = host.requestAnimationFrame?.(() => { if (!(layer && landingDriverOf(layer)))
|
|
2164
|
+
go(); });
|
|
2165
|
+
if (frame)
|
|
2166
|
+
offs.push(() => host.cancelAnimationFrame?.(frame));
|
|
2167
|
+
}
|
|
2168
|
+
if (layer?.hasAttribute(SceneAttribute.Landed))
|
|
2169
|
+
go();
|
|
2170
|
+
return () => {
|
|
2171
|
+
done = true;
|
|
2172
|
+
letGo();
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
1877
2175
|
|
|
1878
2176
|
/**
|
|
1879
2177
|
* @vectoriox/iox-ui/scene-core — a Scene: a stage that holds still while the page scrolls past it, its layers moving on
|
|
@@ -1886,5 +2184,5 @@ function attachSceneRoots(roots, options = {}) {
|
|
|
1886
2184
|
* Generated bundle index. Do not edit.
|
|
1887
2185
|
*/
|
|
1888
2186
|
|
|
1889
|
-
export { LENIS_SMOOTH_CLASS, LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_TRACK_EASE, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneEase, SceneProp, SceneRange, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, crossesStage, crossingOf, dampToward, followToward, gentleFrames, heldProgress, isHoldTrack, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, pageScroller, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrollSubpixel, scrubPieceProgress, scrubTextReveal, setPageScroller, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, unmovedBox, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
2187
|
+
export { LENIS_SMOOTH_CLASS, LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, REVEAL_STAGGER_MAX_MS, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LAND_EVENT, SCENE_LAND_TRIGGER, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_TRACK_EASE, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneEase, SceneProp, SceneRange, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, boxInside, buildSceneRecipe, colourAt, crossesStage, crossingOf, dampToward, followToward, gentleFrames, heldProgress, holdLookAt, isHoldTrack, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, onSceneLand, outermostNodeOf, pageScroller, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, progressShowingFocus, progressShowingStep, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrollSubpixel, scrubPieceProgress, scrubTextReveal, setPageScroller, splitForReveal, splitText, stepLanding, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, textRevealStaggerOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, travellingLayerOf, unmovedBox, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
1890
2188
|
//# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map
|