@vectoriox/iox-ui 5.87.0 → 5.89.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 +659 -118
- 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 +1082 -51
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +244 -7
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +604 -20
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +375 -2
- package/index.d.ts +196 -2
- package/package.json +1 -1
- package/scene-core/index.d.ts +167 -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/slider.ts +3 -2
- 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/compose-layout.ts +821 -0
- package/src/generation-core/compose-site.ts +14 -2
- package/src/generation-core/layout-language.ts +354 -0
- package/src/generation-core/node-baselines.generated.ts +5 -1
- package/src/generation-core/public-api.ts +2 -0
- 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 +208 -0
- package/styles/iox-design.css +66 -1
|
@@ -62,16 +62,16 @@ const SLIDER_SCROLL_STEP_SCREENS = 0.55;
|
|
|
62
62
|
function heldProgress(p, n) {
|
|
63
63
|
if (!(n >= 2) || !Number.isFinite(p))
|
|
64
64
|
return 0;
|
|
65
|
-
const s = clamp01(p) * (n - 1);
|
|
65
|
+
const s = clamp01$1(p) * (n - 1);
|
|
66
66
|
const i = Math.min(n - 2, Math.floor(s));
|
|
67
|
-
const f = clamp01((s - i - SLIDER_HOLD_SHARE) / (1 - 2 * SLIDER_HOLD_SHARE));
|
|
67
|
+
const f = clamp01$1((s - i - SLIDER_HOLD_SHARE) / (1 - 2 * SLIDER_HOLD_SHARE));
|
|
68
68
|
return round((i + smoothstep(f)) / (n - 1));
|
|
69
69
|
}
|
|
70
70
|
/** At or under this stage width a layer plays its phone tracks. The `mobile` breakpoint's width. */
|
|
71
71
|
const SCENE_PHONE_MAX_WIDTH = FRAMES_PHONE_MAX_WIDTH;
|
|
72
72
|
const DECIMALS = 10000;
|
|
73
73
|
const round = (v) => Math.round(v * DECIMALS) / DECIMALS;
|
|
74
|
-
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
74
|
+
const clamp01$1 = (v) => Math.min(1, Math.max(0, v));
|
|
75
75
|
const smoothstep = (t) => t * t * (3 - 2 * t);
|
|
76
76
|
/** A colour a track may hold: a hex, an rgb()/hsl() literal, or a design token. Anything else could break out of the
|
|
77
77
|
* inline style it lands in. */
|
|
@@ -137,7 +137,7 @@ function revealClipPath(showing, from = SCENE_REVEAL_DEFAULT, inlineSign = 1) {
|
|
|
137
137
|
const linear = (t) => t;
|
|
138
138
|
/** The two keys around `p` and how far between them it has come. */
|
|
139
139
|
function span(keys, p, ease = smoothstep) {
|
|
140
|
-
const at = clamp01(p);
|
|
140
|
+
const at = clamp01$1(p);
|
|
141
141
|
if (at <= keys[0][0])
|
|
142
142
|
return { a: keys[0], b: keys[0], f: 0 };
|
|
143
143
|
for (let i = 1; i < keys.length; i++) {
|
|
@@ -186,7 +186,7 @@ function sceneFrame(tracks, p, options = {}) {
|
|
|
186
186
|
if (prop in TRANSFORM_REST)
|
|
187
187
|
moves[prop] = valueAt(keys, p);
|
|
188
188
|
else if (prop === SceneProp.Opacity) {
|
|
189
|
-
const opacity = clamp01(valueAt(keys, p));
|
|
189
|
+
const opacity = clamp01$1(valueAt(keys, p));
|
|
190
190
|
frame.opacity = String(opacity);
|
|
191
191
|
frame.pointerEvents = opacity > 0 ? '' : 'none';
|
|
192
192
|
}
|
|
@@ -221,7 +221,7 @@ function scenePlayed(tracks, p) {
|
|
|
221
221
|
}
|
|
222
222
|
/** Word `index` of `count`, with `lit` % lit: words light one after the other, each easing in as the last finishes. */
|
|
223
223
|
function sceneWordOpacity(index, count, lit) {
|
|
224
|
-
return round(SCENE_WORD_DIM + (1 - SCENE_WORD_DIM) * clamp01((lit / PERCENT$1) * count - index));
|
|
224
|
+
return round(SCENE_WORD_DIM + (1 - SCENE_WORD_DIM) * clamp01$1((lit / PERCENT$1) * count - index));
|
|
225
225
|
}
|
|
226
226
|
const CSS_NAME = {
|
|
227
227
|
transform: 'transform',
|
|
@@ -618,6 +618,186 @@ function buildSceneRecipe(create, words = {}) {
|
|
|
618
618
|
return root;
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Scroll-driven motion outside a Scene (premium components M6, N7 — Motion v2 V1). An element plays its actions by WHERE
|
|
623
|
+
* 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
|
|
624
|
+
* fills as the page is read. Every one of them rides the ONE `ScrollDriver` (its links), never a loop of its own.
|
|
625
|
+
*
|
|
626
|
+
* The ranges are CSS's named view-timeline ranges, so a `view()` timeline could take them over 1:1, plus the whole page
|
|
627
|
+
* (a reading-progress bar). The maths is pure: geometry in, progress out, the same at any canvas zoom because every length
|
|
628
|
+
* is in one space.
|
|
629
|
+
*/
|
|
630
|
+
var ScrollRange;
|
|
631
|
+
(function (ScrollRange) {
|
|
632
|
+
/** From the element's top edge at the bottom of the screen until it is wholly in (CSS `entry`). */
|
|
633
|
+
ScrollRange["Enter"] = "enter";
|
|
634
|
+
/** From the moment it starts to come in until it has wholly left (CSS `cover`). */
|
|
635
|
+
ScrollRange["Cover"] = "cover";
|
|
636
|
+
/** While it is wholly in view, or, when it is taller than the screen, while it fills it (CSS `contain`). */
|
|
637
|
+
ScrollRange["Contain"] = "contain";
|
|
638
|
+
/** From the moment it starts to leave until it has gone (CSS `exit`). */
|
|
639
|
+
ScrollRange["Exit"] = "exit";
|
|
640
|
+
/** The section the element stands in, while it is read: Contain, measured on the section (a section's reading bar). */
|
|
641
|
+
ScrollRange["Section"] = "section";
|
|
642
|
+
/** The whole page, from its top to its bottom: how much of it has been read. */
|
|
643
|
+
ScrollRange["Page"] = "page";
|
|
644
|
+
})(ScrollRange || (ScrollRange = {}));
|
|
645
|
+
const SCROLL_RANGE_DEFAULT = ScrollRange.Cover;
|
|
646
|
+
const RANGES = new Set(Object.values(ScrollRange));
|
|
647
|
+
/** The node element that holds `el` outermost — its section on the page — stopping below `stop`. A node element is one
|
|
648
|
+
* carrying its `iox-node-<id>` class, in every render path; a wrapper a renderer drew around nodes is never one. */
|
|
649
|
+
function outermostNodeOf(el, stop = null) {
|
|
650
|
+
let found = el;
|
|
651
|
+
for (let p = el.parentElement; p && p !== stop; p = p.parentElement) {
|
|
652
|
+
if (Array.from(p.classList).some(c => c.startsWith('iox-node-')))
|
|
653
|
+
found = p;
|
|
654
|
+
}
|
|
655
|
+
return found;
|
|
656
|
+
}
|
|
657
|
+
/** A saved range, or the default for anything else. */
|
|
658
|
+
function normalizeScrollRange(value) {
|
|
659
|
+
return typeof value === 'string' && RANGES.has(value) ? value : SCROLL_RANGE_DEFAULT;
|
|
660
|
+
}
|
|
661
|
+
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
662
|
+
/** Where a range starts and ends, as the element's top relative to the view's top. */
|
|
663
|
+
function rangeEnds(range, box, view) {
|
|
664
|
+
const vh = view.height;
|
|
665
|
+
const h = box.height;
|
|
666
|
+
const fit = vh - h;
|
|
667
|
+
switch (range) {
|
|
668
|
+
case ScrollRange.Enter: return { start: vh, end: Math.max(fit, 0) };
|
|
669
|
+
case ScrollRange.Contain:
|
|
670
|
+
case ScrollRange.Section: return { start: Math.max(fit, 0), end: Math.min(fit, 0) };
|
|
671
|
+
case ScrollRange.Exit: return { start: Math.min(fit, 0), end: -h };
|
|
672
|
+
default: return { start: vh, end: -h };
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
/** How far the scroll travels through a range, in the box's space: what a parallax depth is a share of. */
|
|
676
|
+
function rangeDistance(range, box, view) {
|
|
677
|
+
if (range === ScrollRange.Page)
|
|
678
|
+
return Math.max(0, box.height - view.height);
|
|
679
|
+
const { start, end } = rangeEnds(range, box, view);
|
|
680
|
+
return Math.abs(start - end);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* 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
|
|
684
|
+
* bottom reaches the bottom of the view. A range of no length is a step: 0 before it, 1 from it on.
|
|
685
|
+
*/
|
|
686
|
+
function rangeProgress(range, box, view) {
|
|
687
|
+
if (range === ScrollRange.Page) {
|
|
688
|
+
const travel = box.height - view.height;
|
|
689
|
+
return travel > 0 ? clamp01((view.top - box.top) / travel) : 0;
|
|
690
|
+
}
|
|
691
|
+
const { start, end } = rangeEnds(range, box, view);
|
|
692
|
+
const t = box.top - view.top;
|
|
693
|
+
if (start === end)
|
|
694
|
+
return t <= start ? 1 : 0;
|
|
695
|
+
return clamp01((start - t) / (start - end));
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* The parallax trio (round three's back · middle · front). Middle is the page's own speed, so it is no action at all.
|
|
699
|
+
* Back glides slower than the page, front faster: a share of the scroll it travels through.
|
|
700
|
+
*/
|
|
701
|
+
var ParallaxDepth;
|
|
702
|
+
(function (ParallaxDepth) {
|
|
703
|
+
ParallaxDepth["Back"] = "back";
|
|
704
|
+
ParallaxDepth["Front"] = "front";
|
|
705
|
+
})(ParallaxDepth || (ParallaxDepth = {}));
|
|
706
|
+
const PARALLAX_DEPTH_DEFAULT = ParallaxDepth.Back;
|
|
707
|
+
/** The share of the scroll a depth moves against the page. Round three moved its layers by about this much. */
|
|
708
|
+
const PARALLAX_SPEED = 0.3;
|
|
709
|
+
/** A phone's layers move half as far: on a narrow stack a glide reaches the next block sooner (round three's phone rule). */
|
|
710
|
+
const PARALLAX_PHONE_FACTOR = 0.5;
|
|
711
|
+
/** What a depth does on a phone (its action's `params.phone`). */
|
|
712
|
+
var ParallaxPhone;
|
|
713
|
+
(function (ParallaxPhone) {
|
|
714
|
+
/** Half as far (round three's phone rule; a depth with no `phone` param). */
|
|
715
|
+
ParallaxPhone["Half"] = "half";
|
|
716
|
+
/** Still: a layer that stacks with its neighbours on a phone never glides into them (round four, CL2 layers). */
|
|
717
|
+
ParallaxPhone["Rest"] = "rest";
|
|
718
|
+
})(ParallaxPhone || (ParallaxPhone = {}));
|
|
719
|
+
function normalizeParallaxPhone(value) {
|
|
720
|
+
return value === ParallaxPhone.Rest ? ParallaxPhone.Rest : ParallaxPhone.Half;
|
|
721
|
+
}
|
|
722
|
+
function normalizeParallaxDepth(value) {
|
|
723
|
+
return value === ParallaxDepth.Front ? ParallaxDepth.Front : PARALLAX_DEPTH_DEFAULT;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* 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`
|
|
727
|
+
* (back) or the other way (front), and stands exactly in its place halfway. Never more than the share of one screen, so
|
|
728
|
+
* a tall layer never slides a screen away from what it belongs to.
|
|
729
|
+
*/
|
|
730
|
+
function parallaxShift(distance, viewHeight, options = {}) {
|
|
731
|
+
if (options.phone && options.onPhone === ParallaxPhone.Rest)
|
|
732
|
+
return 0;
|
|
733
|
+
const speed = PARALLAX_SPEED * (options.phone ? PARALLAX_PHONE_FACTOR : 1);
|
|
734
|
+
const shift = speed * Math.min(Math.max(0, distance) / 2, Math.max(0, viewHeight));
|
|
735
|
+
return Math.round(shift * 10) / 10;
|
|
736
|
+
}
|
|
737
|
+
/** The frames of a parallax depth over its range: the individual `translate` property, so the element's own `transform`
|
|
738
|
+
* (a hover lift, an entrance) is never overwritten. */
|
|
739
|
+
function parallaxFrames(depth, shift) {
|
|
740
|
+
const sign = depth === ParallaxDepth.Front ? -1 : 1;
|
|
741
|
+
return [{ translate: `0 ${-sign * shift}px` }, { translate: `0 ${sign * shift}px` }];
|
|
742
|
+
}
|
|
743
|
+
/** A bar that fills along the reading direction: the individual `scale` property, from its reading start (iox-design.css). */
|
|
744
|
+
const PROGRESS_BAR_FRAMES = Object.freeze([{ scale: '0 1' }, { scale: '1 1' }]);
|
|
745
|
+
/** What a scroll-driven action is, for what each visitor gets of it (`scrollPlayFor`). */
|
|
746
|
+
var ScrollActionKind;
|
|
747
|
+
(function (ScrollActionKind) {
|
|
748
|
+
/** A glide at a depth: pure decoration. */
|
|
749
|
+
ScrollActionKind["Parallax"] = "parallax";
|
|
750
|
+
/** How much has been read: information, tied to the visitor's own scroll. */
|
|
751
|
+
ScrollActionKind["Progress"] = "progress";
|
|
752
|
+
/** Any entrance or exit, played by the scroll instead of the clock. */
|
|
753
|
+
ScrollActionKind["Scrub"] = "scrub";
|
|
754
|
+
})(ScrollActionKind || (ScrollActionKind = {}));
|
|
755
|
+
/** What a visitor gets of one scroll-driven action. */
|
|
756
|
+
var ScrollPlay;
|
|
757
|
+
(function (ScrollPlay) {
|
|
758
|
+
/** All of it. */
|
|
759
|
+
ScrollPlay["Full"] = "full";
|
|
760
|
+
/** Its opacity only: no movement (reduced motion, Emil 192: gentler, not zero). */
|
|
761
|
+
ScrollPlay["Gentle"] = "gentle";
|
|
762
|
+
/** Nothing: the element stands as it is, where it is. */
|
|
763
|
+
ScrollPlay["Rest"] = "rest";
|
|
764
|
+
})(ScrollPlay || (ScrollPlay = {}));
|
|
765
|
+
const PLAY = {
|
|
766
|
+
// Decoration goes first: reduced motion and a light device keep the layer in its place.
|
|
767
|
+
[ScrollActionKind.Parallax]: { reduced: ScrollPlay.Rest, light: ScrollPlay.Rest },
|
|
768
|
+
// A reading bar is the visitor's own scroll drawn: it stays, and under reduced motion it follows with no glide.
|
|
769
|
+
[ScrollActionKind.Progress]: { reduced: ScrollPlay.Full, light: ScrollPlay.Full },
|
|
770
|
+
// A scrubbed fade keeps its fade under reduced motion; a light device sees the element as it rests.
|
|
771
|
+
[ScrollActionKind.Scrub]: { reduced: ScrollPlay.Gentle, light: ScrollPlay.Rest },
|
|
772
|
+
};
|
|
773
|
+
/** THE degrade (motion-v2 §3d/§3e): one table, read by the canvas and both engine paths. */
|
|
774
|
+
function scrollPlayFor(kind, env) {
|
|
775
|
+
if (env.reducedMotion)
|
|
776
|
+
return PLAY[kind].reduced;
|
|
777
|
+
if (env.light)
|
|
778
|
+
return PLAY[kind].light;
|
|
779
|
+
return ScrollPlay.Full;
|
|
780
|
+
}
|
|
781
|
+
/** Properties a Gentle play keeps: what changes colour or opacity, never place. */
|
|
782
|
+
const GENTLE_PROPERTIES = new Set(['opacity', 'color', 'backgroundColor', 'offset', 'easing']);
|
|
783
|
+
/** A frame list cut down to what a Gentle play keeps; empty when nothing is left to play. */
|
|
784
|
+
function gentleFrames(frames) {
|
|
785
|
+
const cut = frames.map(frame => Object.fromEntries(Object.entries(frame).filter(([key]) => GENTLE_PROPERTIES.has(key))));
|
|
786
|
+
return cut.some(frame => Object.keys(frame).some(key => key !== 'offset' && key !== 'easing')) ? cut : [];
|
|
787
|
+
}
|
|
788
|
+
/** The least memory a device may report before decoration stays still. Not `hardwareConcurrency`: Safari caps it, and an
|
|
789
|
+
* iPhone would read as a weak device. */
|
|
790
|
+
const LIGHT_DEVICE_MEMORY_GB = 2;
|
|
791
|
+
/** True when the visitor asked to save data, or the device reports little memory: scrubs and depths rest. */
|
|
792
|
+
function lightMotionWanted(host = typeof window !== 'undefined' ? window : null) {
|
|
793
|
+
const nav = host?.navigator;
|
|
794
|
+
if (!nav)
|
|
795
|
+
return false;
|
|
796
|
+
if (nav.connection?.saveData)
|
|
797
|
+
return true;
|
|
798
|
+
return typeof nav.deviceMemory === 'number' && nav.deviceMemory <= LIGHT_DEVICE_MEMORY_GB;
|
|
799
|
+
}
|
|
800
|
+
|
|
621
801
|
/**
|
|
622
802
|
* Text into pieces, in the browser only (premium sites SC3, Motion v2 §3c). A saved node keeps its plain text and the
|
|
623
803
|
* server sends it whole, so every word is in the raw response, editing never meets a piece, and there is no markup for
|
|
@@ -828,6 +1008,24 @@ function sceneScrollState(rootTop, originTop, zoom, travel) {
|
|
|
828
1008
|
const local = Math.min(travel, Math.max(0, -(rootTop - originTop) / (zoom || 1)));
|
|
829
1009
|
return { local, progress: local / travel };
|
|
830
1010
|
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Where an element's LAYOUT box stands on screen: its offsets up to the nearest box that has no offset parent, placed by
|
|
1013
|
+
* that box's own rectangle. Transforms on the element itself are not in it — a layer that glides is measured where it
|
|
1014
|
+
* 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.
|
|
1015
|
+
*/
|
|
1016
|
+
function layoutBoxOnScreen(el, within = null) {
|
|
1017
|
+
let offset = 0;
|
|
1018
|
+
let ref = el;
|
|
1019
|
+
// Never past `within` (the page): offsets inside the canvas's zoomed frame are its own px, and the box that places them
|
|
1020
|
+
// must be drawn at the same zoom.
|
|
1021
|
+
while (ref.offsetParent instanceof HTMLElement && (!within || within.contains(ref.offsetParent))) {
|
|
1022
|
+
offset += ref.offsetTop;
|
|
1023
|
+
ref = ref.offsetParent;
|
|
1024
|
+
}
|
|
1025
|
+
const rect = ref.getBoundingClientRect();
|
|
1026
|
+
const zoom = ref.offsetHeight > 0 && rect.height > 0 ? rect.height / ref.offsetHeight : 1;
|
|
1027
|
+
return { box: { top: rect.top + offset * zoom, height: el.offsetHeight * zoom }, zoom };
|
|
1028
|
+
}
|
|
831
1029
|
function parseTracks(raw) {
|
|
832
1030
|
if (!raw)
|
|
833
1031
|
return [];
|
|
@@ -842,6 +1040,7 @@ class ScrollDriver {
|
|
|
842
1040
|
constructor(options = {}) {
|
|
843
1041
|
this.options = options;
|
|
844
1042
|
this.scenes = new Map();
|
|
1043
|
+
this.links = new Set();
|
|
845
1044
|
this.frame = 0;
|
|
846
1045
|
this.lastTime = 0;
|
|
847
1046
|
this.wakeUp = () => this.wake();
|
|
@@ -856,6 +1055,8 @@ class ScrollDriver {
|
|
|
856
1055
|
const seconds = this.lastTime ? Math.min(MAX_FRAME_SECONDS, (now - this.lastTime) / 1000) : WAKING_FRAME_SECONDS;
|
|
857
1056
|
this.lastTime = now;
|
|
858
1057
|
const reads = [...this.scenes.values()].map(scene => this.read(scene));
|
|
1058
|
+
const view = this.links.size ? this.viewBox() : null;
|
|
1059
|
+
const linkReads = [...this.links].map(state => this.readLink(state, view));
|
|
859
1060
|
let moving = false;
|
|
860
1061
|
for (const { scene, local, target } of reads) {
|
|
861
1062
|
if (this.options.pin && scene.stage)
|
|
@@ -870,6 +1071,16 @@ class ScrollDriver {
|
|
|
870
1071
|
this.options.onFrame?.(scene.root, { target, progress: scene.progress });
|
|
871
1072
|
moving = moving || !settled;
|
|
872
1073
|
}
|
|
1074
|
+
for (const { state, target } of linkReads) {
|
|
1075
|
+
const immediate = state.fresh || !!state.link.immediate;
|
|
1076
|
+
const next = immediate ? target : dampToward(state.progress, target, seconds, this.options.damping);
|
|
1077
|
+
const settled = immediate || Math.abs(target - state.progress) * Math.max(1, state.geometry.distance) < SETTLED_PX;
|
|
1078
|
+
state.progress = settled ? target : next;
|
|
1079
|
+
state.target = target;
|
|
1080
|
+
state.fresh = false;
|
|
1081
|
+
state.link.write(state.progress, state.geometry);
|
|
1082
|
+
moving = moving || !settled;
|
|
1083
|
+
}
|
|
873
1084
|
if (moving)
|
|
874
1085
|
this.wake();
|
|
875
1086
|
else
|
|
@@ -964,6 +1175,20 @@ class ScrollDriver {
|
|
|
964
1175
|
scene.stage.style.setProperty('translate', `0 ${this.read(scene).local}px`);
|
|
965
1176
|
}
|
|
966
1177
|
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Follow where `link.measured` stands, on this loop. Returns the way to let go. A link that is added lands on its first
|
|
1180
|
+
* frame exactly where the scroll is, with no glide.
|
|
1181
|
+
*/
|
|
1182
|
+
addLink(link) {
|
|
1183
|
+
const state = { link, progress: 0, target: 0, fresh: true, geometry: { distance: 0, viewHeight: 0 } };
|
|
1184
|
+
this.links.add(state);
|
|
1185
|
+
this.wake();
|
|
1186
|
+
return () => { this.links.delete(state); };
|
|
1187
|
+
}
|
|
1188
|
+
/** True while it plays anything: a Scene or a link. */
|
|
1189
|
+
get busy() {
|
|
1190
|
+
return this.scenes.size > 0 || this.links.size > 0;
|
|
1191
|
+
}
|
|
967
1192
|
/** Something moved that no scroll or resize announces (the canvas's zoom). */
|
|
968
1193
|
wake() {
|
|
969
1194
|
if (this.frame)
|
|
@@ -979,6 +1204,7 @@ class ScrollDriver {
|
|
|
979
1204
|
this.host.removeEventListener(SCENE_WAKE_EVENT, this.onWakeEvent, { capture: true });
|
|
980
1205
|
for (const root of [...this.scenes.keys()])
|
|
981
1206
|
this.remove(root);
|
|
1207
|
+
this.links.clear();
|
|
982
1208
|
this.resize?.disconnect();
|
|
983
1209
|
}
|
|
984
1210
|
/** Read a root's stage and layers from its DOM: its own Scene's only, never a nested one's. */
|
|
@@ -1034,6 +1260,17 @@ class ScrollDriver {
|
|
|
1034
1260
|
for (const layer of scene.layers)
|
|
1035
1261
|
layer.stale = true;
|
|
1036
1262
|
}
|
|
1263
|
+
/** The part of the page on screen: the host's own, or the window. */
|
|
1264
|
+
viewBox() {
|
|
1265
|
+
return this.options.view?.() ?? { top: 0, height: this.host.innerHeight };
|
|
1266
|
+
}
|
|
1267
|
+
readLink(state, view) {
|
|
1268
|
+
const { box, zoom } = layoutBoxOnScreen(state.link.measured, state.link.within ?? null);
|
|
1269
|
+
const z = zoom || 1;
|
|
1270
|
+
const target = rangeProgress(state.link.range, box, view);
|
|
1271
|
+
state.geometry = { distance: rangeDistance(state.link.range, box, view) / z, viewHeight: view.height / z };
|
|
1272
|
+
return { state, target };
|
|
1273
|
+
}
|
|
1037
1274
|
read(scene) {
|
|
1038
1275
|
const rect = scene.root.getBoundingClientRect();
|
|
1039
1276
|
const origin = this.options.originOf?.(scene.root)?.getBoundingClientRect().top ?? 0;
|
|
@@ -1169,5 +1406,5 @@ function attachSceneRoots(roots, options = {}) {
|
|
|
1169
1406
|
* Generated bundle index. Do not edit.
|
|
1170
1407
|
*/
|
|
1171
1408
|
|
|
1172
|
-
export { LIGHT_UP_PIECE_CAP, 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, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollDriver, TextRevealBy, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, heldProgress, lineIndexes, movedSceneKey, normalizeTracks, playTextReveal, 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, splitText, syncSceneAttributes, textPieces, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
1409
|
+
export { LIGHT_UP_PIECE_CAP, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, 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, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, gentleFrames, heldProgress, layoutBoxOnScreen, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, parallaxFrames, 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, splitText, syncSceneAttributes, textPieces, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
1173
1410
|
//# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map
|