@occluze/umber 0.3.0 → 0.4.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.
Files changed (87) hide show
  1. package/README.md +93 -47
  2. package/THIRD-PARTY-NOTICES.md +33 -0
  3. package/dist/chunks/badge.js +2 -2
  4. package/dist/chunks/basis.js +2 -2
  5. package/dist/chunks/batches.js +2 -0
  6. package/dist/chunks/capture.js +2 -2
  7. package/dist/chunks/covers.js +2 -2
  8. package/dist/chunks/curves.js +2 -2
  9. package/dist/chunks/flip.js +2 -2
  10. package/dist/chunks/fx.js +2 -2
  11. package/dist/chunks/gl.js +2 -2
  12. package/dist/chunks/glsl.js +2 -2
  13. package/dist/chunks/glyphs.js +2 -0
  14. package/dist/chunks/inspect.js +2 -2
  15. package/dist/chunks/instances.js +2 -2
  16. package/dist/chunks/layers.js +2 -2
  17. package/dist/chunks/licence.js +2 -2
  18. package/dist/chunks/morph.js +2 -2
  19. package/dist/chunks/pace.js +2 -0
  20. package/dist/chunks/patch.js +2 -2
  21. package/dist/chunks/prepared.js +2 -2
  22. package/dist/chunks/profiler.js +2 -2
  23. package/dist/chunks/recheck.js +2 -0
  24. package/dist/chunks/resize.js +2 -0
  25. package/dist/chunks/restore.js +2 -2
  26. package/dist/chunks/shapes.js +2 -2
  27. package/dist/chunks/sim.js +2 -2
  28. package/dist/chunks/text.js +2 -2
  29. package/dist/chunks/video.js +2 -2
  30. package/dist/chunks/vocabulary.js +2 -2
  31. package/dist/chunks/warm.js +2 -2
  32. package/dist/modules/debug.js +2 -2
  33. package/dist/modules/debug.mjs +2 -2
  34. package/dist/modules/handoff.js +2 -2
  35. package/dist/modules/handoff.mjs +2 -2
  36. package/dist/modules/input.js +2 -2
  37. package/dist/modules/input.mjs +2 -2
  38. package/dist/modules/scrollfx.js +2 -2
  39. package/dist/modules/scrollfx.mjs +2 -2
  40. package/dist/modules/scrub.js +2 -2
  41. package/dist/modules/scrub.mjs +2 -2
  42. package/dist/modules/three.js +2 -2
  43. package/dist/modules/three.mjs +2 -2
  44. package/dist/node/assets.mjs +4 -2
  45. package/dist/node/astro.mjs +26 -18
  46. package/dist/node/cli.mjs +63 -10
  47. package/dist/node/shared-P6KINBNR.mjs +2113 -0
  48. package/dist/node/{shared-4FIU6DYP.mjs → shared-VQKZUUXF.mjs} +106 -17
  49. package/dist/node/vite.mjs +7 -3
  50. package/dist/prepared.mjs +2 -0
  51. package/dist/umber.css +1 -1
  52. package/dist/umber.js +2 -2
  53. package/dist/umber.mjs +2 -2
  54. package/docs/AI-quick.md +43 -87
  55. package/docs/AI.md +1965 -1828
  56. package/docs/npm.md +13 -16
  57. package/package.json +31 -48
  58. package/types/assets.d.ts +109 -4
  59. package/types/astro.d.ts +20 -23
  60. package/types/debug.d.ts +1 -1
  61. package/types/esm.d.ts +2 -6
  62. package/types/input.d.ts +3 -3
  63. package/types/loop.d.ts +21 -9
  64. package/types/module.d.ts +0 -2
  65. package/types/scrollfx.d.ts +5 -41
  66. package/types/scrub.d.ts +2 -2
  67. package/types/three.d.ts +26 -1
  68. package/types/umber.d.ts +152 -155
  69. package/types/vite.d.ts +3 -3
  70. package/dist/chunks/views.js +0 -2
  71. package/dist/frameworks/astro.mjs +0 -2
  72. package/dist/frameworks/react.mjs +0 -2
  73. package/dist/frameworks/svelte.mjs +0 -2
  74. package/dist/frameworks/vue.mjs +0 -2
  75. package/dist/modules/router-swap.js +0 -2
  76. package/dist/modules/router.js +0 -2
  77. package/dist/modules/router.mjs +0 -2
  78. package/dist/modules/scroll-more.js +0 -2
  79. package/dist/modules/scroll-touch.js +0 -2
  80. package/dist/modules/scroll.js +0 -2
  81. package/dist/modules/scroll.mjs +0 -2
  82. package/dist/node/shared-3Q24RNIF.mjs +0 -602
  83. package/types/react.d.ts +0 -15
  84. package/types/router.d.ts +0 -223
  85. package/types/scroll.d.ts +0 -190
  86. package/types/svelte.d.ts +0 -16
  87. package/types/vue.d.ts +0 -14
