@vectoriox/iox-ui 5.161.0 → 5.163.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.
Files changed (43) hide show
  1. package/actions-core/index.d.ts +171 -3
  2. package/assist-core/index.d.ts +3 -2
  3. package/composite-core/index.d.ts +185 -2
  4. package/design-core/index.d.ts +130 -0
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
  8. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +404 -163
  10. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-design-core.mjs +152 -1
  12. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +302 -10
  14. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  15. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
  16. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  17. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +306 -48
  18. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  19. package/fesm2022/vectoriox-iox-ui.mjs +383 -10
  20. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  21. package/generation-core/index.d.ts +243 -6
  22. package/harness-core/index.d.ts +132 -2
  23. package/index.d.ts +105 -3
  24. package/package.json +1 -1
  25. package/scene-core/index.d.ts +130 -10
  26. package/src/actions-core/popup-arrival.ts +328 -0
  27. package/src/actions-core/public-api.ts +1 -0
  28. package/src/assist-core/media-generate.ts +6 -5
  29. package/src/composite-core/popup.ts +285 -0
  30. package/src/composite-core/public-api.ts +1 -0
  31. package/src/design-core/flavor-spec.generated.ts +152 -1
  32. package/src/generation-core/ai-run.ts +65 -2
  33. package/src/generation-core/compose-layout.ts +11 -5
  34. package/src/generation-core/pictures.ts +4 -3
  35. package/src/generation-core/site-spec.generated.ts +235 -0
  36. package/src/harness-core/business-types.ts +2 -0
  37. package/src/harness-core/harness-spec.generated.ts +83 -0
  38. package/src/harness-core/popup-stance.ts +111 -0
  39. package/src/harness-core/public-api.ts +1 -0
  40. package/src/scene-core/scene-edit.ts +12 -8
  41. package/src/scene-core/scene.ts +131 -21
  42. package/src/scene-core/scroll-driver.ts +209 -23
  43. package/styles/iox-design.css +121 -2
@@ -42,6 +42,46 @@ var SceneRevealFrom;
42
42
  SceneRevealFrom["Start"] = "start";
43
43
  SceneRevealFrom["End"] = "end";
44
44
  })(SceneRevealFrom || (SceneRevealFrom = {}));
45
+ /**
46
+ * How a track runs between two keys (award plan "Reddottours", RT-D1). A scrubbed TRAVEL runs straight, so a layer moves
47
+ * exactly as far as the scroll moves it (theirs is `ease: none`; smoothstep slowed every walk at both ends); a FADE keeps
48
+ * smoothstep, which is what a fade looks right with. A track says its own only when it differs from its property's.
49
+ */
50
+ var SceneEase;
51
+ (function (SceneEase) {
52
+ SceneEase["Linear"] = "linear";
53
+ SceneEase["Smooth"] = "smooth";
54
+ })(SceneEase || (SceneEase = {}));
55
+ /** Each property's ease when its track says none: travel straight, fades and colours smooth. */
56
+ const SCENE_TRACK_EASE = {
57
+ [SceneProp.X]: SceneEase.Linear,
58
+ [SceneProp.Y]: SceneEase.Linear,
59
+ [SceneProp.Scale]: SceneEase.Linear,
60
+ [SceneProp.Rotate]: SceneEase.Linear,
61
+ [SceneProp.Clip]: SceneEase.Linear,
62
+ [SceneProp.Play]: SceneEase.Linear,
63
+ [SceneProp.Opacity]: SceneEase.Smooth,
64
+ [SceneProp.Words]: SceneEase.Smooth,
65
+ [SceneProp.Ground]: SceneEase.Smooth,
66
+ [SceneProp.Ink]: SceneEase.Smooth,
67
+ };
68
+ /**
69
+ * WHAT a track's 0–1 is measured over (award plan "Reddottours", AW9). A track says its own only when it is not the hold.
70
+ * - Hold: the root's held travel — the stage pinned while the page scrolls the root's extra height (every Scene so far).
71
+ * - Exit: the root's LEAVING, after the hold — from the stage's release until it has gone by its own height (their S1:
72
+ * the held film sinks at 0.4× as the next band rises).
73
+ * - Cross inline / Cross block: the layer's OWN crossing of the stage — 0 as its leading edge enters the stage's far side,
74
+ * 1 as its trailing edge leaves the near side — measured where it stands without its own move, so inside a walking row
75
+ * each picture drifts as IT crosses the screen (their S3, GSAP's `containerAnimation`). Inline follows the reading
76
+ * direction (a walk enters from the end); block enters from below.
77
+ */
78
+ var SceneRange;
79
+ (function (SceneRange) {
80
+ SceneRange["Hold"] = "hold";
81
+ SceneRange["Exit"] = "exit";
82
+ SceneRange["CrossInline"] = "cross-inline";
83
+ SceneRange["CrossBlock"] = "cross-block";
84
+ })(SceneRange || (SceneRange = {}));
45
85
  /** What a reveal opens from when nobody has said: the page's own direction of travel, upward as it scrolls. */
