@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.
- package/actions-core/index.d.ts +171 -3
- package/assist-core/index.d.ts +3 -2
- package/composite-core/index.d.ts +185 -2
- package/design-core/index.d.ts +130 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +404 -163
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +152 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +302 -10
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +306 -48
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +383 -10
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +243 -6
- package/harness-core/index.d.ts +132 -2
- package/index.d.ts +105 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +130 -10
- package/src/actions-core/popup-arrival.ts +328 -0
- package/src/actions-core/public-api.ts +1 -0
- package/src/assist-core/media-generate.ts +6 -5
- package/src/composite-core/popup.ts +285 -0
- package/src/composite-core/public-api.ts +1 -0
- package/src/design-core/flavor-spec.generated.ts +152 -1
- package/src/generation-core/ai-run.ts +65 -2
- package/src/generation-core/compose-layout.ts +11 -5
- package/src/generation-core/pictures.ts +4 -3
- package/src/generation-core/site-spec.generated.ts +235 -0
- package/src/harness-core/business-types.ts +2 -0
- package/src/harness-core/harness-spec.generated.ts +83 -0
- package/src/harness-core/popup-stance.ts +111 -0
- package/src/harness-core/public-api.ts +1 -0
- package/src/scene-core/scene-edit.ts +12 -8
- package/src/scene-core/scene.ts +131 -21
- package/src/scene-core/scroll-driver.ts +209 -23
- package/styles/iox-design.css +121 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SceneRole } from '@vectoriox/iox-ui/composite-core';
|
|
2
2
|
import { FramePlayer, normalizeFrameSequence, VideoAttribute } from '@vectoriox/iox-ui/media-core';
|
|
3
3
|
|
|
4
|
-
import { heldProgress, normalizeTracks, SCENE_PHONE_MAX_WIDTH, SceneAttribute, sceneFrame, SceneFrame, scenePlayed, sceneWordOpacity, sceneWordsLit, SceneTrack } from './scene';
|
|
4
|
+
import { crossesStage, heldProgress, normalizeTracks, SCENE_PHONE_MAX_WIDTH, SceneAttribute, sceneFrame, SceneFrame, scenePlayed, SceneProgress, sceneWordOpacity, sceneWordsLit, SceneTrack } from './scene';
|
|
5
5
|
import { rangeDistance, rangeProgress, ScrollBox, ScrollRange } from './scroll-range';
|
|
6
6
|
import { LIGHT_UP_PIECE_CAP, SplitText, splitText } from './split-text';
|
|
7
7
|
|
|
@@ -11,7 +11,11 @@ import { LIGHT_UP_PIECE_CAP, SplitText, splitText } from './split-text';
|
|
|
11
11
|
* canvas's zoom the same rectangle divides by the same zoom, and the answer is the same at any scale.
|
|
12
12
|
*
|
|
13
13
|
* - The value is DAMPED: the scroll stops and the page settles a moment later. This is much of the prototype's weight,
|
|
14
|
-
* and why this is not a CSS scroll timeline, which cannot do it.
|
|
14
|
+
* and why this is not a CSS scroll timeline, which cannot do it. Smoothed ONCE (award plan "Reddottours", RT-D2): while
|
|
15
|
+
* Lenis is smoothing the page's scroll, the driver FOLLOWS it with no damping of its own (`follow`) — a second damping
|
|
16
|
+
* on top made every picture trail the hand — and reads it where Lenis has it, not on the whole pixel the browser keeps
|
|
17
|
+
* (a film turns that pixel into a visible step, vectoriox/iox-ui#140). A scroll Lenis does not smooth (a jump, the
|
|
18
|
+
* keyboard, the scroll bar) is damped as on a page the browser scrolls natively, and so is the canvas (it pins).
|
|
15
19
|
* - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,
|
|
16
20
|
* its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.
|
|
17
21
|
* `translate`, not `transform`: a Stage may carry tracks of its own.
|
|
@@ -27,6 +31,13 @@ const MAX_FRAME_SECONDS = 0.1;
|
|
|
27
31
|
const WAKING_FRAME_SECONDS = 1 / 60;
|
|
28
32
|
const STAGE_SELECTOR = `.iox-role-${SceneRole.Stage.replace(/\./g, '-')}, [${SceneAttribute.Stage}]`;
|
|
29
33
|
const TRANSFORM_WILL_CHANGE = 'transform, opacity';
|
|
34
|
+
/** The class Lenis keeps on the element it scrolls only while it is SMOOTHING a scroll (a jump, the keyboard and the scroll
|
|
35
|
+
* bar are not smoothed): what a driver with no named scroller reads. */
|
|
36
|
+
export const LENIS_SMOOTH_CLASS = 'lenis-smooth';
|
|
37
|
+
/** The most the browser's rounding of the scroll can hide, page px; a larger gap is not rounding and is never added. */
|
|
38
|
+
const MAX_SUBPIXEL = 1;
|
|
39
|
+
/** A crossing that moved less than this since the last frame has stopped moving (it is a 0–1 value). */
|
|
40
|
+
const CROSSING_SETTLED = 0.0001;
|
|
30
41
|
|
|
31
42
|
/**
|
|
32
43
|
* Dispatched (bubbling) by something the driver plays that arrived after the driver last looked — a Swiper booted on a
|
|
@@ -42,6 +53,52 @@ export const SCENE_WAKE_EVENT = 'iox-scene-wake';
|
|
|
42
53
|
*/
|
|
43
54
|
const HELD = new WeakMap<HTMLElement, ScrollDriver>();
|
|
44
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The page's smooth scroller as the driver reads it — a Lenis instance is one as it is: whether it is smoothing a scroll
|
|
58
|
+
* right now, where it has the page (`scroll`, unrounded) and where the browser drew it (`actualScroll`, on a whole pixel).
|
|
59
|
+
*/
|
|
60
|
+
export interface SmoothScroller {
|
|
61
|
+
readonly isSmooth: boolean;
|
|
62
|
+
readonly scroll: number;
|
|
63
|
+
readonly actualScroll: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const PAGE_SCROLLERS = new WeakMap<Window, SmoothScroller>();
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Name (or, with null, forget) the scroller that smooths a window's DOCUMENT — the iox-ui page scroller does, when it
|
|
70
|
+
* starts Lenis on the document. Every driver on that window reads it; a scroller of a wrapper is never named here.
|
|
71
|
+
*/
|
|
72
|
+
export function setPageScroller(host: Window, scroller: SmoothScroller | null): void {
|
|
73
|
+
if (scroller) PAGE_SCROLLERS.set(host, scroller);
|
|
74
|
+
else PAGE_SCROLLERS.delete(host);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The scroller named for a window's document, if any. */
|
|
78
|
+
export function pageScroller(host: Window): SmoothScroller | null {
|
|
79
|
+
return PAGE_SCROLLERS.get(host) ?? null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Page px the scroller has the page past where the browser drew it (its whole pixel): what a driver adds back, so a film
|
|
84
|
+
* never steps by the page's pixels. Read while smoothing AND after: a smoothing ends on its own unrounded value, and the
|
|
85
|
+
* film rests there rather than stepping back onto the pixel. 0 with no scroller, or a gap larger than rounding makes.
|
|
86
|
+
*/
|
|
87
|
+
export function scrollSubpixel(scroller: SmoothScroller | null): number {
|
|
88
|
+
if (!scroller) return 0;
|
|
89
|
+
const gap = scroller.scroll - scroller.actualScroll;
|
|
90
|
+
return Number.isFinite(gap) && Math.abs(gap) <= MAX_SUBPIXEL ? gap : 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* One frame of a driver that FOLLOWS an already smoothed scroll (RT-D2): the scroll's own move since the last frame is
|
|
95
|
+
* taken whole, and only a gap left from before (a damped jump the smoothing then continued) is damped away. With no gap
|
|
96
|
+
* it stands exactly on the scroll; it never snaps across one.
|
|
97
|
+
*/
|
|
98
|
+
export function followToward(current: number, previousTarget: number, target: number, seconds: number, rate: number = SCENE_DAMPING): number {
|
|
99
|
+
return dampToward(current + (target - previousTarget), target, seconds, rate);
|
|
100
|
+
}
|
|
101
|
+
|
|
45
102
|
/** The slider a stage carries when the scroll plays it: a booted Swiper (it sets `el.swiper`), read by shape. */
|
|
46
103
|
interface PlayedSlider { slides?: ArrayLike<unknown>; setProgress?: (progress: number, speed?: number) => void; destroyed?: boolean }
|
|
47
104
|
function sliderOf(stage: HTMLElement | null): PlayedSlider | null {
|
|
@@ -63,6 +120,47 @@ export function sceneScrollState(rootTop: number, originTop: number, zoom: numbe
|
|
|
63
120
|
return { local, progress: local / travel };
|
|
64
121
|
}
|
|
65
122
|
|
|
123
|
+
/** Page px a root has been scrolled past its hold's start, from 0 up to `distance` (its hold and its leaving). */
|
|
124
|
+
export function sceneScrollAlong(rootTop: number, originTop: number, zoom: number, distance: number): number {
|
|
125
|
+
if (distance <= 0) return 0;
|
|
126
|
+
return Math.min(distance, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** How far through a crossing: `entered` px of `span` (the stage's size plus the layer's), clamped 0–1. */
|
|
130
|
+
export function crossingOf(entered: number, span: number): number {
|
|
131
|
+
if (!(span > 0)) return 0;
|
|
132
|
+
return Math.round(Math.min(1, Math.max(0, entered / span)) * 10000) / 10000;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* An element's box on screen without its OWN transform: the box of the nearest ancestor that draws one (it carries every
|
|
137
|
+
* move above it, a walking row's included — a host the component path renders with `display: contents` draws none) plus
|
|
138
|
+
* where the layout places the element inside it. Null when its place cannot be read (no such ancestor, not laid out).
|
|
139
|
+
*/
|
|
140
|
+
export function unmovedBox(el: HTMLElement): { left: number; top: number; right: number; bottom: number; width: number; height: number } | null {
|
|
141
|
+
let holder = el.parentElement;
|
|
142
|
+
while (holder && holder.getClientRects().length === 0) holder = holder.parentElement;
|
|
143
|
+
if (!holder) return null;
|
|
144
|
+
const outer = holder.getBoundingClientRect();
|
|
145
|
+
const zoom = holder.offsetWidth > 0 && outer.width > 0 ? outer.width / holder.offsetWidth : 1;
|
|
146
|
+
let x: number;
|
|
147
|
+
let y: number;
|
|
148
|
+
if (el.offsetParent === holder) {
|
|
149
|
+
x = el.offsetLeft + holder.clientLeft;
|
|
150
|
+
y = el.offsetTop + holder.clientTop;
|
|
151
|
+
} else if (el.offsetParent && el.offsetParent === holder.offsetParent) {
|
|
152
|
+
x = el.offsetLeft - holder.offsetLeft;
|
|
153
|
+
y = el.offsetTop - holder.offsetTop;
|
|
154
|
+
} else {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const left = outer.left + x * zoom;
|
|
158
|
+
const top = outer.top + y * zoom;
|
|
159
|
+
const width = el.offsetWidth * zoom;
|
|
160
|
+
const height = el.offsetHeight * zoom;
|
|
161
|
+
return { left, top, right: left + width, bottom: top + height, width, height };
|
|
162
|
+
}
|
|
163
|
+
|
|
66
164
|
export interface ScrollDriverOptions {
|
|
67
165
|
/** Hold the stage with `translate` (the canvas). The live site's stage is sticky and needs nothing. */
|
|
68
166
|
pin?: boolean;
|
|
@@ -71,6 +169,13 @@ export interface ScrollDriverOptions {
|
|
|
71
169
|
/** Follow what changes inside a root: tracks edited, layers added (the canvas). */
|
|
72
170
|
observe?: boolean;
|
|
73
171
|
damping?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Follow the scroll, with no damping of its own (RT-D2): true when something already smooths the scroll the driver
|
|
174
|
+
* reads. A function is asked on every frame. Absent: true while the page's scroller (`setPageScroller`; else a Lenis
|
|
175
|
+
* marking the document's root `LENIS_SMOOTH_CLASS`) is SMOOTHING a scroll and the driver does not `pin` — a jump, the
|
|
176
|
+
* keyboard and the scroll bar are not smoothed by Lenis, and the canvas keeps its damping.
|
|
177
|
+
*/
|
|
178
|
+
follow?: boolean | (() => boolean);
|
|
74
179
|
/** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */
|
|
75
180
|
onFrame?: (root: HTMLElement, state: SceneFrameState) => void;
|
|
76
181
|
/** The part of the screen the page is seen through, when that is not the window (the canvas's scroller). Links only. */
|
|
@@ -156,6 +261,11 @@ interface Layer {
|
|
|
156
261
|
/** Its pictures, while a Play track plays them, and what they were built from: a change starts a new player. */
|
|
157
262
|
player: FramePlayer | null;
|
|
158
263
|
playerKey: string;
|
|
264
|
+
/** It has a track measured over its own crossing of the stage: measured in every frame's read. */
|
|
265
|
+
crosses: boolean;
|
|
266
|
+
/** Where it stands in its crossing (0–1), inline and block, as last read. */
|
|
267
|
+
crossInline: number;
|
|
268
|
+
crossBlock: number;
|
|
159
269
|
}
|
|
160
270
|
|
|
161
271
|
interface Scene {
|
|
@@ -164,9 +274,15 @@ interface Scene {
|
|
|
164
274
|
layers: Layer[];
|
|
165
275
|
progress: number;
|
|
166
276
|
target: number;
|
|
277
|
+
/** Page px scrolled past the hold's start, over the hold and the leaving (`travel + exit`): what is damped. */
|
|
278
|
+
position: number;
|
|
279
|
+
/** Where the scroll stood in the last frame, the same px: a driver that follows takes the scroll's move since. */
|
|
280
|
+
along: number;
|
|
167
281
|
/** Page px and the stage's own width, measured when something resizes and never per frame. */
|
|
168
282
|
height: number;
|
|
169
283
|
travel: number;
|
|
284
|
+
/** Page px the root takes to leave after its hold: the stage's height (an Exit track runs over it). */
|
|
285
|
+
exit: number;
|
|
170
286
|
/** Page px from the top of the screen at which the stage holds: 0 for a Scene, mid-screen for a played slider. */
|
|
171
287
|
stick: number;
|
|
172
288
|
phone: boolean;
|
|
@@ -211,7 +327,7 @@ export class ScrollDriver {
|
|
|
211
327
|
if (holder && holder !== this) return false;
|
|
212
328
|
this.remove(root);
|
|
213
329
|
HELD.set(root, this);
|
|
214
|
-
const scene: Scene = { root, stage: null, layers: [], progress: 0, target: 0, height: 0, travel: 0, stick: 0, phone: false, inlineSign: 1, fresh: true, mutations: null };
|
|
330
|
+
const scene: 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 };
|
|
215
331
|
this.scenes.set(root, scene);
|
|
216
332
|
this.resize?.observe(root);
|
|
217
333
|
if (this.options.observe) {
|
|
@@ -357,7 +473,13 @@ export class ScrollDriver {
|
|
|
357
473
|
private readLayer(el: HTMLElement, scene: Scene): Layer {
|
|
358
474
|
const previous = scene.layers.find(layer => layer.el === el);
|
|
359
475
|
el.style.setProperty('will-change', TRANSFORM_WILL_CHANGE);
|
|
360
|
-
|
|
476
|
+
const tracks = parseTracks(el.getAttribute(SceneAttribute.Tracks));
|
|
477
|
+
const phoneTracks = parseTracks(el.getAttribute(SceneAttribute.PhoneTracks));
|
|
478
|
+
return {
|
|
479
|
+
el, tracks, phoneTracks, last: previous?.last ?? {}, stale: true, words: previous?.words ?? null, wordsRefused: false,
|
|
480
|
+
player: previous?.player ?? null, playerKey: previous?.playerKey ?? '',
|
|
481
|
+
crosses: crossesStage(tracks) || crossesStage(phoneTracks), crossInline: previous?.crossInline ?? 0, crossBlock: previous?.crossBlock ?? 0,
|
|
482
|
+
};
|
|
361
483
|
}
|
|
362
484
|
|
|
363
485
|
private remeasureAll(): void {
|
|
@@ -368,6 +490,7 @@ export class ScrollDriver {
|
|
|
368
490
|
private measure(scene: Scene): void {
|
|
369
491
|
scene.height = scene.root.offsetHeight;
|
|
370
492
|
scene.travel = Math.max(0, scene.height - (scene.stage?.offsetHeight ?? scene.height));
|
|
493
|
+
scene.exit = scene.stage?.offsetHeight ?? 0;
|
|
371
494
|
// Where the stage holds: its sticky top (a played slider holds mid-screen; a Scene's stage at 0). Read when
|
|
372
495
|
// something resizes, never per frame.
|
|
373
496
|
scene.stick = scene.stage ? (parseFloat(this.host.getComputedStyle(scene.stage).top) || 0) : 0;
|
|
@@ -380,16 +503,33 @@ export class ScrollDriver {
|
|
|
380
503
|
this.frame = 0;
|
|
381
504
|
const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;
|
|
382
505
|
this.lastTime = now;
|
|
383
|
-
const
|
|
506
|
+
const follow = this.following();
|
|
507
|
+
// Where the page's scroller has the page beyond the browser's whole pixel: read with it, so a film does not step by
|
|
508
|
+
// pixels. Not when the host says outright how to follow (`follow`): it reads its own scroll.
|
|
509
|
+
const subpixel = this.options.follow === undefined ? scrollSubpixel(this.scroller()) : 0;
|
|
510
|
+
const reads = [...this.scenes.values()].map(scene => this.read(scene, subpixel));
|
|
511
|
+
// Each layer that moves over its own crossing is read with the rest, before any write: where its row stood after the
|
|
512
|
+
// last frame. A row that moved since is read again on the next frame, so the crossing lands where the row lands.
|
|
513
|
+
const crossed = reads.map(({ scene }) => this.readCrossings(scene)).some(Boolean);
|
|
384
514
|
const view = this.links.size ? this.viewBox() : null;
|
|
385
|
-
const linkReads = [...this.links].map(state => this.readLink(state, view
|
|
386
|
-
let moving =
|
|
387
|
-
for (const { scene, local,
|
|
515
|
+
const linkReads = [...this.links].map(state => this.readLink(state, view!, subpixel));
|
|
516
|
+
let moving = crossed;
|
|
517
|
+
for (const { scene, local, along } of reads) {
|
|
388
518
|
if (this.options.pin && scene.stage) scene.stage.style.setProperty('translate', `0 ${local}px`);
|
|
389
|
-
const next = scene.fresh ?
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
519
|
+
const next = scene.fresh ? along
|
|
520
|
+
: follow ? followToward(scene.position, scene.along, along, seconds, this.options.damping)
|
|
521
|
+
: dampToward(scene.position, along, seconds, this.options.damping);
|
|
522
|
+
// The step onto the scroll is what is left: taken once it is under SETTLED_PX, so it never shows. Following, what
|
|
523
|
+
// is left is the gap from before (the scroll's own move is taken whole).
|
|
524
|
+
const gap = follow ? scene.along - scene.position : along - scene.position;
|
|
525
|
+
const settled = scene.fresh || Math.abs(gap) < SETTLED_PX;
|
|
526
|
+
const before = scene.position;
|
|
527
|
+
scene.position = settled ? along : next;
|
|
528
|
+
scene.along = along;
|
|
529
|
+
// A crossing was read before this frame moved its row: it is read again on the next frame, after the move.
|
|
530
|
+
if (scene.position !== before && scene.layers.some(layer => layer.crosses)) moving = true;
|
|
531
|
+
const target = scene.travel > 0 ? local / scene.travel : 0;
|
|
532
|
+
scene.progress = scene.travel > 0 ? Math.min(scene.travel, scene.position) / scene.travel : 0;
|
|
393
533
|
scene.target = target;
|
|
394
534
|
scene.fresh = false;
|
|
395
535
|
this.write(scene);
|
|
@@ -398,8 +538,11 @@ export class ScrollDriver {
|
|
|
398
538
|
}
|
|
399
539
|
for (const { state, target } of linkReads) {
|
|
400
540
|
const immediate = state.fresh || !!state.link.immediate;
|
|
401
|
-
const next = immediate ? target
|
|
402
|
-
|
|
541
|
+
const next = immediate ? target
|
|
542
|
+
: follow ? followToward(state.progress, state.target, target, seconds, this.options.damping)
|
|
543
|
+
: dampToward(state.progress, target, seconds, this.options.damping);
|
|
544
|
+
const gap = follow ? state.target - state.progress : target - state.progress;
|
|
545
|
+
const settled = immediate || Math.abs(gap) * Math.max(1, state.geometry.distance) < SETTLED_PX;
|
|
403
546
|
state.progress = settled ? target : next;
|
|
404
547
|
state.target = target;
|
|
405
548
|
state.fresh = false;
|
|
@@ -410,13 +553,53 @@ export class ScrollDriver {
|
|
|
410
553
|
else this.lastTime = 0;
|
|
411
554
|
};
|
|
412
555
|
|
|
556
|
+
/** True when the scroll the driver reads is being smoothed right now: it follows it (RT-D2). */
|
|
557
|
+
private following(): boolean {
|
|
558
|
+
const follow = this.options.follow;
|
|
559
|
+
if (typeof follow === 'function') return follow();
|
|
560
|
+
if (typeof follow === 'boolean') return follow;
|
|
561
|
+
if (this.options.pin) return false;
|
|
562
|
+
const scroller = this.scroller();
|
|
563
|
+
return scroller ? scroller.isSmooth : !!this.host.document?.documentElement?.classList.contains(LENIS_SMOOTH_CLASS);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
private scroller(): SmoothScroller | null {
|
|
567
|
+
return this.options.pin ? null : pageScroller(this.host);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Where each crossing layer of a Scene stands in its crossing of the stage. Its box is read WITHOUT its own move (its
|
|
572
|
+
* 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
|
|
573
|
+
* how far it is moved. True when any of them moved since the last frame.
|
|
574
|
+
*/
|
|
575
|
+
private readCrossings(scene: Scene): boolean {
|
|
576
|
+
const crossing = scene.layers.filter(layer => layer.crosses);
|
|
577
|
+
if (!crossing.length) return false;
|
|
578
|
+
const stage = (scene.stage ?? scene.root).getBoundingClientRect();
|
|
579
|
+
let moved = false;
|
|
580
|
+
for (const layer of crossing) {
|
|
581
|
+
const box = unmovedBox(layer.el);
|
|
582
|
+
if (!box) continue;
|
|
583
|
+
const inline = scene.inlineSign === 1
|
|
584
|
+
? crossingOf(stage.right - box.left, stage.width + box.width)
|
|
585
|
+
: crossingOf(box.right - stage.left, stage.width + box.width);
|
|
586
|
+
const block = crossingOf(stage.bottom - box.top, stage.height + box.height);
|
|
587
|
+
moved = moved || Math.abs(inline - layer.crossInline) > CROSSING_SETTLED || Math.abs(block - layer.crossBlock) > CROSSING_SETTLED;
|
|
588
|
+
layer.crossInline = inline;
|
|
589
|
+
layer.crossBlock = block;
|
|
590
|
+
}
|
|
591
|
+
return moved;
|
|
592
|
+
}
|
|
593
|
+
|
|
413
594
|
/** The part of the page on screen: the host's own, or the window. */
|
|
414
595
|
private viewBox(): ScrollBox {
|
|
415
596
|
return this.options.view?.() ?? { top: 0, height: this.host.innerHeight };
|
|
416
597
|
}
|
|
417
598
|
|
|
418
|
-
private readLink(state: LinkState, view: ScrollBox): { state: LinkState; target: number } {
|
|
419
|
-
const
|
|
599
|
+
private readLink(state: LinkState, view: ScrollBox, subpixel = 0): { state: LinkState; target: number } {
|
|
600
|
+
const measured = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
|
|
601
|
+
const zoom = measured.zoom;
|
|
602
|
+
const box = subpixel ? { top: measured.box.top - subpixel, height: measured.box.height } : measured.box;
|
|
420
603
|
const z = zoom || 1;
|
|
421
604
|
const target = rangeProgress(state.link.range, box, view);
|
|
422
605
|
state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z, opening: this.openingOf(state.link, box, view) };
|
|
@@ -432,23 +615,26 @@ export class ScrollDriver {
|
|
|
432
615
|
return rangeProgress(link.range, { top: view.top + (box.top - top), height: box.height }, view);
|
|
433
616
|
}
|
|
434
617
|
|
|
435
|
-
private read(scene: Scene): { scene: Scene; local: number;
|
|
436
|
-
const
|
|
618
|
+
private read(scene: Scene, subpixel = 0): { scene: Scene; local: number; along: number } {
|
|
619
|
+
const box = scene.root.getBoundingClientRect();
|
|
620
|
+
const rect = { top: box.top - subpixel, height: box.height };
|
|
437
621
|
const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
|
|
438
622
|
const zoom = scene.height ? rect.height / scene.height : 1;
|
|
439
|
-
const { local
|
|
440
|
-
return { scene, local,
|
|
623
|
+
const { local } = sceneScrollState(rect.top, origin + scene.stick * zoom, zoom, scene.travel);
|
|
624
|
+
return { scene, local, along: sceneScrollAlong(rect.top, origin + scene.stick * zoom, zoom, scene.travel + scene.exit) };
|
|
441
625
|
}
|
|
442
626
|
|
|
443
627
|
private write(scene: Scene): void {
|
|
444
628
|
// A slider the scroll plays (M4): the damped moment, held on each picture.
|
|
445
629
|
const slider = sliderOf(scene.stage);
|
|
446
630
|
if (slider) slider.setProgress!(heldProgress(scene.progress, slider.slides?.length ?? 0), 0);
|
|
631
|
+
const exit = scene.exit > 0 ? Math.min(1, Math.max(0, (scene.position - scene.travel) / scene.exit)) : 0;
|
|
447
632
|
for (const layer of scene.layers) {
|
|
448
633
|
const tracks = scene.phone && layer.phoneTracks.length ? layer.phoneTracks : layer.tracks;
|
|
449
|
-
|
|
450
|
-
this.
|
|
451
|
-
|
|
634
|
+
const at: SceneProgress = { hold: scene.progress, exit, crossInline: layer.crossInline, crossBlock: layer.crossBlock };
|
|
635
|
+
this.writeWords(layer, sceneWordsLit(tracks, at));
|
|
636
|
+
this.writePlayed(layer, scene, scenePlayed(tracks, at));
|
|
637
|
+
const frame = sceneFrame(tracks, at, { inlineSign: scene.inlineSign });
|
|
452
638
|
for (const key of Object.keys(frame) as (keyof SceneFrame)[]) {
|
|
453
639
|
if (layer.stale || frame[key] !== layer.last[key]) layer.el.style[key] = frame[key] ?? '';
|
|
454
640
|
}
|
package/styles/iox-design.css
CHANGED
|
@@ -968,11 +968,130 @@ body:not(.builder-active):has(.iox-bar-reserve) { padding-bottom: calc(var(--iox
|
|
|
968
968
|
}
|
|
969
969
|
|
|
970
970
|
/* A closed live dialog never shows, whatever display its node sets (a drawer lays its parts out as a
|
|
971
|
-
flex column): an author rule would otherwise beat the UA's `dialog:not([open]) { display: none }`.
|
|
972
|
-
|
|
971
|
+
flex column): an author rule would otherwise beat the UA's `dialog:not([open]) { display: none }`.
|
|
972
|
+
Popups PU1: a NON-modal dialog (a popup's corner / bar) is shown with `showPopover()` and never gets `[open]` — it is
|
|
973
|
+
shown while `:popover-open`. Inside `:is()` (forgiving), so a browser without the Popover API still hides every closed
|
|
974
|
+
dialog. */
|
|
975
|
+
dialog[data-iox-dialog]:not([open]):not(:is(:popover-open)) {
|
|
973
976
|
display: none;
|
|
974
977
|
}
|
|
975
978
|
|
|
979
|
+
/* ── POPUPS (popups-plan.md §3b, §6, §7, §8 — PU1) ─────────────────────────────────────────────────────────────────────
|
|
980
|
+
A popup is a Dialog with `data-iox-popup` (its kind) and `data-iox-popup-form`, opened by the popup runtime:
|
|
981
|
+
· `corner` — a card at the bottom-right corner, `--iox-popup-inset` from both edges (the same corner on a Hebrew
|
|
982
|
+
site, popups-plan §3b), sliding in from that edge; NON-modal (`showPopover`).
|
|
983
|
+
· `bar` — one line along the bottom edge (≤ 64px; ≤ 88px on a phone), rising from it; NON-modal.
|
|
984
|
+
· `centred` — a newsletter's modal card on a laptop (`showModal`, the look's scrim), growing from .97; on a phone the
|
|
985
|
+
runtime opens it as the corner card.
|
|
986
|
+
· on a phone (≤ 767px) every card is a bottom card at most 30% of the screen high, inset by the smaller of the token and
|
|
987
|
+
12px, above a bottom bar and the safe area; it rises 24px as it fades in (a slide from the side reads as a page change).
|
|
988
|
+
Motion (Emil): transitions, never keyframes — a close mid-arrival leaves from where it is; transform / opacity only; the
|
|
989
|
+
look's ease-enter / ease-exit; `popup-dur-in` × the How-animated scale the runtime writes, the exit `popup-dur-out`;
|
|
990
|
+
Still fades only; reduced motion a ≤ 200ms fade, no movement. Specificity: above the styled dialog's own enter / leave
|
|
991
|
+
(0,3,1) so a popup's motion is its own. */
|
|
992
|
+
dialog[data-iox-dialog][data-iox-popup] {
|
|
993
|
+
--popup-inset: var(--iox-popup-inset);
|
|
994
|
+
--popup-in: calc(var(--iox-popup-dur-in) * var(--popup-scale, 1));
|
|
995
|
+
--popup-out: calc(var(--iox-popup-dur-out) * var(--popup-scale, 1));
|
|
996
|
+
--popup-from-x: 0px;
|
|
997
|
+
--popup-from-y: 0px;
|
|
998
|
+
--popup-from-scale: 1;
|
|
999
|
+
box-sizing: border-box;
|
|
1000
|
+
overflow: auto;
|
|
1001
|
+
overscroll-behavior: contain;
|
|
1002
|
+
transition:
|
|
1003
|
+
translate var(--popup-in) var(--iox-ease-enter),
|
|
1004
|
+
scale var(--popup-in) var(--iox-ease-enter),
|
|
1005
|
+
opacity var(--popup-in) var(--iox-ease-enter),
|
|
1006
|
+
overlay var(--popup-in) allow-discrete,
|
|
1007
|
+
display var(--popup-in) allow-discrete;
|
|
1008
|
+
}
|
|
1009
|
+
dialog[data-iox-dialog][data-iox-popup]:is([data-iox-popup-form='corner'], [data-iox-popup-form='bar']) {
|
|
1010
|
+
position: fixed;
|
|
1011
|
+
margin: 0;
|
|
1012
|
+
}
|
|
1013
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-form='corner'] {
|
|
1014
|
+
--popup-from-x: calc(100% + var(--popup-inset));
|
|
1015
|
+
inset: auto var(--popup-inset) calc(var(--popup-inset) + env(safe-area-inset-bottom, 0px)) auto;
|
|
1016
|
+
min-width: min(360px, calc(100vw - var(--popup-inset) * 2));
|
|
1017
|
+
max-width: min(560px, calc(100vw - var(--popup-inset) * 2));
|
|
1018
|
+
max-height: calc(100dvh - var(--popup-inset) * 2);
|
|
1019
|
+
}
|
|
1020
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-form='bar'] {
|
|
1021
|
+
--popup-from-y: 100%;
|
|
1022
|
+
inset: auto 0 0 0;
|
|
1023
|
+
width: 100%;
|
|
1024
|
+
max-width: 100%;
|
|
1025
|
+
max-height: 64px;
|
|
1026
|
+
border-radius: 0;
|
|
1027
|
+
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
1028
|
+
}
|
|
1029
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-form='centred'] { --popup-from-scale: 0.97; transform-origin: center; }
|
|
1030
|
+
/* Non-modal: no scrim, nothing under it is covered — the page stays fully usable. */
|
|
1031
|
+
dialog[data-iox-dialog][data-iox-popup]:is([data-iox-dialog-nonmodal], [aria-modal='false'])::backdrop { display: none; }
|
|
1032
|
+
/* Its ✕ is a real button, 44 × 44, its hover only for a mouse (§7). */
|
|
1033
|
+
dialog[data-iox-dialog][data-iox-popup] > .iox-dialog-close {
|
|
1034
|
+
width: 44px;
|
|
1035
|
+
min-width: 44px;
|
|
1036
|
+
height: 44px;
|
|
1037
|
+
flex-shrink: 0;
|
|
1038
|
+
align-self: flex-start;
|
|
1039
|
+
}
|
|
1040
|
+
dialog[data-iox-dialog][data-iox-popup]:has(> .iox-dialog-close) { padding-inline-end: max(var(--iox-dialog-pad, 0px), 56px); }
|
|
1041
|
+
dialog[data-iox-dialog][data-iox-popup]:is([open], :popover-open):not([data-iox-closing]) {
|
|
1042
|
+
translate: 0px 0px;
|
|
1043
|
+
scale: 1;
|
|
1044
|
+
opacity: 1;
|
|
1045
|
+
}
|
|
1046
|
+
dialog[data-iox-dialog][data-iox-popup]:is([data-iox-closing], :not([open]):not(:popover-open)) {
|
|
1047
|
+
translate: var(--popup-from-x) var(--popup-from-y);
|
|
1048
|
+
scale: var(--popup-from-scale);
|
|
1049
|
+
opacity: 0;
|
|
1050
|
+
transition-timing-function: var(--iox-ease-exit);
|
|
1051
|
+
transition-duration: var(--popup-out);
|
|
1052
|
+
}
|
|
1053
|
+
@starting-style {
|
|
1054
|
+
dialog[data-iox-dialog][data-iox-popup]:is([open], :popover-open) {
|
|
1055
|
+
translate: var(--popup-from-x) var(--popup-from-y);
|
|
1056
|
+
scale: var(--popup-from-scale);
|
|
1057
|
+
opacity: 0;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
@media (max-width: 767px) {
|
|
1061
|
+
dialog[data-iox-dialog][data-iox-popup]:not([data-iox-popup-form='bar']) {
|
|
1062
|
+
--popup-inset: min(var(--iox-popup-inset), 12px);
|
|
1063
|
+
--popup-from-x: 0px;
|
|
1064
|
+
--popup-from-y: 24px;
|
|
1065
|
+
--popup-from-scale: 1;
|
|
1066
|
+
position: fixed;
|
|
1067
|
+
inset: auto var(--popup-inset) calc(var(--popup-inset) + env(safe-area-inset-bottom, 0px)) var(--popup-inset);
|
|
1068
|
+
margin: 0;
|
|
1069
|
+
width: auto;
|
|
1070
|
+
min-width: 0;
|
|
1071
|
+
max-width: none;
|
|
1072
|
+
max-height: 30dvh;
|
|
1073
|
+
}
|
|
1074
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-form='bar'] { max-height: 88px; }
|
|
1075
|
+
html:has(.iox-bar-reserve) dialog[data-iox-dialog][data-iox-popup]:not([data-iox-popup-form='bar']) {
|
|
1076
|
+
inset-block-end: calc(var(--popup-inset) + var(--iox-tabbar-height, 64px) + env(safe-area-inset-bottom, 0px));
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
/* Still (How animated) moves nothing — it fades; reduced motion is a ≤ 200ms fade (gentler, never zero; Off stays 0ms). */
|
|
1080
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-still] {
|
|
1081
|
+
--popup-from-x: 0px;
|
|
1082
|
+
--popup-from-y: 0px;
|
|
1083
|
+
--popup-from-scale: 1;
|
|
1084
|
+
}
|
|
1085
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1086
|
+
dialog[data-iox-dialog][data-iox-popup][data-iox-popup-form] {
|
|
1087
|
+
--popup-from-x: 0px;
|
|
1088
|
+
--popup-from-y: 0px;
|
|
1089
|
+
--popup-from-scale: 1;
|
|
1090
|
+
--popup-in: min(var(--iox-popup-dur-in), 200ms);
|
|
1091
|
+
--popup-out: min(var(--iox-popup-dur-out), 200ms);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
976
1095
|
/* A bottom-bar item reads the ITEM's ink (the contract's inkScopes): its icon and label change together. */
|
|
977
1096
|
.iox-es-bottom-bar-item {
|
|
978
1097
|
--iox-icon-color: currentColor;
|