@vectoriox/iox-ui 5.160.0 → 5.162.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.
@@ -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,10 @@ 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): when
1273
+ * the page itself scrolls through Lenis its scroll is already smoothed, so the driver FOLLOWS it with no damping of
1274
+ * its own (`follow`) — a second damping on top made every picture trail the hand. The canvas (its Lenis scrolls a
1275
+ * wrapper the driver pins against) and a page the browser scrolls natively keep the driver's damping.
1177
1276
  * - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,
1178
1277
  * its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.
1179
1278
  * `translate`, not `transform`: a Stage may carry tracks of its own.
@@ -1188,6 +1287,10 @@ const MAX_FRAME_SECONDS = 0.1;
1188
1287
  const WAKING_FRAME_SECONDS = 1 / 60;
1189
1288
  const STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\./g, '-')}, [${SceneAttribute.Stage}]`;
1190
1289
  const TRANSFORM_WILL_CHANGE = 'transform, opacity';
1290
+ /** The class Lenis keeps on the element it scrolls (the document's root, on the live site) for as long as it runs. */
1291
+ const LENIS_ROOT_CLASS = 'lenis';
1292
+ /** A crossing that moved less than this since the last frame has stopped moving (it is a 0–1 value). */
1293
+ const CROSSING_SETTLED = 0.0001;
1191
1294
  /**
1192
1295
  * Dispatched (bubbling) by something the driver plays that arrived after the driver last looked — a Swiper booted on a
1193
1296
  * slider's stage. Never a DOM `scroll`: nothing that follows the driver may dispatch one (SC2).
@@ -1217,6 +1320,50 @@ function sceneScrollState(rootTop, originTop, zoom, travel) {
1217
1320
  const local = Math.min(travel, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
1218
1321
  return { local, progress: local / travel };
1219
1322
  }
1323
+ /** Page px a root has been scrolled past its hold's start, from 0 up to `distance` (its hold and its leaving). */
1324
+ function sceneScrollAlong(rootTop, originTop, zoom, distance) {
1325
+ if (distance <= 0)
1326
+ return 0;
1327
+ return Math.min(distance, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
1328
+ }
1329
+ /** How far through a crossing: `entered` px of `span` (the stage's size plus the layer's), clamped 0–1. */
1330
+ function crossingOf(entered, span) {
1331
+ if (!(span > 0))
1332
+ return 0;
1333
+ return Math.round(Math.min(1, Math.max(0, entered / span)) * 10000) / 10000;
1334
+ }
1335
+ /**
1336
+ * An element's box on screen without its OWN transform: the box of the nearest ancestor that draws one (it carries every
1337
+ * move above it, a walking row's included — a host the component path renders with `display: contents` draws none) plus
1338
+ * where the layout places the element inside it. Null when its place cannot be read (no such ancestor, not laid out).
1339
+ */
1340
+ function unmovedBox(el) {
1341
+ let holder = el.parentElement;
1342
+ while (holder && holder.getClientRects().length === 0)
1343
+ holder = holder.parentElement;
1344
+ if (!holder)
1345
+ return null;
1346
+ const outer = holder.getBoundingClientRect();
1347
+ const zoom = holder.offsetWidth > 0 && outer.width > 0 ? outer.width / holder.offsetWidth : 1;
1348
+ let x;
1349
+ let y;
1350
+ if (el.offsetParent === holder) {
1351
+ x = el.offsetLeft + holder.clientLeft;
1352
+ y = el.offsetTop + holder.clientTop;
1353
+ }
1354
+ else if (el.offsetParent && el.offsetParent === holder.offsetParent) {
1355
+ x = el.offsetLeft - holder.offsetLeft;
1356
+ y = el.offsetTop - holder.offsetTop;
1357
+ }
1358
+ else {
1359
+ return null;
1360
+ }
1361
+ const left = outer.left + x * zoom;
1362
+ const top = outer.top + y * zoom;
1363
+ const width = el.offsetWidth * zoom;
1364
+ const height = el.offsetHeight * zoom;
1365
+ return { left, top, right: left + width, bottom: top + height, width, height };
1366
+ }
1220
1367
  /**
1221
1368
  * Where an element's LAYOUT box stands on screen: its offsets up to the nearest box that has no offset parent, placed by
1222
1369
  * that box's own rectangle. Transforms on the element itself are not in it — a layer that glides is measured where it
@@ -1263,17 +1410,28 @@ class ScrollDriver {
1263
1410
  this.frame = 0;
1264
1411
  const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;
1265
1412
  this.lastTime = now;
1413
+ const follow = this.following();
1266
1414
  const reads = [...this.scenes.values()].map(scene => this.read(scene));
1415
+ // Each layer that moves over its own crossing is read with the rest, before any write: where its row stood after the
1416
+ // last frame. A row that moved since is read again on the next frame, so the crossing lands where the row lands.
1417
+ const crossed = reads.map(({ scene }) => this.readCrossings(scene)).some(Boolean);
1267
1418
  const view = this.links.size ? this.viewBox() : null;
1268
1419
  const linkReads = [...this.links].map(state => this.readLink(state, view));
1269
- let moving = false;
1270
- for (const { scene, local, target } of reads) {
1420
+ let moving = crossed;
1421
+ for (const { scene, local, along } of reads) {
1271
1422
  if (this.options.pin && scene.stage)
1272
1423
  scene.stage.style.setProperty('translate', `0 ${local}px`);
1273
- const next = scene.fresh ? target : dampToward(scene.progress, target, seconds, this.options.damping);
1424
+ const immediate = scene.fresh || follow;
1425
+ const next = immediate ? along : dampToward(scene.position, along, seconds, this.options.damping);
1274
1426
  // 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;
1427
+ const settled = immediate || Math.abs(along - scene.position) < SETTLED_PX;
1428
+ const before = scene.position;
1429
+ scene.position = settled ? along : next;
1430
+ // A crossing was read before this frame moved its row: it is read again on the next frame, after the move.
1431
+ if (scene.position !== before && scene.layers.some(layer => layer.crosses))
1432
+ moving = true;
1433
+ const target = scene.travel > 0 ? local / scene.travel : 0;
1434
+ scene.progress = scene.travel > 0 ? Math.min(scene.travel, scene.position) / scene.travel : 0;
1277
1435
  scene.target = target;
1278
1436
  scene.fresh = false;
1279
1437
  this.write(scene);
@@ -1281,7 +1439,7 @@ class ScrollDriver {
1281
1439
  moving = moving || !settled;
1282
1440
  }
1283
1441
  for (const { state, target } of linkReads) {
1284
- const immediate = state.fresh || !!state.link.immediate;
1442
+ const immediate = state.fresh || !!state.link.immediate || follow;
1285
1443
  const next = immediate ? target : dampToward(state.progress, target, seconds, this.options.damping);
1286
1444
  const settled = immediate || Math.abs(target - state.progress) * Math.max(1, state.geometry.distance) < SETTLED_PX;
1287
1445
  state.progress = settled ? target : next;
@@ -1310,7 +1468,7 @@ class ScrollDriver {
1310
1468
  return false;
1311
1469
  this.remove(root);
1312
1470
  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 };
1471
+ const scene = { root, stage: null, layers: [], progress: 0, target: 0, position: 0, height: 0, travel: 0, exit: 0, stick: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
1314
1472
  this.scenes.set(root, scene);
1315
1473
  this.resize?.observe(root);
1316
1474
  if (this.options.observe) {
@@ -1451,7 +1609,13 @@ class ScrollDriver {
1451
1609
  readLayer(el, scene) {
1452
1610
  const previous = scene.layers.find(layer => layer.el === el);
1453
1611
  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 ?? '' };
1612
+ const tracks = parseTracks(el.getAttribute(SceneAttribute.Tracks));
1613
+ const phoneTracks = parseTracks(el.getAttribute(SceneAttribute.PhoneTracks));
1614
+ return {
1615
+ el, tracks, phoneTracks, last: previous?.last ?? {}, stale: true, words: previous?.words ?? null, wordsRefused: false,
1616
+ player: previous?.player ?? null, playerKey: previous?.playerKey ?? '',
1617
+ crosses: crossesStage(tracks) || crossesStage(phoneTracks), crossInline: previous?.crossInline ?? 0, crossBlock: previous?.crossBlock ?? 0,
1618
+ };
1455
1619
  }
1456
1620
  remeasureAll() {
1457
1621
  for (const scene of this.scenes.values())
@@ -1461,6 +1625,7 @@ class ScrollDriver {
1461
1625
  measure(scene) {
1462
1626
  scene.height = scene.root.offsetHeight;
1463
1627
  scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));
1628
+ scene.exit = scene.stage?.offsetHeight ?? 0;
1464
1629
  // Where the stage holds: its sticky top (a played slider holds mid-screen; a Scene's stage at 0). Read when
1465
1630
  // something resizes, never per frame.
1466
1631
  scene.stick = scene.stage ? (parseFloat(this.host.getComputedStyle(scene.stage).top) || 0) : 0;
@@ -1469,6 +1634,40 @@ class ScrollDriver {
1469
1634
  for (const layer of scene.layers)
1470
1635
  layer.stale = true;
1471
1636
  }
1637
+ /** True when the scroll the driver reads is already smoothed: it follows it exactly (RT-D2). */
1638
+ following() {
1639
+ const follow = this.options.follow;
1640
+ if (typeof follow === 'function')
1641
+ return follow();
1642
+ if (typeof follow === 'boolean')
1643
+ return follow;
1644
+ return !this.options.pin && !!this.host.document?.documentElement?.classList.contains(LENIS_ROOT_CLASS);
1645
+ }
1646
+ /**
1647
+ * Where each crossing layer of a Scene stands in its crossing of the stage. Its box is read WITHOUT its own move (its
1648
+ * 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
1649
+ * how far it is moved. True when any of them moved since the last frame.
1650
+ */
1651
+ readCrossings(scene) {
1652
+ const crossing = scene.layers.filter(layer => layer.crosses);
1653
+ if (!crossing.length)
1654
+ return false;
1655
+ const stage = (scene.stage ?? scene.root).getBoundingClientRect();
1656
+ let moved = false;
1657
+ for (const layer of crossing) {
1658
+ const box = unmovedBox(layer.el);
1659
+ if (!box)
1660
+ continue;
1661
+ const inline = scene.inlineSign === 1
1662
+ ? crossingOf(stage.right - box.left, stage.width + box.width)
1663
+ : crossingOf(box.right - stage.left, stage.width + box.width);
1664
+ const block = crossingOf(stage.bottom - box.top, stage.height + box.height);
1665
+ moved = moved || Math.abs(inline - layer.crossInline) > CROSSING_SETTLED || Math.abs(block - layer.crossBlock) > CROSSING_SETTLED;
1666
+ layer.crossInline = inline;
1667
+ layer.crossBlock = block;
1668
+ }
1669
+ return moved;
1670
+ }
1472
1671
  /** The part of the page on screen: the host's own, or the window. */
1473
1672
  viewBox() {
1474
1673
  return this.options.view?.() ?? { top: 0, height: this.host.innerHeight };
@@ -1494,19 +1693,21 @@ class ScrollDriver {
1494
1693
  const rect = scene.root.getBoundingClientRect();
1495
1694
  const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
1496
1695
  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 };
1696
+ const { local } = sceneScrollState(rect.top, origin + scene.stick * zoom, zoom, scene.travel);
1697
+ return { scene, local, along: sceneScrollAlong(rect.top, origin + scene.stick * zoom, zoom, scene.travel + scene.exit) };
1499
1698
  }
1500
1699
  write(scene) {
1501
1700
  // A slider the scroll plays (M4): the damped moment, held on each picture.
1502
1701
  const slider = sliderOf(scene.stage);
1503
1702
  if (slider)
1504
1703
  slider.setProgress(heldProgress(scene.progress, slider.slides?.length ?? 0), 0);
1704
+ const exit = scene.exit > 0 ? Math.min(1, Math.max(0, (scene.position - scene.travel) / scene.exit)) : 0;
1505
1705
  for (const layer of scene.layers) {
1506
1706
  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 });
1707
+ const at = { hold: scene.progress, exit, crossInline: layer.crossInline, crossBlock: layer.crossBlock };
1708
+ this.writeWords(layer, sceneWordsLit(tracks, at));
1709
+ this.writePlayed(layer, scene, scenePlayed(tracks, at));
1710
+ const frame = sceneFrame(tracks, at, { inlineSign: scene.inlineSign });
1510
1711
  for (const key of Object.keys(frame)) {
1511
1712
  if (layer.stale || frame[key] !== layer.last[key])
1512
1713
  layer.el.style[key] = frame[key] ?? '';
@@ -1625,5 +1826,5 @@ function attachSceneRoots(roots, options = {}) {
1625
1826
  * Generated bundle index. Do not edit.
1626
1827
  */
1627
1828
 
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 };
1829
+ export { LENIS_ROOT_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, gentleFrames, heldProgress, isHoldTrack, 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, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrubPieceProgress, scrubTextReveal, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, unmovedBox, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
1629
1830
  //# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map