@vectoriox/iox-ui 5.161.0 → 5.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/design-core/index.d.ts +130 -0
- 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 +246 -5
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +241 -40
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/generation-core/index.d.ts +197 -1
- package/package.json +1 -1
- package/scene-core/index.d.ts +98 -10
- package/src/design-core/flavor-spec.generated.ts +152 -1
- package/src/generation-core/compose-layout.ts +11 -5
- package/src/generation-core/site-spec.generated.ts +235 -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 +130 -16
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@vectoriox/iox-ui/composite-core';
|
|
6
6
|
|
|
7
7
|
import { ColorScheme, DesignChoices, LIST_MIX_PROP, LinkType, scrubOfChoices, setColorScheme, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
8
|
-
import { TextRevealBy } from '@vectoriox/iox-ui/scene-core';
|
|
8
|
+
import { SCENE_TRACK_EASE, SceneEase, SceneProp, TextRevealBy } from '@vectoriox/iox-ui/scene-core';
|
|
9
9
|
import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
|
|
10
10
|
import { composeNavHeader, composePresetForm } from './compose-site';
|
|
11
11
|
import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
|
|
@@ -50,7 +50,8 @@ export enum LayoutGapCode {
|
|
|
50
50
|
Blur = 'blur',
|
|
51
51
|
/** M8-G3: `scaleIn` / `pop` start at the product's 0.8, not 0.95 / 0.9, and `pop` has no overshoot. */
|
|
52
52
|
ScaleIn = 'scale-in',
|
|
53
|
-
/** M8-G4: a held layer's keys
|
|
53
|
+
/** M8-G4: a held layer's keys run straight (travel) or smooth (a fade) — an `out` or `drawer` ease is drawn as its
|
|
54
|
+
* property's (award plan "Reddottours", RT-D1: travel linear, fades smooth; `linear` / `inOut` are drawn as asked). */
|
|
54
55
|
TrackEase = 'track-ease',
|
|
55
56
|
/** M8-G5: a depth glides at the product's one speed (no per-look scale), and a picture's own drift inside its frame
|
|
56
57
|
* is a fixed over-scale. */
|
|
@@ -520,7 +521,10 @@ function depthInteraction(nodeId: string, depth: string): unknown {
|
|
|
520
521
|
|
|
521
522
|
const TRACK_REST: Readonly<Record<string, number>> = { x: 0, y: 0, scale: 1, rotate: 0, opacity: 1, clip: 100, words: 100 };
|
|
522
523
|
|
|
523
|
-
interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string }
|
|
524
|
+
interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string; ease?: SceneEase }
|
|
525
|
+
|
|
526
|
+
/** The layout's eases the product's tracks can run (RT-D1); anything else is drawn as the property's own. */
|
|
527
|
+
const TRACK_EASE: Readonly<Partial<Record<LayoutEase, SceneEase>>> = { [LayoutEase.Linear]: SceneEase.Linear, [LayoutEase.InOut]: SceneEase.Smooth };
|
|
524
528
|
|
|
525
529
|
/** A layout track as a scene-core track: lengths move from the layer's own box to the stage's (cqw / cqh). */
|
|
526
530
|
function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, path: string): SceneTrackOut | null {
|
|
@@ -529,13 +533,16 @@ function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, pa
|
|
|
529
533
|
gap(ctx, LayoutGapCode.Blur, path, 'a blur track is dropped');
|
|
530
534
|
return null;
|
|
531
535
|
}
|
|
532
|
-
|
|
536
|
+
const own = SCENE_TRACK_EASE[t.prop as SceneProp];
|
|
537
|
+
const ease = t.ease ? TRACK_EASE[t.ease as LayoutEase] : undefined;
|
|
538
|
+
if (t.ease && !ease) gap(ctx, LayoutGapCode.TrackEase, path, `${t.prop} runs ${own === SceneEase.Linear ? 'straight' : 'smooth (smoothstep)'}, not ${t.ease}`);
|
|
533
539
|
let scale = 1;
|
|
534
540
|
if (t.prop === LayoutTrackProp.X) scale = (l.col[1] - l.col[0]) / GRID_COLUMNS;
|
|
535
541
|
if (t.prop === LayoutTrackProp.Y) scale = (l.row[1] - l.row[0]) / rows;
|
|
536
542
|
const round = (v: number) => Math.round(v * scale * 100) / 100;
|
|
537
543
|
const track: SceneTrackOut = { prop: t.prop, keys: [[a, round(Number(t.from))], [b, round(Number(t.to))]] };
|
|
538
544
|
if (t.prop === LayoutTrackProp.Clip) track.from = LayoutSide.Bottom;
|
|
545
|
+
if (ease && ease !== own) track.ease = ease;
|
|
539
546
|
return track;
|
|
540
547
|
}
|
|
541
548
|
|
|
@@ -1646,7 +1653,6 @@ function composeSection(s: LayoutSection, si: number, prevGround: string | null,
|
|
|
1646
1653
|
phone(wide, { width: FULL, ...phoneStack(si === 0) });
|
|
1647
1654
|
wide.sceneTracks = [{ prop: 'x', keys: [[0, 0], [1, -(track - 1) * 100]] }];
|
|
1648
1655
|
wide.scenePhoneTracks = [{ prop: 'x', keys: [[0, 0]] }];
|
|
1649
|
-
gap(ctx, LayoutGapCode.TrackEase, `sections[${si}]`, 'the sideways travel eases (smoothstep), not linear');
|
|
1650
1656
|
wide.children = layers;
|
|
1651
1657
|
stage.children = [wide];
|
|
1652
1658
|
}
|
|
@@ -10575,6 +10575,241 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
10575
10575
|
}
|
|
10576
10576
|
]
|
|
10577
10577
|
},
|
|
10578
|
+
"popup": {
|
|
10579
|
+
"ingredients": {
|
|
10580
|
+
"kind": [
|
|
10581
|
+
"announcement",
|
|
10582
|
+
"offer",
|
|
10583
|
+
"newsletter"
|
|
10584
|
+
],
|
|
10585
|
+
"form": [
|
|
10586
|
+
"corner",
|
|
10587
|
+
"bar",
|
|
10588
|
+
"centred"
|
|
10589
|
+
],
|
|
10590
|
+
"arrive": [
|
|
10591
|
+
"scroll",
|
|
10592
|
+
"time",
|
|
10593
|
+
"scrollOrTime",
|
|
10594
|
+
"leaving",
|
|
10595
|
+
"button"
|
|
10596
|
+
],
|
|
10597
|
+
"again": [
|
|
10598
|
+
"days",
|
|
10599
|
+
"visit",
|
|
10600
|
+
"once"
|
|
10601
|
+
],
|
|
10602
|
+
"art": [
|
|
10603
|
+
"none",
|
|
10604
|
+
"picture"
|
|
10605
|
+
]
|
|
10606
|
+
},
|
|
10607
|
+
"meanings": {
|
|
10608
|
+
"kind.announcement": "news the owner states: an opening, a new branch, holiday hours — one line and, if any, a link to the page that says more",
|
|
10609
|
+
"kind.offer": "an offer the owner states, in the owner's words — a picture, a short line and a link to the offer's page",
|
|
10610
|
+
"kind.newsletter": "an invitation to the owner's newsletter — a short line and the newsletter form",
|
|
10611
|
+
"form.corner": "a card at the bottom end corner (the start corner on a right-to-left site), 360–560 px wide; on a phone a bottom card at most 30% of the screen high",
|
|
10612
|
+
"form.bar": "a strip along the bottom edge, one line: at most 64 px high on a laptop, 88 px on a phone",
|
|
10613
|
+
"form.centred": "a centred card over the look's scrim — a newsletter on a laptop only; on a phone it shows as the corner card",
|
|
10614
|
+
"arrive.scroll": "once the visitor has scrolled half of the first screen — the visitor's own scroll, never a programmatic one",
|
|
10615
|
+
"arrive.time": "after a number of seconds on the page (at least 3), counted only while the tab is visible",
|
|
10616
|
+
"arrive.scrollOrTime": "whichever comes first: the scroll or the time",
|
|
10617
|
+
"arrive.leaving": "on a laptop, when a mouse leaves through the top of the window after 10 seconds on the page; a phone gets the time instead",
|
|
10618
|
+
"arrive.button": "never by itself — only when a button opens it",
|
|
10619
|
+
"again.days": "after the visitor closes it, not again for a number of days (30 unless the owner says otherwise)",
|
|
10620
|
+
"again.visit": "once per visit",
|
|
10621
|
+
"again.once": "once, ever — until the owner changes it",
|
|
10622
|
+
"art.none": "no picture",
|
|
10623
|
+
"art.picture": "the owner's picture at the start of the card"
|
|
10624
|
+
},
|
|
10625
|
+
"meaningsHe": {
|
|
10626
|
+
"kind.announcement": "חדשות שהבעלים מספרים: פתיחה, סניף חדש, שעות חג — שורה אחת, ואם יש, קישור לעמוד שמספר עוד",
|
|
10627
|
+
"kind.offer": "הצעה שהבעלים מספרים, במילים שלהם — תמונה, שורה קצרה וקישור לעמוד ההצעה",
|
|
10628
|
+
"kind.newsletter": "הזמנה לניוזלטר של העסק — שורה קצרה וטופס ההרשמה",
|
|
10629
|
+
"form.corner": "כרטיס בפינה התחתונה בסוף השורה (בפינת ההתחלה באתר מימין לשמאל), ברוחב 360–560 פיקסלים; בטלפון כרטיס תחתון בגובה של עד 30% מהמסך",
|
|
10630
|
+
"form.bar": "פס לאורך תחתית המסך, שורה אחת: עד 64 פיקסלים במחשב, 88 בטלפון",
|
|
10631
|
+
"form.centred": "כרטיס במרכז המסך מעל רקע מעומעם — רק לניוזלטר ורק במחשב; בטלפון הוא מוצג ככרטיס בפינה",
|
|
10632
|
+
"arrive.scroll": "אחרי שהמבקר גלל חצי מהמסך הראשון — גלילה של המבקר עצמו, אף פעם לא גלילה של הקוד",
|
|
10633
|
+
"arrive.time": "אחרי מספר שניות בעמוד (לפחות 3), נספרות רק כשהלשונית גלויה",
|
|
10634
|
+
"arrive.scrollOrTime": "המוקדם מבין השניים: הגלילה או הזמן",
|
|
10635
|
+
"arrive.leaving": "במחשב, כשהעכבר יוצא מראש החלון אחרי 10 שניות בעמוד; בטלפון — לפי זמן",
|
|
10636
|
+
"arrive.button": "אף פעם לא מעצמו — רק כשכפתור פותח אותו",
|
|
10637
|
+
"again.days": "אחרי שהמבקר סוגר אותו, לא שוב במשך מספר ימים (30, אלא אם הבעלים קובעים אחרת)",
|
|
10638
|
+
"again.visit": "פעם אחת בכל ביקור",
|
|
10639
|
+
"again.once": "פעם אחת בלבד — עד שהבעלים משנים אותו",
|
|
10640
|
+
"art.none": "בלי תמונה",
|
|
10641
|
+
"art.picture": "התמונה של העסק בתחילת הכרטיס"
|
|
10642
|
+
},
|
|
10643
|
+
"waits": {
|
|
10644
|
+
"arrive.leaving": {
|
|
10645
|
+
"phase": "PU2b",
|
|
10646
|
+
"drawnAs": "time"
|
|
10647
|
+
}
|
|
10648
|
+
},
|
|
10649
|
+
"defaults": {
|
|
10650
|
+
"kind": "offer",
|
|
10651
|
+
"form": "corner",
|
|
10652
|
+
"arrive": "scrollOrTime",
|
|
10653
|
+
"again": "days",
|
|
10654
|
+
"art": "picture"
|
|
10655
|
+
},
|
|
10656
|
+
"named": {
|
|
10657
|
+
"announcement": {
|
|
10658
|
+
"kind": "announcement",
|
|
10659
|
+
"form": "bar",
|
|
10660
|
+
"arrive": "scroll",
|
|
10661
|
+
"again": "visit",
|
|
10662
|
+
"art": "none"
|
|
10663
|
+
},
|
|
10664
|
+
"offer": {
|
|
10665
|
+
"kind": "offer",
|
|
10666
|
+
"form": "corner",
|
|
10667
|
+
"arrive": "scrollOrTime",
|
|
10668
|
+
"again": "days",
|
|
10669
|
+
"art": "picture"
|
|
10670
|
+
},
|
|
10671
|
+
"newsletter": {
|
|
10672
|
+
"kind": "newsletter",
|
|
10673
|
+
"form": "corner",
|
|
10674
|
+
"arrive": "scrollOrTime",
|
|
10675
|
+
"again": "days",
|
|
10676
|
+
"art": "none"
|
|
10677
|
+
}
|
|
10678
|
+
},
|
|
10679
|
+
"arrival": {
|
|
10680
|
+
"announcement": {
|
|
10681
|
+
"screens": 0.5
|
|
10682
|
+
},
|
|
10683
|
+
"offer": {
|
|
10684
|
+
"screens": 0.5,
|
|
10685
|
+
"seconds": 8
|
|
10686
|
+
},
|
|
10687
|
+
"newsletter": {
|
|
10688
|
+
"pageShare": 0.4,
|
|
10689
|
+
"seconds": 25
|
|
10690
|
+
}
|
|
10691
|
+
},
|
|
10692
|
+
"generatedForms": [
|
|
10693
|
+
"corner",
|
|
10694
|
+
"bar"
|
|
10695
|
+
],
|
|
10696
|
+
"fingerprint": [
|
|
10697
|
+
"form"
|
|
10698
|
+
],
|
|
10699
|
+
"refused": {
|
|
10700
|
+
"again.every-view": "every page view is the nag: the visitor closed it",
|
|
10701
|
+
"arrive.load": "at load it is an interstitial: the landing view is always the page (minimum 3 s or a real scroll)",
|
|
10702
|
+
"form.fullscreen": "a popup that covers the page hides the content the visitor came for",
|
|
10703
|
+
"kind.countdown": "a countdown is pressure, never news the owner stated (AW-D16)"
|
|
10704
|
+
},
|
|
10705
|
+
"rules": {
|
|
10706
|
+
"oneOverlay": true,
|
|
10707
|
+
"onePerPageView": true,
|
|
10708
|
+
"minSeconds": 3,
|
|
10709
|
+
"scrollScreens": 0.5,
|
|
10710
|
+
"timeSeconds": 8,
|
|
10711
|
+
"leavingLaptopOnly": true,
|
|
10712
|
+
"leavingAfterSeconds": 10,
|
|
10713
|
+
"phoneLeavingSeconds": 25,
|
|
10714
|
+
"phoneMaxHeight": 0.3,
|
|
10715
|
+
"barMaxPx": {
|
|
10716
|
+
"laptop": 64,
|
|
10717
|
+
"phone": 88
|
|
10718
|
+
},
|
|
10719
|
+
"cornerWidthPx": [
|
|
10720
|
+
360,
|
|
10721
|
+
560
|
|
10722
|
+
],
|
|
10723
|
+
"centredNewsletterOnly": true,
|
|
10724
|
+
"centredLaptopOnly": true,
|
|
10725
|
+
"quietRoutes": [
|
|
10726
|
+
"checkout",
|
|
10727
|
+
"order",
|
|
10728
|
+
"account",
|
|
10729
|
+
"sign-in",
|
|
10730
|
+
"legal",
|
|
10731
|
+
"not-found",
|
|
10732
|
+
"recover",
|
|
10733
|
+
"unsubscribe"
|
|
10734
|
+
],
|
|
10735
|
+
"memoryDays": 30,
|
|
10736
|
+
"neverAfterActed": true,
|
|
10737
|
+
"memoryCategory": "necessary",
|
|
10738
|
+
"endedLeftOut": true,
|
|
10739
|
+
"durationByAnimated": {
|
|
10740
|
+
"still": 200,
|
|
10741
|
+
"subtle": 350,
|
|
10742
|
+
"standard": 450,
|
|
10743
|
+
"lively": 550,
|
|
10744
|
+
"expressive": 600
|
|
10745
|
+
},
|
|
10746
|
+
"exitRatio": 0.55,
|
|
10747
|
+
"reducedFadeMs": 200,
|
|
10748
|
+
"phoneRisePx": 24,
|
|
10749
|
+
"phoneInsetMaxPx": 12,
|
|
10750
|
+
"closeTargetPx": 44,
|
|
10751
|
+
"focusStays": true,
|
|
10752
|
+
"noSnippet": true
|
|
10753
|
+
},
|
|
10754
|
+
"tiers": {
|
|
10755
|
+
"kind.announcement": "all",
|
|
10756
|
+
"kind.offer": "all",
|
|
10757
|
+
"kind.newsletter": "all",
|
|
10758
|
+
"form.corner": "all",
|
|
10759
|
+
"form.bar": "all",
|
|
10760
|
+
"form.centred": "all",
|
|
10761
|
+
"arrive.scroll": "all",
|
|
10762
|
+
"arrive.time": "all",
|
|
10763
|
+
"arrive.scrollOrTime": "all",
|
|
10764
|
+
"arrive.leaving": "all",
|
|
10765
|
+
"arrive.button": "all",
|
|
10766
|
+
"again.days": "all",
|
|
10767
|
+
"again.visit": "all",
|
|
10768
|
+
"again.once": "all",
|
|
10769
|
+
"art.none": "all",
|
|
10770
|
+
"art.picture": "all",
|
|
10771
|
+
"rules.oneOverlay": "all",
|
|
10772
|
+
"rules.onePerPageView": "all",
|
|
10773
|
+
"rules.minSeconds": "all",
|
|
10774
|
+
"rules.scrollScreens": "all",
|
|
10775
|
+
"rules.timeSeconds": "all",
|
|
10776
|
+
"rules.leavingLaptopOnly": "all",
|
|
10777
|
+
"rules.leavingAfterSeconds": "all",
|
|
10778
|
+
"rules.phoneLeavingSeconds": "all",
|
|
10779
|
+
"rules.phoneMaxHeight": "all",
|
|
10780
|
+
"rules.barMaxPx": "all",
|
|
10781
|
+
"rules.cornerWidthPx": "all",
|
|
10782
|
+
"rules.centredNewsletterOnly": "all",
|
|
10783
|
+
"rules.centredLaptopOnly": "all",
|
|
10784
|
+
"rules.quietRoutes": "all",
|
|
10785
|
+
"rules.memoryDays": "all",
|
|
10786
|
+
"rules.neverAfterActed": "all",
|
|
10787
|
+
"rules.memoryCategory": "all",
|
|
10788
|
+
"rules.endedLeftOut": "all",
|
|
10789
|
+
"rules.durationByAnimated": "all",
|
|
10790
|
+
"rules.exitRatio": "all",
|
|
10791
|
+
"rules.reducedFadeMs": "all",
|
|
10792
|
+
"rules.phoneRisePx": "all",
|
|
10793
|
+
"rules.phoneInsetMaxPx": "all",
|
|
10794
|
+
"rules.closeTargetPx": "all",
|
|
10795
|
+
"rules.focusStays": "all",
|
|
10796
|
+
"rules.noSnippet": "all"
|
|
10797
|
+
},
|
|
10798
|
+
"references": [
|
|
10799
|
+
{
|
|
10800
|
+
"id": "corner-offer-first-scroll",
|
|
10801
|
+
"after": "Doron pick 2026-11-24: vesuvio (popups-plan §1)",
|
|
10802
|
+
"added": "2026-11-24",
|
|
10803
|
+
"mix": {
|
|
10804
|
+
"kind": "offer",
|
|
10805
|
+
"form": "corner",
|
|
10806
|
+
"arrive": "scroll",
|
|
10807
|
+
"again": "days",
|
|
10808
|
+
"art": "picture"
|
|
10809
|
+
}
|
|
10810
|
+
}
|
|
10811
|
+
]
|
|
10812
|
+
},
|
|
10578
10813
|
"motion": {
|
|
10579
10814
|
"ingredients": {
|
|
10580
10815
|
"arrive": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SceneRole } from '@vectoriox/iox-ui/composite-core';
|
|
2
2
|
import { FILM_SMOOTH_PER_SCREEN } from '@vectoriox/iox-ui/media-core';
|
|
3
3
|
|
|
4
|
-
import { normalizeTracks, SCENE_REVEAL_DEFAULT, SceneKey, SceneNodeSource, SceneProp, SceneRevealFrom, SceneTrack,
|
|
4
|
+
import { isHoldTrack, normalizeTracks, SCENE_REVEAL_DEFAULT, SceneKey, SceneNodeSource, SceneProp, SceneRevealFrom, SceneTrack, trackValueAt } from './scene';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Authoring a Scene (premium-sites plan §5b, SC2): the decisions the builder's timeline and its panel share, so neither
|
|
@@ -57,7 +57,9 @@ export function sceneTrackDef(prop: SceneProp): SceneTrackDef {
|
|
|
57
57
|
return DEF_BY_PROP.get(prop)!;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
/** The track the timeline edits: the HOLD's (an exit or a crossing track is the composer's, kept as it is). */
|
|
61
|
+
const isEdited = (t: SceneTrack, prop: SceneProp): boolean => t.prop === prop && isHoldTrack(t);
|
|
62
|
+
const trackOf = (tracks: ReadonlyArray<SceneTrack>, prop: SceneProp): SceneTrack | undefined => tracks.find(t => isEdited(t, prop));
|
|
61
63
|
const samePosition = (a: number, b: number): boolean => sceneKeyPosition(a) === sceneKeyPosition(b);
|
|
62
64
|
const roundTo = (value: number, places = 4): number => Number(value.toFixed(places));
|
|
63
65
|
|
|
@@ -65,7 +67,7 @@ const roundTo = (value: number, places = 4): number => Number(value.toFixed(plac
|
|
|
65
67
|
export function sceneDisplayValue(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): number {
|
|
66
68
|
const def = sceneTrackDef(prop);
|
|
67
69
|
const track = trackOf(tracks, prop);
|
|
68
|
-
return roundTo((track ?
|
|
70
|
+
return roundTo((track ? trackValueAt(track, p) : def.rest) * def.factor, 2);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -90,12 +92,14 @@ function storedValue(def: SceneTrackDef, value: number | string): number | strin
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
function replaceTrack(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, keys: ReadonlyArray<SceneKey>): SceneTrack[] {
|
|
93
|
-
const rest = tracks.filter(t => t
|
|
95
|
+
const rest = tracks.filter(t => !isEdited(t, prop));
|
|
94
96
|
if (!keys.length) return rest;
|
|
95
|
-
const at = tracks.findIndex(t => t
|
|
97
|
+
const at = tracks.findIndex(t => isEdited(t, prop));
|
|
96
98
|
const next = [...rest];
|
|
97
99
|
const from = prop === SceneProp.Clip ? { from: tracks[at]?.from ?? SCENE_REVEAL_DEFAULT } : {};
|
|
98
|
-
|
|
100
|
+
// Its own ease stays with it: new keys never change how the track runs between them.
|
|
101
|
+
const ease = tracks[at]?.ease ? { ease: tracks[at].ease } : {};
|
|
102
|
+
next.splice(at < 0 ? rest.length : at, 0, { prop, ...from, ...ease, keys });
|
|
99
103
|
return next;
|
|
100
104
|
}
|
|
101
105
|
|
|
@@ -110,7 +114,7 @@ export function sceneRevealFromOf(tracks: ReadonlyArray<SceneTrack>): SceneRevea
|
|
|
110
114
|
*/
|
|
111
115
|
export function withSceneRevealFrom(tracks: ReadonlyArray<SceneTrack>, from: SceneRevealFrom, p: number): SceneTrack[] {
|
|
112
116
|
if (!trackOf(tracks, SceneProp.Clip)) return [...tracks, { prop: SceneProp.Clip, from, keys: [[sceneKeyPosition(p), sceneTrackDef(SceneProp.Clip).rest]] }];
|
|
113
|
-
return tracks.map(track => (track
|
|
117
|
+
return tracks.map(track => (isEdited(track, SceneProp.Clip) ? { ...track, from } : track));
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
/**
|
|
@@ -124,7 +128,7 @@ export function withScenePlayback(tracks: ReadonlyArray<SceneTrack>): SceneTrack
|
|
|
124
128
|
|
|
125
129
|
/** Stop playing a layer's pictures. */
|
|
126
130
|
export function withoutScenePlayback(tracks: ReadonlyArray<SceneTrack>): SceneTrack[] {
|
|
127
|
-
return tracks.filter(track => track
|
|
131
|
+
return tracks.filter(track => !isEdited(track, SceneProp.Play));
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
/**
|
package/src/scene-core/scene.ts
CHANGED
|
@@ -42,6 +42,55 @@ export enum SceneRevealFrom {
|
|
|
42
42
|
End = 'end',
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* How a track runs between two keys (award plan "Reddottours", RT-D1). A scrubbed TRAVEL runs straight, so a layer moves
|
|
47
|
+
* exactly as far as the scroll moves it (theirs is `ease: none`; smoothstep slowed every walk at both ends); a FADE keeps
|
|
48
|
+
* smoothstep, which is what a fade looks right with. A track says its own only when it differs from its property's.
|
|
49
|
+
*/
|
|
50
|
+
export enum SceneEase {
|
|
51
|
+
Linear = 'linear',
|
|
52
|
+
Smooth = 'smooth',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Each property's ease when its track says none: travel straight, fades and colours smooth. */
|
|
56
|
+
export const SCENE_TRACK_EASE: Readonly<Record<SceneProp, SceneEase>> = {
|
|
57
|
+
[SceneProp.X]: SceneEase.Linear,
|
|
58
|
+
[SceneProp.Y]: SceneEase.Linear,
|
|
59
|
+
[SceneProp.Scale]: SceneEase.Linear,
|
|
60
|
+
[SceneProp.Rotate]: SceneEase.Linear,
|
|
61
|
+
[SceneProp.Clip]: SceneEase.Linear,
|
|
62
|
+
[SceneProp.Play]: SceneEase.Linear,
|
|
63
|
+
[SceneProp.Opacity]: SceneEase.Smooth,
|
|
64
|
+
[SceneProp.Words]: SceneEase.Smooth,
|
|
65
|
+
[SceneProp.Ground]: SceneEase.Smooth,
|
|
66
|
+
[SceneProp.Ink]: SceneEase.Smooth,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* WHAT a track's 0–1 is measured over (award plan "Reddottours", AW9). A track says its own only when it is not the hold.
|
|
71
|
+
* - Hold: the root's held travel — the stage pinned while the page scrolls the root's extra height (every Scene so far).
|
|
72
|
+
* - Exit: the root's LEAVING, after the hold — from the stage's release until it has gone by its own height (their S1:
|
|
73
|
+
* the held film sinks at 0.4× as the next band rises).
|
|
74
|
+
* - Cross inline / Cross block: the layer's OWN crossing of the stage — 0 as its leading edge enters the stage's far side,
|
|
75
|
+
* 1 as its trailing edge leaves the near side — measured where it stands without its own move, so inside a walking row
|
|
76
|
+
* each picture drifts as IT crosses the screen (their S3, GSAP's `containerAnimation`). Inline follows the reading
|
|
77
|
+
* direction (a walk enters from the end); block enters from below.
|
|
78
|
+
*/
|
|
79
|
+
export enum SceneRange {
|
|
80
|
+
Hold = 'hold',
|
|
81
|
+
Exit = 'exit',
|
|
82
|
+
CrossInline = 'cross-inline',
|
|
83
|
+
CrossBlock = 'cross-block',
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Where a layer stands on each range at one moment. Hold is the Scene's progress; the others are 0 until measured. */
|
|
87
|
+
export interface SceneProgress {
|
|
88
|
+
hold: number;
|
|
89
|
+
exit?: number;
|
|
90
|
+
crossInline?: number;
|
|
91
|
+
crossBlock?: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
45
94
|
/** What a reveal opens from when nobody has said: the page's own direction of travel, upward as it scrolls. */
|
|
46
95
|
export const SCENE_REVEAL_DEFAULT = SceneRevealFrom.Bottom;
|
|
47
96
|
|
|
@@ -50,10 +99,14 @@ export type SceneKey = readonly [number, number | string];
|
|
|
50
99
|
|
|
51
100
|
export interface SceneTrack {
|
|
52
101
|
prop: SceneProp;
|
|
53
|
-
/** Ascending by progress. Between two keys the value
|
|
102
|
+
/** Ascending by progress. Between two keys the value runs by `ease`; outside them it holds the nearest. */
|
|
54
103
|
keys: ReadonlyArray<SceneKey>;
|
|
55
104
|
/** A Clip track's direction. */
|
|
56
105
|
from?: SceneRevealFrom;
|
|
106
|
+
/** How it runs between keys; absent = its property's (`SCENE_TRACK_EASE`). */
|
|
107
|
+
ease?: SceneEase;
|
|
108
|
+
/** What its progress is measured over; absent = the hold. */
|
|
109
|
+
range?: SceneRange;
|
|
57
110
|
}
|
|
58
111
|
|
|
59
112
|
/** What a node carries (both a builder node and a saved one). */
|
|
@@ -114,6 +167,15 @@ const COLOUR = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\([\d\s.,%/]+\)|var\(--iox-[\w-]+\))
|
|
|
114
167
|
const COLOUR_PROPS: ReadonlySet<SceneProp> = new Set([SceneProp.Ground, SceneProp.Ink]);
|
|
115
168
|
const ALL_PROPS: ReadonlySet<string> = new Set(Object.values(SceneProp));
|
|
116
169
|
const REVEAL_FROMS: ReadonlySet<string> = new Set(Object.values(SceneRevealFrom));
|
|
170
|
+
const EASES: ReadonlySet<string> = new Set(Object.values(SceneEase));
|
|
171
|
+
const RANGES: ReadonlySet<string> = new Set(Object.values(SceneRange));
|
|
172
|
+
|
|
173
|
+
/** How a track runs between its keys. */
|
|
174
|
+
export const trackEase = (track: Pick<SceneTrack, 'prop' | 'ease'>): SceneEase => track.ease ?? SCENE_TRACK_EASE[track.prop];
|
|
175
|
+
/** What a track's progress is measured over. */
|
|
176
|
+
export const trackRange = (track: Pick<SceneTrack, 'range'>): SceneRange => track.range ?? SceneRange.Hold;
|
|
177
|
+
/** A track the hold drives (every authored track): what the timeline edits. */
|
|
178
|
+
export const isHoldTrack = (track: Pick<SceneTrack, 'range'>): boolean => trackRange(track) === SceneRange.Hold;
|
|
117
179
|
const PERCENT = 100;
|
|
118
180
|
const clampPercent = (v: number): number => Math.min(PERCENT, Math.max(0, v));
|
|
119
181
|
|
|
@@ -139,7 +201,14 @@ export function normalizeTracks(tracks: unknown): SceneTrack[] {
|
|
|
139
201
|
.slice()
|
|
140
202
|
.sort((a, b) => a[0] - b[0]);
|
|
141
203
|
if (!keys.length) continue;
|
|
142
|
-
|
|
204
|
+
const base: SceneTrack = prop === SceneProp.Clip ? clipTrack(keys, (track as SceneTrack).from) : { prop, keys };
|
|
205
|
+
// Kept only where they say something: a track at its property's ease and on the hold reads as it always did.
|
|
206
|
+
const { ease, range } = track as SceneTrack;
|
|
207
|
+
out.push({
|
|
208
|
+
...base,
|
|
209
|
+
...(typeof ease === 'string' && EASES.has(ease) && ease !== SCENE_TRACK_EASE[prop as SceneProp] ? { ease } : {}),
|
|
210
|
+
...(typeof range === 'string' && RANGES.has(range) && range !== SceneRange.Hold ? { range } : {}),
|
|
211
|
+
});
|
|
143
212
|
}
|
|
144
213
|
return out;
|
|
145
214
|
}
|
|
@@ -169,6 +238,7 @@ export function revealClipPath(showing: number, from: SceneRevealFrom = SCENE_RE
|
|
|
169
238
|
}
|
|
170
239
|
|
|
171
240
|
const linear = (t: number): number => t;
|
|
241
|
+
const EASE_FN: Readonly<Record<SceneEase, (t: number) => number>> = { [SceneEase.Linear]: linear, [SceneEase.Smooth]: smoothstep };
|
|
172
242
|
|
|
173
243
|
/** The two keys around `p` and how far between them it has come. */
|
|
174
244
|
function span(keys: ReadonlyArray<SceneKey>, p: number, ease: (t: number) => number = smoothstep): { a: SceneKey; b: SceneKey; f: number } {
|
|
@@ -186,7 +256,7 @@ function span(keys: ReadonlyArray<SceneKey>, p: number, ease: (t: number) => num
|
|
|
186
256
|
return { a: last, b: last, f: 0 };
|
|
187
257
|
}
|
|
188
258
|
|
|
189
|
-
/** A numeric track's value at progress `p
|
|
259
|
+
/** A numeric track's value at progress `p` (eased smoothstep unless `ease` says otherwise — `trackValueAt` reads the track's). */
|
|
190
260
|
export function valueAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): number {
|
|
191
261
|
if (!keys.length) return 0;
|
|
192
262
|
const { a, b, f } = span(keys, p, ease);
|
|
@@ -198,14 +268,42 @@ export function valueAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: num
|
|
|
198
268
|
* A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live
|
|
199
269
|
* reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.
|
|
200
270
|
*/
|
|
201
|
-
export function colourAt(keys: ReadonlyArray<SceneKey>, p: number): string {
|
|
271
|
+
export function colourAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): string {
|
|
202
272
|
if (!keys.length) return '';
|
|
203
|
-
const { a, b, f } = span(keys, p);
|
|
273
|
+
const { a, b, f } = span(keys, p, ease);
|
|
204
274
|
if (f <= 0 || a === b) return String(a[1]);
|
|
205
275
|
if (f >= 1) return String(b[1]);
|
|
206
276
|
return `color-mix(in oklab, ${a[1]} ${round((1 - f) * 100)}%, ${b[1]})`;
|
|
207
277
|
}
|
|
208
278
|
|
|
279
|
+
/** A numeric track's value at progress `p`, run by its own ease. */
|
|
280
|
+
export function trackValueAt(track: SceneTrack, p: number): number {
|
|
281
|
+
return valueAt(track.keys, p, EASE_FN[trackEase(track)]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** A colour track's value at progress `p`, run by its own ease. */
|
|
285
|
+
export function trackColourAt(track: SceneTrack, p: number): string {
|
|
286
|
+
return colourAt(track.keys, p, EASE_FN[trackEase(track)]);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const RANGE_KEY: Readonly<Record<SceneRange, keyof SceneProgress>> = {
|
|
290
|
+
[SceneRange.Hold]: 'hold',
|
|
291
|
+
[SceneRange.Exit]: 'exit',
|
|
292
|
+
[SceneRange.CrossInline]: 'crossInline',
|
|
293
|
+
[SceneRange.CrossBlock]: 'crossBlock',
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/** Where a track stands: the progress of its own range. A bare number is the hold (and 0 on every other range). */
|
|
297
|
+
export function trackProgress(track: Pick<SceneTrack, 'range'>, p: number | SceneProgress): number {
|
|
298
|
+
if (typeof p === 'number') return trackRange(track) === SceneRange.Hold ? p : 0;
|
|
299
|
+
return p[RANGE_KEY[trackRange(track)]] ?? 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** True when a layer has a track measured over its own crossing: the driver measures where it stands. */
|
|
303
|
+
export function crossesStage(tracks: ReadonlyArray<SceneTrack>): boolean {
|
|
304
|
+
return tracks.some(t => t.range === SceneRange.CrossInline || t.range === SceneRange.CrossBlock);
|
|
305
|
+
}
|
|
306
|
+
|
|
209
307
|
export interface SceneFrameOptions {
|
|
210
308
|
/** -1 when the stage reads right-to-left: the inline axis mirrors. */
|
|
211
309
|
inlineSign?: 1 | -1;
|
|
@@ -218,22 +316,34 @@ const TRANSFORM_REST: Readonly<Partial<Record<SceneProp, number>>> = { [ScenePro
|
|
|
218
316
|
* A layer's frame at progress `p`. Lengths are container-query units, so one frame is right at any width, under any
|
|
219
317
|
* canvas zoom, on the server and with no measuring: the stage is the size container (`iox-design.css`).
|
|
220
318
|
*/
|
|
221
|
-
export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options: SceneFrameOptions = {}): SceneFrame {
|
|
319
|
+
export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress, options: SceneFrameOptions = {}): SceneFrame {
|
|
222
320
|
const frame: SceneFrame = {};
|
|
321
|
+
// Per property and range, the last track wins (as one list always read). Across ranges they compose: a hold that
|
|
322
|
+
// carries a layer and an exit that sinks it add their moves, and their scales and opacities multiply.
|
|
323
|
+
const byRange = new Map<string, { prop: SceneProp; value: number | string; from?: SceneRevealFrom }>();
|
|
324
|
+
for (const track of tracks) {
|
|
325
|
+
const at = trackProgress(track, p);
|
|
326
|
+
const value = COLOUR_PROPS.has(track.prop) ? trackColourAt(track, at) : trackValueAt(track, at);
|
|
327
|
+
byRange.set(`${track.prop}|${trackRange(track)}`, { prop: track.prop, value, from: track.from });
|
|
328
|
+
}
|
|
223
329
|
const moves: Partial<Record<SceneProp, number>> = {};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
frame.pointerEvents = opacity > 0 ? '' : 'none';
|
|
330
|
+
let opacity: number | null = null;
|
|
331
|
+
for (const { prop, value, from } of byRange.values()) {
|
|
332
|
+
if (prop in TRANSFORM_REST) {
|
|
333
|
+
const v = Number(value);
|
|
334
|
+
moves[prop] = prop === SceneProp.Scale ? (moves[prop] ?? 1) * v : (moves[prop] ?? 0) + v;
|
|
230
335
|
}
|
|
231
|
-
else if (prop === SceneProp.
|
|
232
|
-
else if (prop === SceneProp.
|
|
233
|
-
else if (prop === SceneProp.
|
|
336
|
+
else if (prop === SceneProp.Opacity) opacity = (opacity ?? 1) * clamp01(Number(value));
|
|
337
|
+
else if (prop === SceneProp.Clip) frame.clipPath = revealClipPath(Number(value), from ?? SceneRevealFrom.Centre, options.inlineSign ?? 1);
|
|
338
|
+
else if (prop === SceneProp.Ground) frame.backgroundColor = String(value);
|
|
339
|
+
else if (prop === SceneProp.Ink) frame.color = String(value);
|
|
340
|
+
}
|
|
341
|
+
if (opacity !== null) {
|
|
342
|
+
frame.opacity = String(round(opacity));
|
|
343
|
+
frame.pointerEvents = opacity > 0 ? '' : 'none';
|
|
234
344
|
}
|
|
235
345
|
if (Object.keys(moves).length) {
|
|
236
|
-
const value = (prop: SceneProp): number => moves[prop] ?? TRANSFORM_REST[prop]
|
|
346
|
+
const value = (prop: SceneProp): number => round(moves[prop] ?? TRANSFORM_REST[prop]!);
|
|
237
347
|
const x = round(value(SceneProp.X) * (options.inlineSign ?? 1));
|
|
238
348
|
frame.transform = `translate3d(${x}cqw, ${value(SceneProp.Y)}cqh, 0) rotate(${value(SceneProp.Rotate)}deg) scale(${value(SceneProp.Scale)})`;
|
|
239
349
|
}
|
|
@@ -244,18 +354,18 @@ export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options
|
|
|
244
354
|
export const SCENE_WORD_DIM = 0.16;
|
|
245
355
|
|
|
246
356
|
/** How many of a layer's words are lit at `p`, in %; null when it has no such track. */
|
|
247
|
-
export function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number): number | null {
|
|
357
|
+
export function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null {
|
|
248
358
|
const track = tracks.find(t => t.prop === SceneProp.Words);
|
|
249
|
-
return track ? clampPercent(
|
|
359
|
+
return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
|
|
250
360
|
}
|
|
251
361
|
|
|
252
362
|
/**
|
|
253
363
|
* How far a layer's pictures have played at `p`, in %; null when it has no such track. A film runs straight between its
|
|
254
|
-
* keys
|
|
364
|
+
* keys (its property's ease): eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
|
|
255
365
|
*/
|
|
256
|
-
export function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number): number | null {
|
|
366
|
+
export function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null {
|
|
257
367
|
const track = tracks.find(t => t.prop === SceneProp.Play);
|
|
258
|
-
return track ? clampPercent(
|
|
368
|
+
return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
|
|
259
369
|
}
|
|
260
370
|
|
|
261
371
|
/** Word `index` of `count`, with `lit` % lit: words light one after the other, each easing in as the last finishes. */
|