@vectoriox/iox-ui 5.87.0 → 5.88.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 +17 -3
- package/composite-core/index.d.ts +208 -2
- package/design-core/index.d.ts +373 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +30 -4
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +656 -116
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +444 -3
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +5 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +231 -7
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +603 -20
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/index.d.ts +196 -2
- package/package.json +1 -1
- package/scene-core/index.d.ts +158 -2
- package/src/actions-core/action.model.ts +3 -0
- package/src/actions-core/element-actions.ts +32 -3
- package/src/composite-core/marquee-runtime.ts +255 -0
- package/src/composite-core/marquee.ts +267 -0
- package/src/composite-core/public-api.ts +3 -0
- package/src/composite-core/scroll-recipes.ts +74 -0
- package/src/composite-core/structure.ts +7 -0
- package/src/design-core/contrast-audit.ts +6 -1
- package/src/design-core/flavor-spec.generated.ts +435 -1
- package/src/generation-core/node-baselines.generated.ts +5 -1
- package/src/scene-core/public-api.ts +1 -0
- package/src/scene-core/scroll-driver.ts +98 -0
- package/src/scene-core/scroll-range.ts +195 -0
- package/styles/iox-design.css +49 -1
|
@@ -2,6 +2,7 @@ import { SceneRole } from '@vectoriox/iox-ui/composite-core';
|
|
|
2
2
|
import { FramePlayer, normalizeFrameSequence, VideoAttribute } from '@vectoriox/iox-ui/media-core';
|
|
3
3
|
|
|
4
4
|
import { heldProgress, normalizeTracks, SCENE_PHONE_MAX_WIDTH, SceneAttribute, sceneFrame, SceneFrame, scenePlayed, sceneWordOpacity, sceneWordsLit, SceneTrack } from './scene';
|
|
5
|
+
import { rangeDistance, rangeProgress, ScrollBox, ScrollRange } from './scroll-range';
|
|
5
6
|
import { LIGHT_UP_PIECE_CAP, SplitText, splitText } from './split-text';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -72,10 +73,64 @@ export interface ScrollDriverOptions {
|
|
|
72
73
|
damping?: number;
|
|
73
74
|
/** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */
|
|
74
75
|
onFrame?: (root: HTMLElement, state: SceneFrameState) => void;
|
|
76
|
+
/** The part of the screen the page is seen through, when that is not the window (the canvas's scroller). Links only. */
|
|
77
|
+
view?: () => ScrollBox | null;
|
|
75
78
|
/** The window, for a test. */
|
|
76
79
|
host?: Window;
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
/**
|
|
83
|
+
* A SCROLL LINK (premium components M6, N7): something outside a Scene that follows where an element stands in the page —
|
|
84
|
+
* a scrubbed entrance, a parallax depth, a reading bar. It rides this same loop: read with every Scene, damped the same
|
|
85
|
+
* way, written in the same write phase. Never a second loop per element.
|
|
86
|
+
*/
|
|
87
|
+
export interface ScrollLink {
|
|
88
|
+
/** What is measured: the element for a view range, the page for `ScrollRange.Page`. */
|
|
89
|
+
measured: HTMLElement;
|
|
90
|
+
range: ScrollRange;
|
|
91
|
+
/** Written in the write phase with the damped progress (0–1). Compositor properties only. */
|
|
92
|
+
write(progress: number, geometry: ScrollLinkGeometry): void;
|
|
93
|
+
/** Follow the scroll exactly, with no glide (reduced motion). */
|
|
94
|
+
immediate?: boolean;
|
|
95
|
+
/** The page the measured element stands in: its layout is measured inside it (`layoutBoxOnScreen`). */
|
|
96
|
+
within?: HTMLElement | null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A link's geometry this frame, in the PAGE's px (the canvas's zoom undone). */
|
|
100
|
+
export interface ScrollLinkGeometry {
|
|
101
|
+
/** How far the scroll travels through the range. */
|
|
102
|
+
distance: number;
|
|
103
|
+
/** The height of the part of the page on screen. */
|
|
104
|
+
viewHeight: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface LinkState {
|
|
108
|
+
link: ScrollLink;
|
|
109
|
+
progress: number;
|
|
110
|
+
target: number;
|
|
111
|
+
fresh: boolean;
|
|
112
|
+
geometry: ScrollLinkGeometry;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Where an element's LAYOUT box stands on screen: its offsets up to the nearest box that has no offset parent, placed by
|
|
117
|
+
* that box's own rectangle. Transforms on the element itself are not in it — a layer that glides is measured where it
|
|
118
|
+
* stands in the flow, so what it is moved by never feeds back into how far it is moved. `zoom` undoes the canvas's scale.
|
|
119
|
+
*/
|
|
120
|
+
export function layoutBoxOnScreen(el: HTMLElement, within: HTMLElement | null = null): { box: ScrollBox; zoom: number } {
|
|
121
|
+
let offset = 0;
|
|
122
|
+
let ref: HTMLElement = el;
|
|
123
|
+
// Never past `within` (the page): offsets inside the canvas's zoomed frame are its own px, and the box that places them
|
|
124
|
+
// must be drawn at the same zoom.
|
|
125
|
+
while (ref.offsetParent instanceof HTMLElement && (!within || within.contains(ref.offsetParent))) {
|
|
126
|
+
offset += ref.offsetTop;
|
|
127
|
+
ref = ref.offsetParent;
|
|
128
|
+
}
|
|
129
|
+
const rect = ref.getBoundingClientRect();
|
|
130
|
+
const zoom = ref.offsetHeight > 0 && rect.height > 0 ? rect.height / ref.offsetHeight : 1;
|
|
131
|
+
return { box: { top: rect.top + offset * zoom, height: el.offsetHeight * zoom }, zoom };
|
|
132
|
+
}
|
|
133
|
+
|
|
79
134
|
export interface SceneFrameState {
|
|
80
135
|
/** Where the scroll stands, undamped: what a scrubber shows. */
|
|
81
136
|
target: number;
|
|
@@ -125,6 +180,7 @@ function parseTracks(raw: string | null): SceneTrack[] {
|
|
|
125
180
|
|
|
126
181
|
export class ScrollDriver {
|
|
127
182
|
private readonly scenes = new Map<HTMLElement, Scene>();
|
|
183
|
+
private readonly links = new Set<LinkState>();
|
|
128
184
|
private readonly host: Window;
|
|
129
185
|
private readonly resize: ResizeObserver | null;
|
|
130
186
|
private frame = 0;
|
|
@@ -228,6 +284,22 @@ export class ScrollDriver {
|
|
|
228
284
|
}
|
|
229
285
|
}
|
|
230
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Follow where `link.measured` stands, on this loop. Returns the way to let go. A link that is added lands on its first
|
|
289
|
+
* frame exactly where the scroll is, with no glide.
|
|
290
|
+
*/
|
|
291
|
+
addLink(link: ScrollLink): () => void {
|
|
292
|
+
const state: LinkState = { link, progress: 0, target: 0, fresh: true, geometry: { distance: 0, viewHeight: 0 } };
|
|
293
|
+
this.links.add(state);
|
|
294
|
+
this.wake();
|
|
295
|
+
return () => { this.links.delete(state); };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** True while it plays anything: a Scene or a link. */
|
|
299
|
+
get busy(): boolean {
|
|
300
|
+
return this.scenes.size > 0 || this.links.size > 0;
|
|
301
|
+
}
|
|
302
|
+
|
|
231
303
|
/** Something moved that no scroll or resize announces (the canvas's zoom). */
|
|
232
304
|
wake(): void {
|
|
233
305
|
if (this.frame) return;
|
|
@@ -241,6 +313,7 @@ export class ScrollDriver {
|
|
|
241
313
|
this.host.removeEventListener('resize', this.wakeUp);
|
|
242
314
|
this.host.removeEventListener(SCENE_WAKE_EVENT, this.onWakeEvent, { capture: true });
|
|
243
315
|
for (const root of [...this.scenes.keys()]) this.remove(root);
|
|
316
|
+
this.links.clear();
|
|
244
317
|
this.resize?.disconnect();
|
|
245
318
|
}
|
|
246
319
|
|
|
@@ -305,6 +378,8 @@ export class ScrollDriver {
|
|
|
305
378
|
const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;
|
|
306
379
|
this.lastTime = now;
|
|
307
380
|
const reads = [...this.scenes.values()].map(scene => this.read(scene));
|
|
381
|
+
const view = this.links.size ? this.viewBox() : null;
|
|
382
|
+
const linkReads = [...this.links].map(state => this.readLink(state, view!));
|
|
308
383
|
let moving = false;
|
|
309
384
|
for (const { scene, local, target } of reads) {
|
|
310
385
|
if (this.options.pin && scene.stage) scene.stage.style.setProperty('translate', `0 ${local}px`);
|
|
@@ -318,10 +393,33 @@ export class ScrollDriver {
|
|
|
318
393
|
this.options.onFrame?.(scene.root, { target, progress: scene.progress });
|
|
319
394
|
moving = moving || !settled;
|
|
320
395
|
}
|
|
396
|
+
for (const { state, target } of linkReads) {
|
|
397
|
+
const immediate = state.fresh || !!state.link.immediate;
|
|
398
|
+
const next = immediate ? target : dampToward(state.progress, target, seconds, this.options.damping);
|
|
399
|
+
const settled = immediate || Math.abs(target - state.progress) * Math.max(1, state.geometry.distance) < SETTLED_PX;
|
|
400
|
+
state.progress = settled ? target : next;
|
|
401
|
+
state.target = target;
|
|
402
|
+
state.fresh = false;
|
|
403
|
+
state.link.write(state.progress, state.geometry);
|
|
404
|
+
moving = moving || !settled;
|
|
405
|
+
}
|
|
321
406
|
if (moving) this.wake();
|
|
322
407
|
else this.lastTime = 0;
|
|
323
408
|
};
|
|
324
409
|
|
|
410
|
+
/** The part of the page on screen: the host's own, or the window. */
|
|
411
|
+
private viewBox(): ScrollBox {
|
|
412
|
+
return this.options.view?.() ?? { top: 0, height: this.host.innerHeight };
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
private readLink(state: LinkState, view: ScrollBox): { state: LinkState; target: number } {
|
|
416
|
+
const { box, zoom } = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
|
|
417
|
+
const z = zoom || 1;
|
|
418
|
+
const target = rangeProgress(state.link.range, box, view);
|
|
419
|
+
state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z };
|
|
420
|
+
return { state, target };
|
|
421
|
+
}
|
|
422
|
+
|
|
325
423
|
private read(scene: Scene): { scene: Scene; local: number; target: number } {
|
|
326
424
|
const rect = scene.root.getBoundingClientRect();
|
|
327
425
|
const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll-driven motion outside a Scene (premium components M6, N7 — Motion v2 V1). An element plays its actions by WHERE
|
|
3
|
+
* it stands in the page, not by time: a fade that follows the scroll, a layer that glides at its own depth, a bar that
|
|
4
|
+
* fills as the page is read. Every one of them rides the ONE `ScrollDriver` (its links), never a loop of its own.
|
|
5
|
+
*
|
|
6
|
+
* The ranges are CSS's named view-timeline ranges, so a `view()` timeline could take them over 1:1, plus the whole page
|
|
7
|
+
* (a reading-progress bar). The maths is pure: geometry in, progress out, the same at any canvas zoom because every length
|
|
8
|
+
* is in one space.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export enum ScrollRange {
|
|
12
|
+
/** From the element's top edge at the bottom of the screen until it is wholly in (CSS `entry`). */
|
|
13
|
+
Enter = 'enter',
|
|
14
|
+
/** From the moment it starts to come in until it has wholly left (CSS `cover`). */
|
|
15
|
+
Cover = 'cover',
|
|
16
|
+
/** While it is wholly in view, or, when it is taller than the screen, while it fills it (CSS `contain`). */
|
|
17
|
+
Contain = 'contain',
|
|
18
|
+
/** From the moment it starts to leave until it has gone (CSS `exit`). */
|
|
19
|
+
Exit = 'exit',
|
|
20
|
+
/** The section the element stands in, while it is read: Contain, measured on the section (a section's reading bar). */
|
|
21
|
+
Section = 'section',
|
|
22
|
+
/** The whole page, from its top to its bottom: how much of it has been read. */
|
|
23
|
+
Page = 'page',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const SCROLL_RANGE_DEFAULT = ScrollRange.Cover;
|
|
27
|
+
|
|
28
|
+
const RANGES: ReadonlySet<string> = new Set(Object.values(ScrollRange));
|
|
29
|
+
|
|
30
|
+
/** The node element that holds `el` outermost — its section on the page — stopping below `stop`. A node element is one
|
|
31
|
+
* carrying its `iox-node-<id>` class, in every render path; a wrapper a renderer drew around nodes is never one. */
|
|
32
|
+
export function outermostNodeOf(el: Element, stop: Element | null = null): HTMLElement {
|
|
33
|
+
let found = el as HTMLElement;
|
|
34
|
+
for (let p = el.parentElement; p && p !== stop; p = p.parentElement) {
|
|
35
|
+
if (Array.from(p.classList).some(c => c.startsWith('iox-node-'))) found = p;
|
|
36
|
+
}
|
|
37
|
+
return found;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A saved range, or the default for anything else. */
|
|
41
|
+
export function normalizeScrollRange(value: unknown): ScrollRange {
|
|
42
|
+
return typeof value === 'string' && RANGES.has(value) ? (value as ScrollRange) : SCROLL_RANGE_DEFAULT;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A box along the scroll axis: its top and its height, in the same space as the view's. */
|
|
46
|
+
export interface ScrollBox {
|
|
47
|
+
top: number;
|
|
48
|
+
height: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const clamp01 = (v: number): number => Math.min(1, Math.max(0, v));
|
|
52
|
+
|
|
53
|
+
/** Where a range starts and ends, as the element's top relative to the view's top. */
|
|
54
|
+
export function rangeEnds(range: ScrollRange, box: ScrollBox, view: ScrollBox): { start: number; end: number } {
|
|
55
|
+
const vh = view.height;
|
|
56
|
+
const h = box.height;
|
|
57
|
+
const fit = vh - h;
|
|
58
|
+
switch (range) {
|
|
59
|
+
case ScrollRange.Enter: return { start: vh, end: Math.max(fit, 0) };
|
|
60
|
+
case ScrollRange.Contain:
|
|
61
|
+
case ScrollRange.Section: return { start: Math.max(fit, 0), end: Math.min(fit, 0) };
|
|
62
|
+
case ScrollRange.Exit: return { start: Math.min(fit, 0), end: -h };
|
|
63
|
+
default: return { start: vh, end: -h };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** How far the scroll travels through a range, in the box's space: what a parallax depth is a share of. */
|
|
68
|
+
export function rangeDistance(range: ScrollRange, box: ScrollBox, view: ScrollBox): number {
|
|
69
|
+
if (range === ScrollRange.Page) return Math.max(0, box.height - view.height);
|
|
70
|
+
const { start, end } = rangeEnds(range, box, view);
|
|
71
|
+
return Math.abs(start - end);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* How far `box` has come through `range` of `view`, 0–1. For `Page`, `box` is the page itself: 0 at its top, 1 once its
|
|
76
|
+
* bottom reaches the bottom of the view. A range of no length is a step: 0 before it, 1 from it on.
|
|
77
|
+
*/
|
|
78
|
+
export function rangeProgress(range: ScrollRange, box: ScrollBox, view: ScrollBox): number {
|
|
79
|
+
if (range === ScrollRange.Page) {
|
|
80
|
+
const travel = box.height - view.height;
|
|
81
|
+
return travel > 0 ? clamp01((view.top - box.top) / travel) : 0;
|
|
82
|
+
}
|
|
83
|
+
const { start, end } = rangeEnds(range, box, view);
|
|
84
|
+
const t = box.top - view.top;
|
|
85
|
+
if (start === end) return t <= start ? 1 : 0;
|
|
86
|
+
return clamp01((start - t) / (start - end));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The parallax trio (round three's back · middle · front). Middle is the page's own speed, so it is no action at all.
|
|
91
|
+
* Back glides slower than the page, front faster: a share of the scroll it travels through.
|
|
92
|
+
*/
|
|
93
|
+
export enum ParallaxDepth {
|
|
94
|
+
Back = 'back',
|
|
95
|
+
Front = 'front',
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const PARALLAX_DEPTH_DEFAULT = ParallaxDepth.Back;
|
|
99
|
+
|
|
100
|
+
/** The share of the scroll a depth moves against the page. Round three moved its layers by about this much. */
|
|
101
|
+
export const PARALLAX_SPEED = 0.3;
|
|
102
|
+
/** A phone's layers move half as far: on a narrow stack a glide reaches the next block sooner (round three's phone rule). */
|
|
103
|
+
export const PARALLAX_PHONE_FACTOR = 0.5;
|
|
104
|
+
|
|
105
|
+
export function normalizeParallaxDepth(value: unknown): ParallaxDepth {
|
|
106
|
+
return value === ParallaxDepth.Front ? ParallaxDepth.Front : PARALLAX_DEPTH_DEFAULT;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* How far a layer stands off its place at each end of its range, in the box's px: it runs from `-shift` to `+shift`
|
|
111
|
+
* (back) or the other way (front), and stands exactly in its place halfway. Never more than the share of one screen, so
|
|
112
|
+
* a tall layer never slides a screen away from what it belongs to.
|
|
113
|
+
*/
|
|
114
|
+
export function parallaxShift(distance: number, viewHeight: number, options: { phone?: boolean } = {}): number {
|
|
115
|
+
const speed = PARALLAX_SPEED * (options.phone ? PARALLAX_PHONE_FACTOR : 1);
|
|
116
|
+
const shift = speed * Math.min(Math.max(0, distance) / 2, Math.max(0, viewHeight));
|
|
117
|
+
return Math.round(shift * 10) / 10;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The frames of a parallax depth over its range: the individual `translate` property, so the element's own `transform`
|
|
121
|
+
* (a hover lift, an entrance) is never overwritten. */
|
|
122
|
+
export function parallaxFrames(depth: ParallaxDepth, shift: number): Array<Record<string, string>> {
|
|
123
|
+
const sign = depth === ParallaxDepth.Front ? -1 : 1;
|
|
124
|
+
return [{ translate: `0 ${-sign * shift}px` }, { translate: `0 ${sign * shift}px` }];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A bar that fills along the reading direction: the individual `scale` property, from its reading start (iox-design.css). */
|
|
128
|
+
export const PROGRESS_BAR_FRAMES: ReadonlyArray<Record<string, string>> = Object.freeze([{ scale: '0 1' }, { scale: '1 1' }]);
|
|
129
|
+
|
|
130
|
+
/** What a scroll-driven action is, for what each visitor gets of it (`scrollPlayFor`). */
|
|
131
|
+
export enum ScrollActionKind {
|
|
132
|
+
/** A glide at a depth: pure decoration. */
|
|
133
|
+
Parallax = 'parallax',
|
|
134
|
+
/** How much has been read: information, tied to the visitor's own scroll. */
|
|
135
|
+
Progress = 'progress',
|
|
136
|
+
/** Any entrance or exit, played by the scroll instead of the clock. */
|
|
137
|
+
Scrub = 'scrub',
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** What a visitor gets of one scroll-driven action. */
|
|
141
|
+
export enum ScrollPlay {
|
|
142
|
+
/** All of it. */
|
|
143
|
+
Full = 'full',
|
|
144
|
+
/** Its opacity only: no movement (reduced motion, Emil 192: gentler, not zero). */
|
|
145
|
+
Gentle = 'gentle',
|
|
146
|
+
/** Nothing: the element stands as it is, where it is. */
|
|
147
|
+
Rest = 'rest',
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface ScrollMotionEnv {
|
|
151
|
+
reducedMotion: boolean;
|
|
152
|
+
/** Save-Data, or a device that says it has little memory (`lightMotionWanted`). */
|
|
153
|
+
light: boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const PLAY: Readonly<Record<ScrollActionKind, { reduced: ScrollPlay; light: ScrollPlay }>> = {
|
|
157
|
+
// Decoration goes first: reduced motion and a light device keep the layer in its place.
|
|
158
|
+
[ScrollActionKind.Parallax]: { reduced: ScrollPlay.Rest, light: ScrollPlay.Rest },
|
|
159
|
+
// A reading bar is the visitor's own scroll drawn: it stays, and under reduced motion it follows with no glide.
|
|
160
|
+
[ScrollActionKind.Progress]: { reduced: ScrollPlay.Full, light: ScrollPlay.Full },
|
|
161
|
+
// A scrubbed fade keeps its fade under reduced motion; a light device sees the element as it rests.
|
|
162
|
+
[ScrollActionKind.Scrub]: { reduced: ScrollPlay.Gentle, light: ScrollPlay.Rest },
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** THE degrade (motion-v2 §3d/§3e): one table, read by the canvas and both engine paths. */
|
|
166
|
+
export function scrollPlayFor(kind: ScrollActionKind, env: ScrollMotionEnv): ScrollPlay {
|
|
167
|
+
if (env.reducedMotion) return PLAY[kind].reduced;
|
|
168
|
+
if (env.light) return PLAY[kind].light;
|
|
169
|
+
return ScrollPlay.Full;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Properties a Gentle play keeps: what changes colour or opacity, never place. */
|
|
173
|
+
const GENTLE_PROPERTIES: ReadonlySet<string> = new Set(['opacity', 'color', 'backgroundColor', 'offset', 'easing']);
|
|
174
|
+
|
|
175
|
+
/** A frame list cut down to what a Gentle play keeps; empty when nothing is left to play. */
|
|
176
|
+
export function gentleFrames<T extends Record<string, unknown>>(frames: ReadonlyArray<T>): T[] {
|
|
177
|
+
const cut = frames.map(frame => Object.fromEntries(Object.entries(frame).filter(([key]) => GENTLE_PROPERTIES.has(key))) as T);
|
|
178
|
+
return cut.some(frame => Object.keys(frame).some(key => key !== 'offset' && key !== 'easing')) ? cut : [];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface LightHost {
|
|
182
|
+
navigator?: Navigator & { connection?: { saveData?: boolean }; deviceMemory?: number };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The least memory a device may report before decoration stays still. Not `hardwareConcurrency`: Safari caps it, and an
|
|
186
|
+
* iPhone would read as a weak device. */
|
|
187
|
+
const LIGHT_DEVICE_MEMORY_GB = 2;
|
|
188
|
+
|
|
189
|
+
/** True when the visitor asked to save data, or the device reports little memory: scrubs and depths rest. */
|
|
190
|
+
export function lightMotionWanted(host: LightHost | null | undefined = typeof window !== 'undefined' ? window : null): boolean {
|
|
191
|
+
const nav = host?.navigator;
|
|
192
|
+
if (!nav) return false;
|
|
193
|
+
if (nav.connection?.saveData) return true;
|
|
194
|
+
return typeof nav.deviceMemory === 'number' && nav.deviceMemory <= LIGHT_DEVICE_MEMORY_GB;
|
|
195
|
+
}
|
package/styles/iox-design.css
CHANGED
|
@@ -642,7 +642,7 @@ span.iox-video__play { pointer-events: none; }
|
|
|
642
642
|
|
|
643
643
|
/* ── Premium components M4 (Emil 55/85): a press lands faster than its release ──────────────────────────────────────
|
|
644
644
|
While pressed, every pressable's transition runs on dur-press; it releases on its own (slower) dur-fast. */
|
|
645
|
-
:is(.iox-es-button-primary, .iox-es-button-secondary, .iox-es-button-ghost, .iox-es-bottom-bar-item):active {
|
|
645
|
+
:is(.iox-es-button-primary, .iox-es-button-secondary, .iox-es-button-ghost, .iox-es-bottom-bar-item, .iox-es-marquee-control):active {
|
|
646
646
|
transition-duration: var(--iox-dur-press, 100ms);
|
|
647
647
|
}
|
|
648
648
|
|
|
@@ -918,3 +918,51 @@ html:has(.iox-bar-reserve) .iox-toasts[data-iox-edge='bottom'] { bottom: calc(16
|
|
|
918
918
|
@starting-style { [data-iox-popover][popover][data-iox-sheet][data-iox-sheet]:popover-open { opacity: 0; translate: none; } }
|
|
919
919
|
[data-iox-popover][popover][data-iox-sheet][data-iox-sheet][data-iox-closing] { opacity: 0; translate: none; }
|
|
920
920
|
}
|
|
921
|
+
|
|
922
|
+
/* ── Premium components M6 — a number that counts (N5), the Marquee (N6), scroll-driven motion outside a Scene (N7) ──
|
|
923
|
+
A number a count plays on is tabular from the first paint (Emil 176), so its box never changes width when the count
|
|
924
|
+
starts or ends. */
|
|
925
|
+
[data-iox-count] { font-variant-numeric: tabular-nums; }
|
|
926
|
+
|
|
927
|
+
/* The reading bar: empty until the scroll fills it (a visitor with no script sees no bar, never a full one), filling from
|
|
928
|
+
its reading start by `scale` — never a width (Emil 41). The runtime turns the origin for a right-to-left page (it reads
|
|
929
|
+
the computed direction: a live page's RTL is CSS `direction`, never a `dir` attribute `:dir()` could see). */
|
|
930
|
+
[data-iox-progress] { scale: 0 1; transform-origin: 0 50%; }
|
|
931
|
+
|
|
932
|
+
/* A section holding a layer at a depth clips vertically: a glide never carries a layer onto the next section's ground
|
|
933
|
+
(round three, M1). `clip`, not `hidden`: no scroll container, so a sticky child still sticks. */
|
|
934
|
+
[data-iox-depth-clip] { overflow-y: clip; }
|
|
935
|
+
|
|
936
|
+
/* The Marquee: ONE linear loop (Emil 180) on the track and its copy, both started by the runtime's Running in the same
|
|
937
|
+
style pass, so they never drift. `translate`, so a hover lift on an item is never overwritten; the duration — and, in a
|
|
938
|
+
right-to-left band, the mirrored keyframes — are the runtime's, written on each track (it reads the computed direction). */
|
|
939
|
+
@keyframes iox-marquee { from { translate: 0 0; } to { translate: -100% 0; } }
|
|
940
|
+
@keyframes iox-marquee-rtl { from { translate: 0 0; } to { translate: 100% 0; } }
|
|
941
|
+
[data-iox-marquee-running] .iox-role-marquee-track { animation: iox-marquee 30s linear infinite; }
|
|
942
|
+
[data-iox-marquee-running][data-iox-marquee-direction="end"] .iox-role-marquee-track { animation-direction: reverse; }
|
|
943
|
+
/* Held: the visitor paused it, it is off screen or the tab is hidden; and while focus is on an item inside. */
|
|
944
|
+
[data-iox-marquee-paused] .iox-role-marquee-track,
|
|
945
|
+
[data-iox-marquee] .iox-role-marquee-rail:focus-within .iox-role-marquee-track { animation-play-state: paused; }
|
|
946
|
+
@media (hover: hover) and (pointer: fine) {
|
|
947
|
+
[data-iox-marquee-hover] .iox-role-marquee-rail:hover .iox-role-marquee-track { animation-play-state: paused; }
|
|
948
|
+
}
|
|
949
|
+
/* Its edges fade on an eased curve (Emil 174), so the words arrive and leave with no visible edge. */
|
|
950
|
+
[data-iox-marquee-fade] .iox-role-marquee-rail {
|
|
951
|
+
--marquee-edge: var(--iox-marquee-fade, 48px);
|
|
952
|
+
mask-image: linear-gradient(to right,
|
|
953
|
+
rgb(0 0 0 / 0) 0, rgb(0 0 0 / 0.2) calc(var(--marquee-edge) * 0.35), rgb(0 0 0 / 0.6) calc(var(--marquee-edge) * 0.7),
|
|
954
|
+
rgb(0 0 0) var(--marquee-edge), rgb(0 0 0) calc(100% - var(--marquee-edge)),
|
|
955
|
+
rgb(0 0 0 / 0.6) calc(100% - var(--marquee-edge) * 0.7), rgb(0 0 0 / 0.2) calc(100% - var(--marquee-edge) * 0.35), rgb(0 0 0 / 0) 100%);
|
|
956
|
+
}
|
|
957
|
+
/* Still for good (a look whose motion is Off): nothing moves, so there is nothing to pause. */
|
|
958
|
+
[data-iox-marquee-still] .iox-role-marquee-pause { display: none; }
|
|
959
|
+
/* Reduced motion (D5): the band stops completely and wraps into a still row, from the first paint; its control goes.
|
|
960
|
+
The canvas keeps the control, so the author can still select and style it. */
|
|
961
|
+
@media (prefers-reduced-motion: reduce) {
|
|
962
|
+
[data-iox-marquee] .iox-role-marquee-track {
|
|
963
|
+
animation: none !important; flex-wrap: wrap !important; justify-content: center !important;
|
|
964
|
+
flex-shrink: 1 !important; width: 100% !important; padding-inline-end: 0 !important;
|
|
965
|
+
}
|
|
966
|
+
[data-iox-marquee] .iox-role-marquee-rail { mask-image: none; }
|
|
967
|
+
[data-iox-marquee]:not(#canvas-preview *, .global-elements-overlay *) .iox-role-marquee-pause { display: none; }
|
|
968
|
+
}
|