package/types/router.d.ts DELETED
@@ -1,223 +0,0 @@
1
- /**
2
- * Types for the router module (@occluze/umber/router).
3
- *
4
- * Page changes without full page loads, with transitions of your own or presets:
5
- *
6
- * import { Router } from "@occluze/umber/router";
7
- * umber.use(Router, { transition: "fade" }); // or createUmber({ modules: [Router] })
8
- * <script src=".../umber@x.y.z/modules/router.js"></script> (registers itself)
9
- *
10
- * umber.router.transition({ name: "to-work", to: "work", leave, enter });
11
- * umber.router.on("after", ({ next }) => gtag("event", "page_view", { page_location: next.url }));
12
- * await umber.router.go("/work");
13
- */
14
-
15
- import type { Umber, UmberModule } from "./umber.js";
16
-
17
- /** A page name (data-umber-page), a path ("/work/*"), a RegExp on the path, a function of the page, or a list of them. */
18
- export type RouterMatch =
19
- string | RegExp | ((page: RouterPage) => boolean) | (string | RegExp | ((page: RouterPage) => boolean))[];
20
-
21
- /** One side of a page change. */
22
- export interface RouterPage {
23
- /** Its URL (with the #hash for the next page). */
24
- url: string;
25
- /** Its container's data-umber-page ("" when it has none). */
26
- page: string;
27
- /** Its [data-umber~=container]. The next page's is null until that page is in: in "before", and in a leave that starts before it is (its steps get it filled in once it is). */
28
- container: HTMLElement | null;
29
- /** The next page's parsed HTML. */
30
- document?: Document;
31
- }
32
-
33
- /** What transitions and hooks get. */
34
- export interface RouterData {
35
- current: RouterPage;
36
- next: RouterPage;
37
- /** The link clicked, "popstate" (back / forward), "load" (once) or go()'s trigger ("go"). */
38
- trigger: Element | string;
39
- direction: "forward" | "back";
40
- /** Where the click was, viewport px; null from the keyboard, back / forward or go(). */
41
- origin: [number, number] | null;
42
- /** The visitor prefers reduced motion: every preset is a 0.2 s cross-fade. */
43
- reducedMotion: boolean;
44
- /** The visitor's last input was a key (keyboard, or a screen reader activating the link): the new page gets keyboard
45
- * focus only then. A mouse, touch or pen click, or go() on its own, leaves focus where it was. */
46
- keyboard: boolean;
47
- /** The chosen transition's name ("" when it has none). */
48
- transition: string;
49
- }
50
-
51
- type Step = (data: RouterData) => unknown;
52
-
53
- /** Options of the presets (and of the element that names one: data-umber-transition-duration="0.6"). */
54
- export interface RouterPresetOptions {
55
- /** Seconds, each half. @default fade 0.4, slide 0.9, zoom 0.5 / 0.7, curtain and wipe 0.65, cover and dissolve 0.8 */
56
- duration?: number;
57
- /** A CSS easing (cover, dissolve: any Umber ease). @default per preset */
58
- ease?: string;
59
- /** curtain, wipe, cover, dissolve: the panel's colour. @default "#111" */
60
- color?: string;
61
- /** cover: a umber.shader() name with a uCover uniform. @default a disc of `color` that grows from the click */
62
- shader?: string;
63
- /** cover, dissolve: draw over everything, a fixed nav too (Umber's canvas lifted for the transition). @default false */
64
- above?: boolean | string;
65
- }
66
-
67
- /** native: the browser's View Transition (document.startViewTransition), fade where there is none. */
68
- export type RouterPreset = "none" | "fade" | "slide" | "zoom" | "curtain" | "wipe" | "cover" | "dissolve" | "native";
69
-
70
- /**
71
- * A transition. Each condition it sets must hold; the most specific one wins (from 1, to 2,
72
- * links 4, custom 8; a tie: the one registered last). One with no condition is the default.
73
- * Every step may return a promise (or be async); a step that throws or takes longer than
74
- * options.timeout loads the page in full instead.
75
- */
76
- export interface RouterTransition extends RouterPresetOptions {
77
- name?: string;
78
- /** Start from a preset: its steps, your options. Your own steps replace its. */
79
- preset?: RouterPreset;
80
- from?: RouterMatch;
81
- to?: RouterMatch;
82
- /** The link clicked matches this selector (or function). */
83
- links?: string | ((link: Element) => boolean);
84
- custom?: (data: RouterData) => boolean;
85
- /** Leave and enter at once, both containers in the page; the old one is pinned where it shows (position: fixed). */
86
- sync?: boolean;
87
- /**
88
- * Leave only once the next page is in (data.next has its container and document), for a
89
- * leave of your own that reads the next page. Without it the leave starts at the click,
90
- * while the next page loads. @default false
91
- */
92
- wait?: boolean;
93
- /** The first page load (from never matches): an intro. Plays wait for it. */
94
- once?: Step;
95
- beforeLeave?: Step;
96
- leave?: Step;
97
- afterLeave?: Step;
98
- /** The new container is in the page, its scripts have not run: set its first frame here. */
99
- beforeEnter?: Step;
100
- enter?: Step;
101
- afterEnter?: Step;
102
- }
103
-
104
- export interface RouterOptions {
105
- /** The transition when nothing else picks one: a preset or a registered name. @default "fade" */
106
- transition?: RouterPreset | (string & {});
107
- /** "hover": fetch a page as the pointer rests on its link, a touch starts or it gets focus; "viewport": also once a link scrolls into view; false: only on click. @default "hover" */
108
- prefetch?: "hover" | "viewport" | false;
109
- /** Pages kept in memory. 0: none. @default 10 */
110
- cache?: number;
111
- /** ms a fetch or any step may take before the page loads in full instead. @default 6000 */
112
- timeout?: number;
113
- /** Where focus goes in the new container (a selector; else the container). false: nowhere. @default "h1" */
114
- focus?: string | false;
115
- /** Say the new page's title in a polite live region. @default true */
116
- announce?: boolean;
117
- /** Scroll to the top, the #hash, or where that history entry was. @default true */
118
- scroll?: boolean;
119
- /** Run the new page's scripts. @default true */
120
- scripts?: boolean;
121
- /** Update title, meta, stylesheets, <html> and <body> classes. @default true */
122
- head?: boolean;
123
- /** Re-initialise Webflow (interactions, forms) after each swap. @default true */
124
- webflow?: boolean;
125
- /** Return true to leave a link (or a data-umber-router-form form) to the browser. */
126
- prevent?: ((link: Element, event?: Event) => boolean) | null;
127
- /** Every transition leaves only once the next page is in (as transition.wait). @default false */
128
- wait?: boolean;
129
- /** Headers sent with every page the router fetches (X-Requested-With, so a server can answer with less). @default {} */
130
- headers?: Record<string, string>;
131
- }
132
-
133
- /** umber.router.go()'s options. */
134
- export interface RouterGoOptions {
135
- transition?: string | RouterTransition;
136
- trigger?: Element | string;
137
- /** "replace": the new page takes the place of the history entry shown (data-umber-router-history="replace" on a link). @default "push" */
138
- history?: "push" | "replace";
139
- }
140
-
141
- /** umber.router.on()'s options. */
142
- export interface RouterHookOptions {
143
- /** Run once, then remove itself. */
144
- once?: boolean;
145
- /** Lower starts first among the hooks of one moment. @default 0 */
146
- order?: number;
147
- }
148
-
149
- /** umber.router.cache: the pages kept in memory (after a sign-in, or an edit made in the page, so the next visit fetches them again). */
150
- export interface RouterCache {
151
- /** Forget every page (one still loading is forgotten once it is in). */
152
- clear(): void;
153
- /** Forget one page; true when it was kept. */
154
- delete(url: string): boolean;
155
- has(url: string): boolean;
156
- }
157
-
158
- /** umber.router, once the module is in. */
159
- export interface RouterApi {
160
- /** The module's options, live: with the script build, set them right after createUmber(). */
161
- readonly options: Required<RouterOptions>;
162
- /** True while a page change runs. */
163
- readonly busy: boolean;
164
- /** The page shown: its URL without the #hash. */
165
- readonly url: string;
166
- /** The page shown: its data-umber-page. */
167
- readonly page: string;
168
- /**
169
- * Change page. Resolves once the new page is in and its transition finished; rejects
170
- * (after starting a full page load of url) when the router can't.
171
- */
172
- go(url: string, options?: RouterGoOptions): Promise<void>;
173
- /** Fetch a page ahead (kept in the cache), its GL got ready too (umber.preload()). Never rejects. */
174
- prefetch(url: string): Promise<void>;
175
- readonly cache: RouterCache;
176
- /** Register a transition; returns its remover. */
177
- transition(def: RouterTransition): () => void;
178
- /**
179
- * A hook for every page change; returns its remover. Each step's hooks run with that step
180
- * of the transition: before, beforeLeave, leave, afterLeave, beforeEnter, enter,
181
- * afterEnter, after. All but after may return what the change waits for (a promise, a
182
- * GSAP tween or timeline, a Web Animation, a list of them).
183
- */
184
- on(name: RouterMoment, fn: Step, options?: RouterHookOptions): () => void;
185
- on(
186
- name: "error",
187
- fn: (e: RouterData & { error: unknown; url: string }) => void,
188
- options?: RouterHookOptions,
189
- ): () => void;
190
- /**
191
- * One page's own code (its data-umber-page): beforeEnter / afterEnter as it comes in (the
192
- * first load too), beforeLeave / afterLeave as it goes. Returns its remover.
193
- */
194
- view(page: string, view: RouterView): () => void;
195
- }
196
-
197
- /** The moments of a change: before, each step, after. */
198
- export type RouterMoment =
199
- "before" | "beforeLeave" | "leave" | "afterLeave" | "beforeEnter" | "enter" | "afterEnter" | "after";
200
-
201
- /** A page's set-up and take-down (umber.router.view()). */
202
- export interface RouterView {
203
- beforeEnter?: Step;
204
- afterEnter?: Step;
205
- beforeLeave?: Step;
206
- afterLeave?: Step;
207
- }
208
-
209
- declare module "./umber.js" {
210
- interface Umber {
211
- /** The router module's API (types/router.d.ts). */
212
- readonly router: RouterApi;
213
- }
214
- }
215
-
216
- /** umber.use(Router, options), createUmber({ modules: [Router] }). */
217
- export declare const Router: UmberModule;
218
-
219
- /** The same without umber.use(): adds umber.router to `engine`. */
220
- export declare function router(engine: Umber, options?: RouterOptions): RouterApi;
221
-
222
- /** @alias The same module as the named export, for `import Router from`. */
223
- export default Router;
package/types/scroll.d.ts DELETED
@@ -1,190 +0,0 @@
1
- /**
2
- * Types for the scroll module (@occluze/umber/scroll).
3
- *
4
- * Smooth scrolling on Umber's own loop: the wheel eases the real scroll position, written
5
- * before the engine reads it each frame, so planes and the DOM move together (0 px apart)
6
- * with no createUmber({ scroll }). Keys, the scrollbar, find-in-page, zoom, sideways swipes,
7
- * touch (unless `touch: true`) and reduced motion stay native.
8
- *
9
- * import { Scroll } from "@occluze/umber/scroll";
10
- * umber.use(Scroll, { lerp: 0.1 }); // or createUmber({ modules: [Scroll] })
11
- * <script src=".../umber@x.y.z/modules/scroll.js"></script> (registers itself)
12
- *
13
- * umber.scroll.scrollTo("#work", { offset: -80 });
14
- * umber.scroll.on("scroll", (s) => console.log(s.animatedScroll, s.velocity));
15
- * umber.scroll.stop(); umber.scroll.start(); // a modal, a page change
16
- *
17
- * HTML: data-umber-scroll="off" | "touch", data-umber-scroll-lerp, data-umber-scroll-duration and
18
- * data-umber-scroll-offset on <body> (or <html>); data-umber-scroll-offset on a #link or its
19
- * target; data-umber-scroll-prevent on an element that scrolls natively; data-umber="scroller"
20
- * on the element that scrolls instead of the window.
21
- */
22
-
23
- import type { Umber, UmberModule } from "./umber.js";
24
-
25
- /** Where scrollTo() goes: px, a selector, an element, or "top" / "bottom" (also "#", "#top", "start", "end"). */
26
- export type ScrollTarget = number | string | Element | null | undefined;
27
-
28
- /** What a scrollTo() carries for the "scroll" handlers while it runs (umber.scroll.userData). */
29
- export type UserData = Record<string, unknown>;
30
-
31
- /** A wheel or touch move as the module heard it (Lenis's virtual-scroll): px, + right / down. */
32
- export interface VirtualScroll {
33
- deltaX: number;
34
- deltaY: number;
35
- event: WheelEvent | TouchEvent;
36
- }
37
-
38
- export interface ScrollToOptions {
39
- /** px added to the target's position (-80: stop 80 px above it, for a fixed header). @default 0 */
40
- offset?: number;
41
- /** Land now, in this frame, with no animation. @default false */
42
- immediate?: boolean;
43
- /** Seconds, with `easing` (instead of the lerp). @default the module's duration (0: the lerp) */
44
- duration?: number;
45
- /** 0..1 -> 0..1, for `duration`. @default an expo ease-out */
46
- easing?: (t: number) => number;
47
- /** The lerp for this move. @default the module's lerp */
48
- lerp?: number;
49
- /** With immediate: a jump, not motion (no velocity, no direction): a page swap, a history step. Without it, an immediate move of a screen or more is a jump, a smaller one is motion. @default false */
50
- jump?: boolean;
51
- /** Ignore the wheel, touch, scroll keys and other scrollTo()s until it lands. @default false */
52
- lock?: boolean;
53
- /** Animate also while stopped or locked (an immediate one always lands). @default false */
54
- force?: boolean;
55
- /** As it starts. */
56
- onStart?: (scroll: ScrollApi) => void;
57
- /** When it lands (not when something interrupts it). */
58
- onComplete?: (scroll: ScrollApi) => void;
59
- /** umber.scroll.userData while this move runs (who asked for it: { initiator: "snap" }). @default {} */
60
- userData?: UserData;
61
- }
62
-
63
- /** Which way of a gesture moves the page: its up / down, its sideways, or whichever is larger. */
64
- export type GestureOrientation = "vertical" | "horizontal" | "both";
65
-
66
- export interface ScrollOptions {
67
- /** The way the page scrolls: "horizontal" scrolls it sideways (scrollLeft, widths). Read once, at umber.use(). @default "vertical" */
68
- orientation?: "vertical" | "horizontal";
69
- /** Which way of the wheel or a finger moves it: its up / down, its sideways, or whichever is larger ("both"). @default "vertical", "both" when horizontal */
70
- gestureOrientation?: GestureOrientation;
71
- /** How fast it eases, as Lenis's lerp: about this share of the way per 60 fps frame (exactly 1 - e^-lerp), the same at any refresh rate (1: at once). @default 0.1 */
72
- lerp?: number;
73
- /** Seconds a wheel move takes, with `easing`; 0 uses the lerp. @default 0 */
74
- duration?: number;
75
- /** For `duration`. @default an expo ease-out */
76
- easing?: ((t: number) => number) | null;
77
- /** Wheel px times this. @default 1 */
78
- wheelMultiplier?: number;
79
- /** Smooth the wheel. false: the wheel scrolls natively (scrollTo() and anchors still animate). @default true */
80
- wheel?: boolean;
81
- /** Smooth touch too: follows the finger, eases its fling. Read once, at umber.use(). @default false (phones scroll natively) */
82
- touch?: boolean;
83
- /** Finger px times this. @default 1 */
84
- touchMultiplier?: number;
85
- /** A fling's lerp (Lenis's syncTouchLerp). @default about 0.05: a phone's own momentum (325 ms) */
86
- touchLerp?: number | null;
87
- /** A fling goes the finger's last px per frame to this power (Lenis's, which uses 1.7). null: speed x 325 ms, like a phone. @default null */
88
- touchInertiaExponent?: number | null;
89
- /** Sees every wheel and touch move first ({ deltaX, deltaY, event }); false leaves it to the browser (Lenis's virtualScroll). */
90
- virtualScroll?: ((data: VirtualScroll) => boolean) | null;
91
- /** What scrolls: the window (null) or an element (give it data-umber="scroller" so planes follow it). @default [data-umber~=scroller], else the window */
92
- wrapper?: Element | string | Window | null;
93
- /** What grows (watched for `limit`). @default the wrapper's first child, or <html> */
94
- content?: Element | string | null;
95
- /** In-page #id links scroll smoothly; an object: scrollTo() options for them (offset, duration...). @default true */
96
- anchors?: boolean | ScrollToOptions;
97
- /** Follow size changes (a ResizeObserver, resize). false: call resize() yourself. @default true */
98
- autoResize?: boolean;
99
- /** true for an element whose wheel / touch stays native (like data-umber-scroll-prevent). */
100
- prevent?: ((el: Element) => boolean) | null;
101
- /** An element under the pointer that scrolls by itself scrolls first, natively. @default true */
102
- nested?: boolean;
103
- /** stop() / start() follow the scroller's own overflow: a modal library that hides it stops the module, and showing it starts it (Lenis's autoToggle). @default false */
104
- autoToggle?: boolean;
105
- /** Where the wheel (and touch) are heard: the scroller (null), or another element. @default null */
106
- eventsTarget?: Element | string | Window | null;
107
- /** Endless: past the end it goes on from the start, and back (the page repeats its first screen at its end, as for Lenis's). @default false */
108
- infinite?: boolean;
109
- }
110
-
111
- /** umber.scroll: the shape scroll libraries share (scrollTo, animatedScroll, on("scroll")...). */
112
- export interface ScrollApi {
113
- /** Where the page is drawn now (px; with `infinite`, it counts on past the end and below 0). */
114
- readonly animatedScroll: number;
115
- /** Where the page is drawn, 0..limit (animatedScroll; with `infinite`, wrapped). */
116
- readonly scroll: number;
117
- /** Where it is heading (px). */
118
- readonly targetScroll: number;
119
- /** The real scroll position (px). */
120
- readonly actualScroll: number;
121
- /** The largest scroll (px). */
122
- readonly limit: number;
123
- /** px per frame at 60 fps (+ down); 0 at rest. */
124
- readonly velocity: number;
125
- /** The velocity before its last change. */
126
- readonly lastVelocity: number;
127
- /** The running scrollTo()'s userData; {} otherwise. */
128
- readonly userData: UserData;
129
- /** 1 down, -1 up (the last move's); 0 before any. */
130
- readonly direction: 1 | -1 | 0;
131
- /** animatedScroll / limit, 0..1. */
132
- readonly progress: number;
133
- /** "smooth" while it eases, "native" while the browser scrolls (keys, the scrollbar), else false. */
134
- readonly isScrolling: false | "smooth" | "native";
135
- readonly isStopped: boolean;
136
- readonly isLocked: boolean;
137
- /** The element that scrolls (<html> for the window). */
138
- readonly rootElement: Element;
139
- /** It scrolls sideways (orientation: "horizontal"). */
140
- readonly isHorizontal: boolean;
141
- /** The options, live: lerp, wheelMultiplier, anchors, prevent... are read on each use. */
142
- readonly options: ScrollOptions &
143
- Required<
144
- Pick<
145
- ScrollOptions,
146
- | "gestureOrientation"
147
- | "lerp"
148
- | "duration"
149
- | "wheelMultiplier"
150
- | "wheel"
151
- | "touchMultiplier"
152
- | "anchors"
153
- | "autoResize"
154
- | "nested"
155
- >
156
- >;
157
- /** @example umber.scroll.scrollTo("#contact", { offset: -80, duration: 1.2 }) */
158
- scrollTo(target: ScrollTarget, options?: ScrollToOptions): void;
159
- /** Hold the page (a modal, a page change): no wheel, touch, keys or scrollTo() (one with force or immediate still moves) until start(). */
160
- stop(): void;
161
- start(): void;
162
- /** Measure again now and take the real position (after a page swap). */
163
- resize(): void;
164
- /** A smooth scroller of its own for an element inside the page (Lenis's nested instances; also data-umber="nested"): resolves with it, or null when there is no such element. */
165
- nest(target: Element | string, options?: ScrollOptions): Promise<ScrollApi | null>;
166
- /** "scroll": every frame it moves, and on native scrolls, with umber.scroll. "virtual-scroll": every wheel and touch move it hears. Returns its off(). */
167
- on(event: "scroll", fn: (scroll: ScrollApi) => void): () => void;
168
- on(event: "virtual-scroll", fn: (data: VirtualScroll) => void): () => void;
169
- off(event: "scroll", fn: (scroll: ScrollApi) => void): void;
170
- off(event: "virtual-scroll", fn: (data: VirtualScroll) => void): void;
171
- /** Step it from your own loop (ms). Never needed: Umber's loop runs it, and leaves it to you while you call this. */
172
- raf(time: number): void;
173
- destroy(): void;
174
- }
175
-
176
- declare module "./umber.js" {
177
- interface Umber {
178
- /** The scroll module's smooth scroller (types/scroll.d.ts). */
179
- readonly scroll: ScrollApi;
180
- }
181
- }
182
-
183
- /** umber.use(Scroll, options), createUmber({ modules: [[Scroll, options]] }). */
184
- export declare const Scroll: UmberModule;
185
-
186
- /** The same without umber.use(): adds umber.scroll to `engine`. */
187
- export declare function smoothScroll(engine: Umber, options?: ScrollOptions): ScrollApi;
188
-
189
- /** @alias The same module as the named export, for `import Scroll from`. */
190
- export default Scroll;
package/types/svelte.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Types for @occluze/umber/svelte: a store of umber.scroll (Svelte's store contract).
3
- *
4
- * import { scroll } from "@occluze/umber/svelte";
5
- * $: progress = $scroll?.progress ?? 0;
6
- */
7
-
8
- import type { ScrollApi } from "./scroll.js";
9
-
10
- /** A readable store: umber.scroll, again every frame it moves (null without the scroll module). The engine: the one on the page, or `gl`. */
11
- export declare function scrollStore(gl?: { readonly scroll?: ScrollApi } | null): {
12
- subscribe(run: (scroll: ScrollApi | null) => void): () => void;
13
- };
14
-
15
- /** The store of the engine on the page. */
16
- export declare const scroll: ReturnType<typeof scrollStore>;
package/types/vue.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * Types for @occluze/umber/vue: useScroll(), Lenis's useLenis() for Umber's umber.scroll.
3
- *
4
- * import { useScroll } from "@occluze/umber/vue";
5
- * const scroll = useScroll((s) => (progress.value = s.progress));
6
- */
7
-
8
- import type { ScrollApi } from "./scroll.js";
9
-
10
- /** A ref (Vue's shallowRef) to umber.scroll (null until mounted, or without the scroll module); `callback` hears its "scroll" while mounted. The engine: the one on the page, or `gl`. */
11
- export declare function useScroll(
12
- callback?: (scroll: ScrollApi) => void,
13
- gl?: { readonly scroll?: ScrollApi } | null,
14
- ): { value: ScrollApi | null };