46
86
  const SCENE_REVEAL_DEFAULT = SceneRevealFrom.Bottom;
47
87
  var SceneAttribute;
@@ -80,6 +120,14 @@ const COLOUR = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\([\d\s.,%/]+\)|var\(--iox-[\w-]+\))
80
120
  const COLOUR_PROPS = new Set([SceneProp.Ground, SceneProp.Ink]);
81
121
  const ALL_PROPS = new Set(Object.values(SceneProp));
82
122
  const REVEAL_FROMS = new Set(Object.values(SceneRevealFrom));
123
+ const EASES = new Set(Object.values(SceneEase));
124
+ const RANGES$1 = new Set(Object.values(SceneRange));
125
+ /** How a track runs between its keys. */
126
+ const trackEase = (track) => track.ease ?? SCENE_TRACK_EASE[track.prop];
127
+ /** What a track's progress is measured over. */
128
+ const trackRange = (track) => track.range ?? SceneRange.Hold;
129
+ /** A track the hold drives (every authored track): what the timeline edits. */
130
+ const isHoldTrack = (track) => trackRange(track) === SceneRange.Hold;
83
131
  const PERCENT$1 = 100;
84
132
  const clampPercent = (v) => Math.min(PERCENT$1, Math.max(0, v));
85
133
  function validKey(key, colour) {
@@ -108,7 +156,14 @@ function normalizeTracks(tracks) {
108
156
  .sort((a, b) => a[0] - b[0]);
109
157
  if (!keys.length)
110
158
  continue;
111
- out.push(prop === SceneProp.Clip ? clipTrack(keys, track.from) : { prop, keys });
159
+ const base = prop === SceneProp.Clip ? clipTrack(keys, track.from) : { prop, keys };
160
+ // Kept only where they say something: a track at its property's ease and on the hold reads as it always did.
161
+ const { ease, range } = track;
162
+ out.push({
163
+ ...base,
164
+ ...(typeof ease === 'string' && EASES.has(ease) && ease !== SCENE_TRACK_EASE[prop] ? { ease } : {}),
165
+ ...(typeof range === 'string' && RANGES$1.has(range) && range !== SceneRange.Hold ? { range } : {}),
166
+ });
112
167
  }
113
168
  return out;
114
169
  }
@@ -136,6 +191,7 @@ function revealClipPath(showing, from = SCENE_REVEAL_DEFAULT, inlineSign = 1) {
136
191
  }
137
192
  }
138
193
  const linear = (t) => t;
194
+ const EASE_FN = { [SceneEase.Linear]: linear, [SceneEase.Smooth]: smoothstep };
139
195
  /** The two keys around `p` and how far between them it has come. */
