@vectoriox/iox-ui 5.182.0 → 5.183.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/fesm2022/vectoriox-iox-ui-harness-core.mjs +19 -3
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +53 -12
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/harness-core/index.d.ts +10 -2
- package/package.json +1 -1
- package/scene-core/index.d.ts +25 -1
- package/src/harness-core/starting-design.ts +24 -4
- package/src/scene-core/arrival.ts +46 -0
- package/src/scene-core/public-api.ts +1 -0
- package/src/scene-core/scroll-driver.ts +5 -10
|
@@ -2,6 +2,53 @@ import { SceneRole, makeCompositePart, NO_ELEMENT_STYLE, writeLayerStyles, write
|
|
|
2
2
|
import { FRAMES_PHONE_MAX_WIDTH, VideoAttribute, VideoClass, FILM_SMOOTH_PER_SCREEN, normalizeFrameSequence, FramePlayer } from '@vectoriox/iox-ui/media-core';
|
|
3
3
|
import { graphemes } from '@vectoriox/iox-ui/design-core';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* When an element ARRIVES on the screen — the moment a viewport entrance (`viewportEnter`) plays and a word with no landing
|
|
7
|
+
* to wait for comes in (`onSceneLand`). ONE rule for every interaction runtime: the builder canvas, the engine and
|
|
8
|
+
* scene-core itself. Framework-free; it asks the host's IntersectionObserver.
|
|
9
|
+
*
|
|
10
|
+
* An element arrives once a tenth of IT shows — or a tenth of the SCREEN shows it, whichever comes first. The second
|
|
11
|
+
* half is what a tall element needs: a list of six cards stacked one under another on a phone is three screens tall, so a
|
|
12
|
+
* tenth of it is more than the space a page header leaves below itself, and an entrance waiting for that tenth never
|
|
13
|
+
* plays on the first screen — the visitor sees an empty band where the cards are (vectoriox/iox-ui#156). An element
|
|
14
|
+
* shorter than the screen arrives exactly as before (a tenth of it shows before a tenth of the screen does).
|
|
15
|
+
*/
|
|
16
|
+
/** The share of an element — or of the screen — that must show before the element arrives. */
|
|
17
|
+
const ARRIVE_SHARE = 0.1;
|
|
18
|
+
/** The observer that asks "does a tenth of the element show". */
|
|
19
|
+
const ARRIVE_ELEMENT_OPTIONS = { threshold: ARRIVE_SHARE };
|
|
20
|
+
/** The observer that asks "does the element show in the screen less its last tenth" — its top a tenth of the screen up. */
|
|
21
|
+
const ARRIVE_SCREEN_OPTIONS = { threshold: 0, rootMargin: `0px 0px -${ARRIVE_SHARE * 100}% 0px` };
|
|
22
|
+
/**
|
|
23
|
+
* Watch `el` arrive and leave: `onChange(true)` as it arrives (either half of the rule), `onChange(false)` as it leaves
|
|
24
|
+
* (neither half holds), each only when the answer changes. Returns the way to let go — or null when the host has no
|
|
25
|
+
* IntersectionObserver (an old browser), so the caller keeps its own stand-in.
|
|
26
|
+
*/
|
|
27
|
+
function watchArrival(el, onChange, host = window) {
|
|
28
|
+
const Observer = host.IntersectionObserver;
|
|
29
|
+
if (!Observer)
|
|
30
|
+
return null;
|
|
31
|
+
const seen = { element: false, screen: false };
|
|
32
|
+
let arrived = false;
|
|
33
|
+
const watch = (half, options) => {
|
|
34
|
+
const io = new Observer(entries => {
|
|
35
|
+
const entry = entries.filter(e => e.target === el).pop();
|
|
36
|
+
if (!entry)
|
|
37
|
+
return;
|
|
38
|
+
seen[half] = entry.isIntersecting;
|
|
39
|
+
const now = seen.element || seen.screen;
|
|
40
|
+
if (now === arrived)
|
|
41
|
+
return;
|
|
42
|
+
arrived = now;
|
|
43
|
+
onChange(now);
|
|
44
|
+
}, options);
|
|
45
|
+
io.observe(el);
|
|
46
|
+
return io;
|
|
47
|
+
};
|
|
48
|
+
const observers = [watch('element', ARRIVE_ELEMENT_OPTIONS), watch('screen', ARRIVE_SCREEN_OPTIONS)];
|
|
49
|
+
return () => observers.forEach(io => io.disconnect());
|
|
50
|
+
}
|
|
51
|
+
|
|
5
52
|
/**
|
|
6
53
|
* A Scene's data and maths (premium-sites plan §5b). A Scene is a recipe of ordinary nodes — a tall Section, a pinned
|
|
7
54
|
* stage inside it, ordinary nodes as layers — so every word stays real, bound and translatable, and all three render
|
|
@@ -1389,8 +1436,6 @@ const SCENE_LAND_TRIGGER = 'sceneLand';
|
|
|
1389
1436
|
const SCENE_LAND_EVENT = 'iox-scene-land';
|
|
1390
1437
|
/** Progress short of a landing that still counts as landed: the damping settles onto the scroll, never past it. */
|
|
1391
1438
|
const LANDED_SLACK = 1e-4;
|
|
1392
|
-
/** How much of an element must show before a word with no landing to wait for arrives (the runtimes' viewport entry). */
|
|
1393
|
-
const ARRIVE_THRESHOLD = 0.1;
|
|
1394
1439
|
/**
|
|
1395
1440
|
* Where a Scene of steps (each covering the one before once it lands) must stand for step `index` to be in FRONT, or null
|
|
1396
1441
|
* when it already is — or when no step moves (nothing covers anything; a phone stacks them). Step i is in front from its
|
|
@@ -2148,15 +2193,11 @@ function onSceneLand(el, run, host = window) {
|
|
|
2148
2193
|
layer.addEventListener(SCENE_LAND_EVENT, heard);
|
|
2149
2194
|
offs.push(() => layer.removeEventListener(SCENE_LAND_EVENT, heard));
|
|
2150
2195
|
}
|
|
2151
|
-
|
|
2152
|
-
if (
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
go();
|
|
2157
|
-
}, { threshold: ARRIVE_THRESHOLD });
|
|
2158
|
-
io.observe(el);
|
|
2159
|
-
offs.push(() => io.disconnect());
|
|
2196
|
+
// Where a driver plays the travel it decides; the viewport only stands in where none does (`watchArrival`'s rule).
|
|
2197
|
+
const unwatch = watchArrival(el, arrived => { if (arrived && !(layer && landingDriverOf(layer)))
|
|
2198
|
+
go(); }, host);
|
|
2199
|
+
if (unwatch) {
|
|
2200
|
+
offs.push(unwatch);
|
|
2160
2201
|
}
|
|
2161
2202
|
else {
|
|
2162
2203
|
// No observer to ask (an old browser): it stands in place on the next frame unless a driver will land it.
|
|
@@ -2184,5 +2225,5 @@ function onSceneLand(el, run, host = window) {
|
|
|
2184
2225
|
* Generated bundle index. Do not edit.
|
|
2185
2226
|
*/
|
|
2186
2227
|
|
|
2187
|
-
export { LENIS_SMOOTH_CLASS, LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, REVEAL_STAGGER_MAX_MS, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LAND_EVENT, SCENE_LAND_TRIGGER, 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, boxInside, buildSceneRecipe, colourAt, crossesStage, crossingOf, dampToward, followToward, gentleFrames, heldProgress, holdLookAt, isHoldTrack, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, onSceneLand, outermostNodeOf, pageScroller, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, progressShowingFocus, progressShowingStep, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrollSubpixel, scrubPieceProgress, scrubTextReveal, setPageScroller, splitForReveal, splitText, stepLanding, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, textRevealStaggerOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, travellingLayerOf, unmovedBox, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
2228
|
+
export { ARRIVE_ELEMENT_OPTIONS, ARRIVE_SCREEN_OPTIONS, ARRIVE_SHARE, LENIS_SMOOTH_CLASS, LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, REVEAL_STAGGER_MAX_MS, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LAND_EVENT, SCENE_LAND_TRIGGER, 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, boxInside, buildSceneRecipe, colourAt, crossesStage, crossingOf, dampToward, followToward, gentleFrames, heldProgress, holdLookAt, isHoldTrack, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, onSceneLand, outermostNodeOf, pageScroller, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, progressShowingFocus, progressShowingStep, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrollSubpixel, scrubPieceProgress, scrubTextReveal, setPageScroller, splitForReveal, splitText, stepLanding, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, textRevealStaggerOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, travellingLayerOf, unmovedBox, valueAt, watchArrival, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
|
|
2188
2229
|
//# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map
|