140
196
  function span(keys, p, ease = smoothstep) {
141
197
  const at = clamp01$1(p);
@@ -152,7 +208,7 @@ function span(keys, p, ease = smoothstep) {
152
208
  const last = keys[keys.length - 1];
153
209
  return { a: last, b: last, f: 0 };
154
210
  }
155
- /** A numeric track's value at progress `p`. */
211
+ /** A numeric track's value at progress `p` (eased smoothstep unless `ease` says otherwise — `trackValueAt` reads the track's). */
156
212
  function valueAt(keys, p, ease) {
157
213
  if (!keys.length)
158
214
  return 0;
@@ -164,16 +220,40 @@ function valueAt(keys, p, ease) {
164
220
  * A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live
165
221
  * reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.
166
222
  */
167
- function colourAt(keys, p) {
223
+ function colourAt(keys, p, ease) {
168
224
  if (!keys.length)
169
225
  return '';
170
- const { a, b, f } = span(keys, p);
226
+ const { a, b, f } = span(keys, p, ease);
171
227
  if (f <= 0 || a === b)
172
228
  return String(a[1]);
173
229
  if (f >= 1)
174
230
  return String(b[1]);
175
231
  return `color-mix(in oklab, ${a[1]} ${round((1 - f) * 100)}%, ${b[1]})`;
176
232
  }
233
+ /** A numeric track's value at progress `p`, run by its own ease. */
234
+ function trackValueAt(track, p) {
235
+ return valueAt(track.keys, p, EASE_FN[trackEase(track)]);
236
+ }
237
+ /** A colour track's value at progress `p`, run by its own ease. */
238
+ function trackColourAt(track, p) {
239
+ return colourAt(track.keys, p, EASE_FN[trackEase(track)]);
240
+ }
241
+ const RANGE_KEY = {
242
+ [SceneRange.Hold]: 'hold',
243
+ [SceneRange.Exit]: 'exit',
244
+ [SceneRange.CrossInline]: 'crossInline',
245
+ [SceneRange.CrossBlock]: 'crossBlock',
246
+ };
247
+ /** Where a track stands: the progress of its own range. A bare number is the hold (and 0 on every other range). */
248
+ function trackProgress(track, p) {
249
+ if (typeof p === 'number')
250
+ return trackRange(track) === SceneRange.Hold ? p : 0;
251
+ return p[RANGE_KEY[trackRange(track)]] ?? 0;
252
+ }
253
+ /** True when a layer has a track measured over its own crossing: the driver measures where it stands. */
254
+ function crossesStage(tracks) {
255
+ return tracks.some(t => t.range === SceneRange.CrossInline || t.range === SceneRange.CrossBlock);
256
+ }
177
257
  /** What the tracks' transform-family properties rest at when a layer has no track for one. */
178
258
  const TRANSFORM_REST = { [SceneProp.X]: 0, [SceneProp.Y]: 0, [SceneProp.Scale]: 1, [SceneProp.Rotate]: 0 };
179
259
  /**
@@ -182,24 +262,36 @@ const TRANSFORM_REST = { [SceneProp.X]: 0, [SceneProp.Y]: 0, [SceneProp.Scale]:
182
262
  */
183
263
  function sceneFrame(tracks, p, options = {}) {
184
264
  const frame = {};
265
+ // Per property and range, the last track wins (as one list always read). Across ranges they compose: a hold that
266
+ // carries a layer and an exit that sinks it add their moves, and their scales and opacities multiply.
267
+ const byRange = new Map();
268
+ for (const track of tracks) {
269
+ const at = trackProgress(track, p);
270
+ const value = COLOUR_PROPS.has(track.prop) ? trackColourAt(track, at) : trackValueAt(track, at);
271
+ byRange.set(`${track.prop}|${trackRange(track)}`, { prop: track.prop, value, from: track.from });
272
+ }
185
273
  const moves = {};
186
- for (const { prop, keys, from } of tracks) {
187
- if (prop in TRANSFORM_REST)
188
- moves[prop] = valueAt(keys, p);
189
- else if (prop === SceneProp.Opacity) {
190
- const opacity = clamp01$1(valueAt(keys, p));
191
- frame.opacity = String(opacity);
192
- frame.pointerEvents = opacity > 0 ? '' : 'none';
274
+ let opacity = null;
275
+ for (const { prop, value, from } of byRange.values()) {
276
+ if (prop in TRANSFORM_REST) {
277
+ const v = Number(value);
278
+ moves[prop] = prop === SceneProp.Scale ? (moves[prop] ?? 1) * v : (moves[prop] ?? 0) + v;
193
279
  }
280
+ else if (prop === SceneProp.Opacity)
281
+ opacity = (opacity ?? 1) * clamp01$1(Number(value));
194
282
  else if (prop === SceneProp.Clip)
195
- frame.clipPath = revealClipPath(valueAt(keys, p), from ?? SceneRevealFrom.Centre, options.inlineSign ?? 1);
283
+ frame.clipPath = revealClipPath(Number(value), from ?? SceneRevealFrom.Centre, options.inlineSign ?? 1);
196
284
  else if (prop === SceneProp.Ground)
197
- frame.backgroundColor = colourAt(keys, p);
285
+ frame.backgroundColor = String(value);
198
286
  else if (prop === SceneProp.Ink)
199
- frame.color = colourAt(keys, p);
287
+ frame.color = String(value);
288
+ }
289
+ if (opacity !== null) {
290
+ frame.opacity = String(round(opacity));
291
+ frame.pointerEvents = opacity > 0 ? '' : 'none';
200
292
  }
201
293
  if (Object.keys(moves).length) {
202
- const value = (prop) => moves[prop] ?? TRANSFORM_REST[prop];
294
+ const value = (prop) => round(moves[prop] ?? TRANSFORM_REST[prop]);
203
295
  const x = round(value(SceneProp.X) * (options.inlineSign ?? 1));
204
296
  frame.transform = `translate3d(${x}cqw, ${value(SceneProp.Y)}cqh, 0) rotate(${value(SceneProp.Rotate)}deg) scale(${value(SceneProp.Scale)})`;
205
297
  }
@@ -210,15 +302,15 @@ const SCENE_WORD_DIM = 0.16;
210
302
  /** How many of a layer's words are lit at `p`, in %; null when it has no such track. */
211
303
  function sceneWordsLit(tracks, p) {
212
304
  const track = tracks.find(t => t.prop === SceneProp.Words);
213
- return track ? clampPercent(valueAt(track.keys, p)) : null;
305
+ return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
214
306
  }
215
307
  /**
216
308
  * How far a layer's pictures have played at `p`, in %; null when it has no such track. A film runs straight between its
217
- * keys, where everything else eases: eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
309
+ * keys (its property's ease): eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
218
310
  */
219
311
  function scenePlayed(tracks, p) {
220
312
  const track = tracks.find(t => t.prop === SceneProp.Play);
221
- return track ? clampPercent(valueAt(track.keys, p, linear)) : null;
313
+ return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
222
314
  }
223
315
  /** Word `index` of `count`, with `lit` % lit: words light one after the other, each easing in as the last finishes. */
224
316
  function sceneWordOpacity(index, count, lit) {
@@ -340,14 +432,16 @@ const DEF_BY_PROP = new Map(SCENE_TRACK_DEFS.map(def => [def.prop, def]));
340
432
  function sceneTrackDef(prop) {
341
433
  return DEF_BY_PROP.get(prop);
342
434
  }
343
- const trackOf = (tracks, prop) => tracks.find(t => t.prop === prop);
435
+ /** The track the timeline edits: the HOLD's (an exit or a crossing track is the composer's, kept as it is). */
436
+ const isEdited = (t, prop) => t.prop === prop && isHoldTrack(t);
437
+ const trackOf = (tracks, prop) => tracks.find(t => isEdited(t, prop));
344
438
  const samePosition = (a, b) => sceneKeyPosition(a) === sceneKeyPosition(b);
345
439
  const roundTo = (value, places = 4) => Number(value.toFixed(places));
346
440
  /** A number track's value at `p` in the author's units, or where the layer rests when it has no such track. */
347
441
  function sceneDisplayValue(tracks, prop, p) {
348
442
  const def = sceneTrackDef(prop);
349
443
  const track = trackOf(tracks, prop);
350
- return roundTo((track ? valueAt(track.keys, p) : def.rest) * def.factor, 2);
444
+ return roundTo((track ? trackValueAt(track, p) : def.rest) * def.factor, 2);
351
445
  }
352
446
  /**
353
447
  * 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
@@ -372,13 +466,15 @@ function storedValue(def, value) {
372
466
  return roundTo(Math.min(def.max, Math.max(def.min, Number(value))) / def.factor);
373
467
  }
374
468
  function replaceTrack(tracks, prop, keys) {
375
- const rest = tracks.filter(t => t.prop !== prop);
469
+ const rest = tracks.filter(t => !isEdited(t, prop));
376
470
  if (!keys.length)
377
471
  return rest;
378
- const at = tracks.findIndex(t => t.prop === prop);
472
+ const at = tracks.findIndex(t => isEdited(t, prop));
379
473
  const next = [...rest];
380
474
  const from = prop === SceneProp.Clip ? { from: tracks[at]?.from ?? SCENE_REVEAL_DEFAULT } : {};
381
- next.splice(at < 0 ? rest.length : at, 0, { prop, ...from, keys });
475
+ // Its own ease stays with it: new keys never change how the track runs between them.
476
+ const ease = tracks[at]?.ease ? { ease: tracks[at].ease } : {};
477
+ next.splice(at < 0 ? rest.length : at, 0, { prop, ...from, ...ease, keys });
382
478
  return next;
383
479
  }
384
480
  /** Where a layer's reveal opens from: its track's direction, else where a new one would open from. */
@@ -392,7 +488,7 @@ function sceneRevealFromOf(tracks) {
392
488
  function withSceneRevealFrom(tracks, from, p) {
393
489
  if (!trackOf(tracks, SceneProp.Clip))
394
490
  return [...tracks, { prop: SceneProp.Clip, from, keys: [[sceneKeyPosition(p), sceneTrackDef(SceneProp.Clip).rest]] }];
395
- return tracks.map(track => (track.prop === SceneProp.Clip ? { ...track, from } : track));
491
+ return tracks.map(track => (isEdited(track, SceneProp.Clip) ? { ...track, from } : track));
396
492
  }
397
493
  /**
398
494
  * A layer's pictures playing across the whole Scene: the start of playing them. Keys the author has set are kept, so
@@ -405,7 +501,7 @@ function withScenePlayback(tracks) {
405
501
  }
406
502
  /** Stop playing a layer's pictures. */
407
503
  function withoutScenePlayback(tracks) {
408
- return tracks.filter(track => track.prop !== SceneProp.Play);
504
+ return tracks.filter(track => !isEdited(track, SceneProp.Play));
409
505
  }
410
506
  /**
411
507
  * 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,
@@ -1173,7 +1269,11 @@ function scrubTextReveal(el, by, look = TextRevealLook.Rise, easing = 'linear')
1173
1269
  * canvas's zoom the same rectangle divides by the same zoom, and the answer is the same at any scale.
1174
1270
  *
1175
1271
  * - The value is DAMPED: the scroll stops and the page settles a moment later. This is much of the prototype's weight,
1176
- * and why this is not a CSS scroll timeline, which cannot do it.
1272
+ * and why this is not a CSS scroll timeline, which cannot do it. Smoothed ONCE (award plan "Reddottours", RT-D2): while
1273
+ * Lenis is smoothing the page's scroll, the driver FOLLOWS it with no damping of its own (`follow`) — a second damping
1274
+ * on top made every picture trail the hand — and reads it where Lenis has it, not on the whole pixel the browser keeps
1275
+ * (a film turns that pixel into a visible step, vectoriox/iox-ui#140). A scroll Lenis does not smooth (a jump, the
1276
+ * keyboard, the scroll bar) is damped as on a page the browser scrolls natively, and so is the canvas (it pins).
1177
1277
  * - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,
1178
1278
  * its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.
1179
1279
  * `translate`, not `transform`: a Stage may carry tracks of its own.
@@ -1188,6 +1288,13 @@ const MAX_FRAME_SECONDS = 0.1;
1188
1288
  const WAKING_FRAME_SECONDS = 1 / 60;
1189
1289
  const STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\./g, '-')}, [${SceneAttribute.Stage}]`;
1190
1290
  const TRANSFORM_WILL_CHANGE = 'transform, opacity';
1291
+ /** The class Lenis keeps on the element it scrolls only while it is SMOOTHING a scroll (a jump, the keyboard and the scroll
1292
+ * bar are not smoothed): what a driver with no named scroller reads. */
1293
+ const LENIS_SMOOTH_CLASS = 'lenis-smooth';
1294
+ /** The most the browser's rounding of the scroll can hide, page px; a larger gap is not rounding and is never added. */
1295
+ const MAX_SUBPIXEL = 1;
1296
+ /** A crossing that moved less than this since the last frame has stopped moving (it is a 0–1 value). */
1297
+ const CROSSING_SETTLED = 0.0001;
1191
1298
  /**
1192
1299
  * Dispatched (bubbling) by something the driver plays that arrived after the driver last looked — a Swiper booted on a
1193
1300
  * slider's stage. Never a DOM `scroll`: nothing that follows the driver may dispatch one (SC2).
@@ -1200,6 +1307,40 @@ const SCENE_WAKE_EVENT = 'iox-scene-wake';
1200
1307
  * lets it go.
1201
1308
  */
1202
1309
  const HELD = new WeakMap();
1310
+ const PAGE_SCROLLERS = new WeakMap();
1311
+ /**
1312
+ * Name (or, with null, forget) the scroller that smooths a window's DOCUMENT — the iox-ui page scroller does, when it
1313
+ * starts Lenis on the document. Every driver on that window reads it; a scroller of a wrapper is never named here.
1314
+ */
1315
+ function setPageScroller(host, scroller) {
1316
+ if (scroller)
1317
+ PAGE_SCROLLERS.set(host, scroller);
1318
+ else
1319
+ PAGE_SCROLLERS.delete(host);
1320
+ }
1321
+ /** The scroller named for a window's document, if any. */
1322
+ function pageScroller(host) {
1323
+ return PAGE_SCROLLERS.get(host) ?? null;
1324
+ }
1325
+ /**
1326
+ * Page px the scroller has the page past where the browser drew it (its whole pixel): what a driver adds back, so a film
1327
+ * never steps by the page's pixels. Read while smoothing AND after: a smoothing ends on its own unrounded value, and the
1328
+ * film rests there rather than stepping back onto the pixel. 0 with no scroller, or a gap larger than rounding makes.
1329
+ */
1330
+ function scrollSubpixel(scroller) {
1331
+ if (!scroller)
1332
+ return 0;
1333
+ const gap = scroller.scroll - scroller.actualScroll;
1334
+ return Number.isFinite(gap) && Math.abs(gap) <= MAX_SUBPIXEL ? gap : 0;
1335
+ }
1336
+ /**
1337
+ * One frame of a driver that FOLLOWS an already smoothed scroll (RT-D2): the scroll's own move since the last frame is
1338
+ * taken whole, and only a gap left from before (a damped jump the smoothing then continued) is damped away. With no gap
1339
+ * it stands exactly on the scroll; it never snaps across one.
1340
+ */
1341
+ function followToward(current, previousTarget, target, seconds, rate = SCENE_DAMPING) {
1342
+ return dampToward(current + (target - previousTarget), target, seconds, rate);
1343
+ }
1203
1344
  function sliderOf(stage) {
1204
1345
  // The stage is the runway's child: the `.swiper` itself (both engine paths), or the canvas's shell around it.
1205
1346
  const holder = (stage?.classList.contains('swiper') ? stage : stage?.querySelector('.swiper'));
@@ -1217,6 +1358,50 @@ function sceneScrollState(rootTop, originTop, zoom, travel) {
1217
1358
  const local = Math.min(travel, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
1218
1359
  return { local, progress: local / travel };
1219
1360
  }
1361
+ /** Page px a root has been scrolled past its hold's start, from 0 up to `distance` (its hold and its leaving). */
1362
+ function sceneScrollAlong(rootTop, originTop, zoom, distance) {
1363
+ if (distance <= 0)
1364
+ return 0;
1365
+ return Math.min(distance, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
1366
+ }
1367
+ /** How far through a crossing: `entered` px of `span` (the stage's size plus the layer's), clamped 0–1. */
1368
+ function crossingOf(entered, span) {
1369
+ if (!(span > 0))
1370
+ return 0;
1371
+ return Math.round(Math.min(1, Math.max(0, entered / span)) * 10000) / 10000;
1372
+ }
1373
+ /**
1374
+ * An element's box on screen without its OWN transform: the box of the nearest ancestor that draws one (it carries every
1375
+ * move above it, a walking row's included — a host the component path renders with `display: contents` draws none) plus
1376
+ * where the layout places the element inside it. Null when its place cannot be read (no such ancestor, not laid out).
1377
+ */
1378
+ function unmovedBox(el) {
1379
+ let holder = el.parentElement;
1380
+ while (holder && holder.getClientRects().length === 0)
1381
+ holder = holder.parentElement;
1382
+ if (!holder)
1383
+ return null;
1384
+ const outer = holder.getBoundingClientRect();
1385
+ const zoom = holder.offsetWidth > 0 && outer.width > 0 ? outer.width / holder.offsetWidth : 1;
1386
+ let x;
1387
+ let y;
1388
+ if (el.offsetParent === holder) {
1389
+ x = el.offsetLeft + holder.clientLeft;
1390
+ y = el.offsetTop + holder.clientTop;
1391
+ }
1392
+ else if (el.offsetParent && el.offsetParent === holder.offsetParent) {
1393
+ x = el.offsetLeft - holder.offsetLeft;
1394
+ y = el.offsetTop - holder.offsetTop;
1395
+ }
1396
+ else {
1397
+ return null;
1398
+ }
1399
+ const left = outer.left + x * zoom;
1400
+ const top = outer.top + y * zoom;
1401
+ const width = el.offsetWidth * zoom;
1402
+ const height = el.offsetHeight * zoom;
1403
+ return { left, top, right: left + width, bottom: top + height, width, height };
1404
+ }
1220
1405
  /**
1221
1406
  * Where an element's LAYOUT box stands on screen: its offsets up to the nearest box that has no offset parent, placed by
1222
1407
  * that box's own rectangle. Transforms on the element itself are not in it — a layer that glides is measured where it
@@ -1263,17 +1448,35 @@ class ScrollDriver {
1263
1448
  this.frame = 0;
1264
1449
  const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;
1265
1450
  this.lastTime = now;
1266
- const reads = [...this.scenes.values()].map(scene => this.read(scene));
1451
+ const follow = this.following();
1452
+ // Where the page's scroller has the page beyond the browser's whole pixel: read with it, so a film does not step by
1453
+ // pixels. Not when the host says outright how to follow (`follow`): it reads its own scroll.
1454
+ const subpixel = this.options.follow === undefined ? scrollSubpixel(this.scroller()) : 0;
1455
+ const reads = [...this.scenes.values()].map(scene => this.read(scene, subpixel));
1456
+ // Each layer that moves over its own crossing is read with the rest, before any write: where its row stood after the
1457
+ // last frame. A row that moved since is read again on the next frame, so the crossing lands where the row lands.
1458
+ const crossed = reads.map(({ scene }) => this.readCrossings(scene)).some(Boolean);
1267
1459
  const view = this.links.size ? this.viewBox() : null;
1268
- const linkReads = [...this.links].map(state => this.readLink(state, view));
1269
- let moving = false;
1270
- for (const { scene, local, target } of reads) {
1460
+ const linkReads = [...this.links].map(state => this.readLink(state, view, subpixel));
1461
+ let moving = crossed;
1462
+ for (const { scene, local, along } of reads) {
1271
1463
  if (this.options.pin && scene.stage)
1272
1464
  scene.stage.style.setProperty('translate', `0 ${local}px`);
1273
- const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);
1274
- // The step onto the scroll is what is left: taken once it is under SETTLED_PX, so it never shows.
1275
- const settled = scene.fresh || Math.abs(target - scene.progress) * Math.max(1, scene.travel) < SETTLED_PX;
1276
- scene.progress = settled ? target : next;
1465
+ const next = scene.fresh ? along
1466
+ : follow ? followToward(scene.position, scene.along, along, seconds, this.options.damping)
1467
+ : dampToward(scene.position, along, seconds, this.options.damping);
1468
+ // The step onto the scroll is what is left: taken once it is under SETTLED_PX, so it never shows. Following, what
1469
+ // is left is the gap from before (the scroll's own move is taken whole).
1470
+ const gap = follow ? scene.along - scene.position : along - scene.position;
1471
+ const settled = scene.fresh || Math.abs(gap) < SETTLED_PX;
1472
+ const before = scene.position;
1473
+ scene.position = settled ? along : next;
1474
+ scene.along = along;
1475
+ // A crossing was read before this frame moved its row: it is read again on the next frame, after the move.
1476
+ if (scene.position !== before && scene.layers.some(layer => layer.crosses))
1477
+ moving = true;
1478
+ const target = scene.travel > 0 ? local / scene.travel : 0;
1479
+ scene.progress = scene.travel > 0 ? Math.min(scene.travel, scene.position) / scene.travel : 0;
1277
1480
  scene.target = target;
1278
1481
  scene.fresh = false;
1279
1482
  this.write(scene);
@@ -1282,8 +1485,11 @@ class ScrollDriver {
1282
1485
  }
1283
1486
  for (const { state, target } of linkReads) {
1284
1487
  const immediate = state.fresh || !!state.link.immediate;
1285
- const next = immediate ? target : dampToward(state.progress, target, seconds, this.options.damping);
1286
- const settled = immediate || Math.abs(target - state.progress) * Math.max(1, state.geometry.distance) < SETTLED_PX;
1488
+ const next = immediate ? target
1489
+ : follow ? followToward(state.progress, state.target, target, seconds, this.options.damping)
1490
+ : dampToward(state.progress, target, seconds, this.options.damping);
1491
+ const gap = follow ? state.target - state.progress : target - state.progress;
1492
+ const settled = immediate || Math.abs(gap) * Math.max(1, state.geometry.distance) < SETTLED_PX;
1287
1493
  state.progress = settled ? target : next;
1288
1494
  state.target = target;
1289
1495
  state.fresh = false;
@@ -1310,7 +1516,7 @@ class ScrollDriver {
1310
1516
  return false;
1311
1517
  this.remove(root);
1312
1518
  HELD.set(root, this);
1313
- const scene = { root, stage: null, layers: [], progress: 0, target: 0, height: 0, travel: 0, stick: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
1519
+ 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 };
1314
1520
  this.scenes.set(root, scene);
1315
1521
  this.resize?.observe(root);
1316
1522
  if (this.options.observe) {
@@ -1451,7 +1657,13 @@ class ScrollDriver {
1451
1657
  readLayer(el, scene) {
1452
1658
  const previous = scene.layers.find(layer => layer.el === el);
1453
1659
  el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);
1454
- return { el, tracks: parseTracks(el.getAttribute(SceneAttribute.Tracks)), phoneTracks: parseTracks(el.getAttribute(SceneAttribute.PhoneTracks)), last: previous?.last ?? {}, stale: true, words: previous?.words ?? null, wordsRefused: false, player: previous?.player ?? null, playerKey: previous?.playerKey ?? '' };
1660
+ const tracks = parseTracks(el.getAttribute(SceneAttribute.Tracks));
1661
+ const phoneTracks = parseTracks(el.getAttribute(SceneAttribute.PhoneTracks));
1662
+ return {
1663
+ el, tracks, phoneTracks, last: previous?.last ?? {}, stale: true, words: previous?.words ?? null, wordsRefused: false,
1664
+ player: previous?.player ?? null, playerKey: previous?.playerKey ?? '',
1665
+ crosses: crossesStage(tracks) || crossesStage(phoneTracks), crossInline: previous?.crossInline ?? 0, crossBlock: previous?.crossBlock ?? 0,
1666
+ };
1455
1667
  }
1456
1668
  remeasureAll() {
1457
1669
  for (const scene of this.scenes.values())
@@ -1461,6 +1673,7 @@ class ScrollDriver {
1461
1673
  measure(scene) {
1462
1674
  scene.height = scene.root.offsetHeight;
1463
1675
  scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));
1676
+ scene.exit = scene.stage?.offsetHeight ?? 0;
1464
1677
  // Where the stage holds: its sticky top (a played slider holds mid-screen; a Scene's stage at 0). Read when
1465
1678
  // something resizes, never per frame.
1466
1679
  scene.stick = scene.stage ? (parseFloat(this.host.getComputedStyle(scene.stage).top) || 0) : 0;
@@ -1469,12 +1682,54 @@ class ScrollDriver {
1469
1682
  for (const layer of scene.layers)
1470
1683
  layer.stale = true;
1471
1684
  }
1685
+ /** True when the scroll the driver reads is being smoothed right now: it follows it (RT-D2). */
1686
+ following() {
1687
+ const follow = this.options.follow;
1688
+ if (typeof follow === 'function')
1689
+ return follow();
1690
+ if (typeof follow === 'boolean')
1691
+ return follow;
1692
+ if (this.options.pin)
1693
+ return false;
1694
+ const scroller = this.scroller();
1695
+ return scroller ? scroller.isSmooth : !!this.host.document?.documentElement?.classList.contains(LENIS_SMOOTH_CLASS);
1696
+ }
1697
+ scroller() {
1698
+ return this.options.pin ? null : pageScroller(this.host);
1699
+ }
1700
+ /**
1701
+ * Where each crossing layer of a Scene stands in its crossing of the stage. Its box is read WITHOUT its own move (its
1702
+ * parent's box, which carries a walking row's move, plus its offset in it), so what it is moved by never feeds back into
1703
+ * how far it is moved. True when any of them moved since the last frame.
1704
+ */
1705
+ readCrossings(scene) {
1706
+ const crossing = scene.layers.filter(layer => layer.crosses);
1707
+ if (!crossing.length)
1708
+ return false;
1709
+ const stage = (scene.stage ?? scene.root).getBoundingClientRect();
1710
+ let moved = false;
1711
+ for (const layer of crossing) {
1712
+ const box = unmovedBox(layer.el);
1713
+ if (!box)
1714
+ continue;
1715
+ const inline = scene.inlineSign === 1
1716
+ ? crossingOf(stage.right - box.left, stage.width + box.width)
1717
+ : crossingOf(box.right - stage.left, stage.width + box.width);
1718
+ const block = crossingOf(stage.bottom - box.top, stage.height + box.height);
1719
+ moved = moved || Math.abs(inline - layer.crossInline) > CROSSING_SETTLED || Math.abs(block - layer.crossBlock) > CROSSING_SETTLED;
1720
+ layer.crossInline = inline;
1721
+ layer.crossBlock = block;
1722
+ }
1723
+ return moved;
1724
+ }
1472
1725
  /** The part of the page on screen: the host's own, or the window. */
1473
1726
  viewBox() {
1474
1727
  return this.options.view?.() ?? { top: 0, height: this.host.innerHeight };
1475
1728
  }
1476
- readLink(state, view) {
1477
- const { box, zoom } = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
1729
+ readLink(state, view, subpixel = 0) {
1730
+ const measured = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
1731
+ const zoom = measured.zoom;
1732
+ const box = subpixel ? { top: measured.box.top - subpixel, height: measured.box.height } : measured.box;
1478
1733
  const z = zoom || 1;
1479
1734
  const target = rangeProgress(state.link.range, box, view);
1480
1735
  state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z, opening: this.openingOf(state.link, box, view) };
@@ -1490,23 +1745,26 @@ class ScrollDriver {
1490
1745
  const top = page.getBoundingClientRect().top;
1491
1746
  return rangeProgress(link.range, { top: view.top + (box.top - top), height: box.height }, view);
1492
1747
  }
1493
- read(scene) {
1494
- const rect = scene.root.getBoundingClientRect();
1748
+ read(scene, subpixel = 0) {
1749
+ const box = scene.root.getBoundingClientRect();
1750
+ const rect = { top: box.top - subpixel, height: box.height };
1495
1751
  const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
1496
1752
  const zoom = scene.height ? rect.height / scene.height : 1;
1497
- const { local, progress } = sceneScrollState(rect.top, origin + scene.stick * zoom, zoom, scene.travel);
1498
- return { scene, local, target: progress };
1753
+ const { local } = sceneScrollState(rect.top, origin + scene.stick * zoom, zoom, scene.travel);
1754
+ return { scene, local, along: sceneScrollAlong(rect.top, origin + scene.stick * zoom, zoom, scene.travel + scene.exit) };
1499
1755
  }
1500
1756
  write(scene) {
1501
1757
  // A slider the scroll plays (M4): the damped moment, held on each picture.
1502
1758
  const slider = sliderOf(scene.stage);
1503
1759
  if (slider)
1504
1760
  slider.setProgress(heldProgress(scene.progress, slider.slides?.length ?? 0), 0);
1761
+ const exit = scene.exit > 0 ? Math.min(1, Math.max(0, (scene.position - scene.travel) / scene.exit)) : 0;
1505
1762
  for (const layer of scene.layers) {
1506
1763
  const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;
1507
- this.writeWords(layer, sceneWordsLit(tracks, scene.progress));
1508
- this.writePlayed(layer, scene, scenePlayed(tracks, scene.progress));
1509
- const frame = sceneFrame(tracks, scene.progress, { inlineSign: scene.inlineSign });
1764
+ const at = { hold: scene.progress, exit, crossInline: layer.crossInline, crossBlock: layer.crossBlock };
1765
+ this.writeWords(layer, sceneWordsLit(tracks, at));
1766
+ this.writePlayed(layer, scene, scenePlayed(tracks, at));
1767
+ const frame = sceneFrame(tracks, at, { inlineSign: scene.inlineSign });
1510
1768
  for (const key of Object.keys(frame)) {
1511
1769
  if (layer.stale || frame[key] !== layer.last[key])
1512
1770
  layer.el.style[key] = frame[key] ?? '';
@@ -1625,5 +1883,5 @@ function attachSceneRoots(roots, options = {}) {
1625
1883
  * Generated bundle index. Do not edit.
1626
1884
  */
1627
1885
 
1628
- export { 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_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, gentleFrames, heldProgress, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, 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, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrubPieceProgress, scrubTextReveal, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
1886
+ 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 };
1629
1887
  //# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map