@n-uf/motion 26.11.61 → 26.11.63

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/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ within the month), the same scheme as `@n-uf/hypr-tiling`.
5
5
 
6
6
  Unreleased entries live in `changes/` until a release joins them.
7
7
 
8
+ ## 26.11.63
9
+
10
+ - The paged swipe takes the rules a finger needs. A `touch-start` marked `claimed` (the system's screen edge, content that keeps its gestures) never arms. A new `scrolled` input takes a finger's swipe in progress, and a finger that goes down within `idle` of one never arms, so a flick that ran a scroll to its end doesn't page on the next flick. A finger that rested `flickRest` (new, 100 ms) before lifting is no flick. With `band` (new, off by default) a finger also tracks towards a side with no page, at progress 0, never committing there, and the new `rubberBand(over, size, strength?)` gives the distance to draw. `PagedSwipeContext` gains `scrolledAt`.
11
+ - A cancel no longer skips a lockout: a committing settle that is cancelled goes to its lockout, so a trackpad's momentum can't commit twice.
12
+ - A wheel sample's speed is its own delta over its time step, not the difference of two travels, which floating point could put a hair off and tip a commit at the speed threshold.
13
+ - A paged swipe keeps the pages and the size it armed with until it ends: a `context` sent mid-gesture is kept for the next swipe and changes neither the page nor the progress of the one in progress. The tracking state carries it as `held`.
14
+ - A blocked `pagedSwipeOn` (a drag owns the pointer) announces no pages in `SWIPE_PAGES_ATTRIBUTE`, so a swipe further out takes the gesture instead of yielding to one that can't page; unblocked, its pages come back.
15
+ - `pagedSwipeOn`'s `SwipeElement` and `SwipeHost` take a real element and `window` under lib.dom (their listeners are typed to accept any event).
16
+ - `SWIPE_PAGES_ATTRIBUTE` names the ways a swipe pages per input: `x+` for a finger, `wx+` for a wheel run. A nested swipe yields only for the input it pages with, so a wheel-only inner swipe no longer stops a finger's outer one, and the reverse.
17
+ - A finger's lift ends the swipe `SWIPE_LIFT_WAIT_MS` (34) later, so the scroll events of the frame it lifted in still take the swipe.
18
+ - A cancel with nothing drawn away from rest (progress 0) ends at once, so a host with nothing to animate is never left settling.
19
+ - A wheel run's first tracking sample no longer calls `preventDefault` on the passive listener it arrived on.
20
+ - `@n-uf/motion/browser` gains `pagedSwipeOn(element, { clock, config?, touch?, wheel?, edgeZone?, host? })`: a paged swipe on an element, the machine and the DOM that feeds it. The nearest thing that way takes the gesture: a scroller that can still scroll that way, or another paged swipe with a page that way (`SWIPE_PAGES_ATTRIBUTE`, kept current by its driver, so nested pagers compose, two copies of the module included). A start in the viewport's edge zone (`SWIPE_EDGE_ZONE_PX`, 24) or on `SWIPE_KEEP_ATTRIBUTE` content is claimed; scrolls are sent as `scrolled`; a second finger cancels. Also `canScrollFurther(element, axis, direction, host)`, and the shapes `SwipeElement` and `SwipeHost`.
21
+ - The paged swipe's new fields are optional: `flickRest` and `band` on `PagedSwipeConfig`, `scrolledAt` on `PagedSwipeContext`, so a config or context written before them still compiles; their defaults apply inside.
22
+ - In a lockout, a touch start that would not arm (claimed, or right after a scroll) leaves the lockout running.
23
+
24
+ ## 26.11.62
25
+
26
+ - **A release sample stamped under 1 ms after the last frame no longer changes the place.** The landing model's hand
27
+ speed read the few pixels such a sample moved over 1 ms (the shortest interval it divided by), a third of the real
28
+ speed or less, so a hand flicked down a lane read slow on its release sample and the held spot could switch on it,
29
+ 100 px or more from the spot the last frame held. A sample stamped under 1 ms past the newest one the hand holds is
30
+ now the same sample: it is left out, so the step, the speed and the steadiness read as they did before it (a gap a
31
+ coarse clock rounds up to 1 ms is a step, as before). In a run of samples all stamped under 1 ms apart (a host
32
+ sampling above 1 kHz) the first one that lies 1 ms or more past the newest held is read over its whole interval, so
33
+ the step and the speed follow the hand: a fling and then a slow creep, both sampled every 0.5 ms, reads slow once the
34
+ creep has lasted the span, and a slide enters a touching lane at 2 and 8 kHz as it does at 1 kHz. A sample stamped
35
+ before the newest one held (the times of one drag are expected never to go back) is left out the same way, however
36
+ far behind: one late stamp changes nothing. Two of them, both 40 ms or more behind and 20 ms or more apart, with no
37
+ in-order sample or repeated frame between, are taken for a clock that stepped back, and the hand starts again from the
38
+ second (two late stamps that far behind and apart restart it though the clock did not step).
39
+
8
40
  ## 26.11.61
9
41
 
10
42
  - **A dropped frame no longer loses a slide.** The landing model's hand speed tells a rest from frames the host lost:
package/dist/browser.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { C as ClockPort } from './port-CmlUctqx.js';
1
+ import { C as ClockPort, T as TimerSource } from './port-CmlUctqx.js';
2
2
  import { R as Rect } from './shapes-EbQlwbCu.js';
3
3
  import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion-sElR1A_c.js';
4
+ import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-CIzjr2DQ.js';
4
5
  import './frame-loop-f0V4b464.js';
5
6
  import './reveal-Dg5fqoWS.js';
7
+ import './keys-BpcrOp4S.js';
6
8
 
7
9
  /**
8
10
  * The parts of a browser global this adapter uses. Typed here instead of
@@ -115,4 +117,105 @@ interface FlipEntry {
115
117
  */
116
118
  declare function flip(entries: readonly FlipEntry[], change: () => void): void;
117
119
 
118
- export { type BoxNodes, type BrowserClockOptions, type BrowserHost, type FlipEntry, type Measurable, type RectLike, type StyleLike, type Styled, createBrowserClock, domDrawable, drawBox, flip, layOutBox, prefersReducedMotion, rectOf };
120
+ /**
121
+ * Put on an element whose content keeps its own gestures (a map, a carousel, a slider): a swipe that starts on it
122
+ * never pages. Empty for both axes, or `"x"` / `"y"` for one.
123
+ */
124
+ declare const SWIPE_KEEP_ATTRIBUTE = "data-swipe-keep";
125
+ /**
126
+ * Kept on every element a {@link pagedSwipeOn} runs on: the ways it can page, per input, space-separated. A finger's
127
+ * are `x+`, `x-`, `y+`, `y-` (the scroll direction a swipe there has: a finger moving left is `x+`); a wheel run's
128
+ * carry a `w` before them (`wx+`). Another swipe further out reads it the way it reads a scroller that can still
129
+ * scroll, for the input in hand, so the nearest one that can take that gesture does. It lives in the DOM, not in
130
+ * module memory, so two copies of this module in one page still see each other.
131
+ */
132
+ declare const SWIPE_PAGES_ATTRIBUTE = "data-swipe-pages";
133
+ /** The px at the viewport's edges (along the swipe) where the system takes swipes: a finger that starts there never pages. */
134
+ declare const SWIPE_EDGE_ZONE_PX = 24;
135
+ /**
136
+ * ms a finger's lift waits before it ends the swipe: the scroll events of the frame the finger lifted in arrive after
137
+ * the lift, and a swipe during which something scrolled must not commit. Two frames at 60 Hz.
138
+ */
139
+ declare const SWIPE_LIFT_WAIT_MS = 34;
140
+ /** A DOM listener as `addEventListener` takes it. Typed `any` so a real element or window (lib.dom) can be passed. */
141
+ type SwipeListener = (event: any) => void;
142
+ /** An element as the driver uses it (typed by shape, so the package builds without lib.dom). */
143
+ interface SwipeElement {
144
+ readonly parentElement: SwipeElement | null;
145
+ readonly scrollLeft: number;
146
+ readonly scrollTop: number;
147
+ readonly scrollWidth: number;
148
+ readonly scrollHeight: number;
149
+ readonly clientWidth: number;
150
+ readonly clientHeight: number;
151
+ getAttribute(name: string): string | null;
152
+ setAttribute(name: string, value: string): void;
153
+ removeAttribute(name: string): void;
154
+ contains(other: unknown): boolean;
155
+ addEventListener(type: string, listener: SwipeListener, options?: {
156
+ readonly passive?: boolean;
157
+ }): void;
158
+ removeEventListener(type: string, listener: SwipeListener): void;
159
+ }
160
+ /** The global the driver reads: the viewport, computed styles, and the document-wide scroll events. */
161
+ interface SwipeHost {
162
+ readonly innerWidth: number;
163
+ readonly innerHeight: number;
164
+ getComputedStyle(element: SwipeElement): {
165
+ readonly overflowX: string;
166
+ readonly overflowY: string;
167
+ readonly direction: string;
168
+ };
169
+ addEventListener(type: string, listener: SwipeListener, options?: {
170
+ readonly passive?: boolean;
171
+ readonly capture?: boolean;
172
+ }): void;
173
+ removeEventListener(type: string, listener: SwipeListener, options?: {
174
+ readonly capture?: boolean;
175
+ }): void;
176
+ }
177
+ /** Options of {@link pagedSwipeOn}. */
178
+ interface PagedSwipeOnOptions {
179
+ /** The machine's clock: its `now()` stamps every sample. */
180
+ readonly clock: TimerSource;
181
+ readonly config?: Partial<PagedSwipeConfig>;
182
+ /** A finger swipes. Default true. */
183
+ readonly touch?: boolean;
184
+ /** A trackpad's two-finger scroll (a wheel run) swipes. Default false. */
185
+ readonly wheel?: boolean;
186
+ /** Default {@link SWIPE_EDGE_ZONE_PX}. */
187
+ readonly edgeZone?: number;
188
+ /** Default `globalThis`. */
189
+ readonly host?: SwipeHost;
190
+ }
191
+ /** What {@link pagedSwipeOn} returns: the running machine (send it `context`, `block`, `settled`), and the way out. */
192
+ interface PagedSwipeOn {
193
+ readonly swipe: Machine<PagedSwipeState, PagedSwipeInput>;
194
+ dispose(): void;
195
+ }
196
+ /** Whether one element can still scroll along `axis` towards `direction` (1: right / down), right-to-left included. */
197
+ declare function canScrollFurther(element: SwipeElement, axis: "x" | "y", direction: 1 | -1, host: SwipeHost): boolean;
198
+ /**
199
+ * A paged swipe on an element: the machine ({@link createPagedSwipe}) and the DOM that feeds it.
200
+ *
201
+ * - **The nearest thing that way takes the gesture.** From the touched element out to this one, the first of: a
202
+ * scroller that can still scroll that way, or another paged swipe ({@link SWIPE_PAGES_ATTRIBUTE}) with a page that
203
+ * way for the same input, takes it; this swipe then doesn't arm. One with `band` takes every finger's swipe along its
204
+ * axis.
205
+ * - **Claimed starts (a finger only):** a finger that goes down within `edgeZone` of the viewport's edges along the
206
+ * swipe (where the system takes swipes: back, the home bar), or on an element marked {@link SWIPE_KEEP_ATTRIBUTE},
207
+ * never pages. A wheel run ignores both.
208
+ * - **Scrolls:** a scroll inside this element, or of the page, while or just before a finger swipes is sent as
209
+ * `scrolled` (the machine's rest rule). A lift ends the swipe {@link SWIPE_LIFT_WAIT_MS} later, so the scroll events
210
+ * of its last frame still count.
211
+ * - A second finger, or the browser taking the touch, cancels. A cancel that has nothing to animate back (progress 0)
212
+ * ends at once; any other settle waits for the host's `settled`.
213
+ * - Touch listeners are passive; the wheel listener is passive except while a wheel run is tracking, when it holds the
214
+ * page still (`preventDefault`).
215
+ *
216
+ * The page size is the element's client extent along the swipe. The host sends `context` (which pages there are),
217
+ * `block` (a drag owns the pointer), and `settled` when its page transition is done.
218
+ */
219
+ declare function pagedSwipeOn(element: SwipeElement, options: PagedSwipeOnOptions): PagedSwipeOn;
220
+
221
+ export { type BoxNodes, type BrowserClockOptions, type BrowserHost, type FlipEntry, type Measurable, type PagedSwipeOn, type PagedSwipeOnOptions, type RectLike, SWIPE_EDGE_ZONE_PX, SWIPE_KEEP_ATTRIBUTE, SWIPE_LIFT_WAIT_MS, SWIPE_PAGES_ATTRIBUTE, type StyleLike, type Styled, type SwipeElement, type SwipeHost, canScrollFurther, createBrowserClock, domDrawable, drawBox, flip, layOutBox, pagedSwipeOn, prefersReducedMotion, rectOf };
package/dist/browser.js CHANGED
@@ -1,3 +1,11 @@
1
+ import {
2
+ PAGED_SWIPE_DEFAULTS,
3
+ createPagedSwipe,
4
+ wheelDelta
5
+ } from "./chunk-K6TAWCGL.js";
6
+ import "./chunk-OOKRBVMB.js";
7
+ import "./chunk-RWDYRT3H.js";
8
+
1
9
  // src/browser/browser-clock.ts
2
10
  function createBrowserClock(options = {}) {
3
11
  const host = options.host ?? globalThis;
@@ -87,12 +95,219 @@ function flip(entries, change) {
87
95
  e.item.glideFrom(from, to);
88
96
  });
89
97
  }
98
+
99
+ // src/browser/paged-swipe-on.ts
100
+ var SWIPE_KEEP_ATTRIBUTE = "data-swipe-keep";
101
+ var SWIPE_PAGES_ATTRIBUTE = "data-swipe-pages";
102
+ var SWIPE_EDGE_ZONE_PX = 24;
103
+ var SWIPE_LIFT_WAIT_MS = 34;
104
+ var SCROLLABLE = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
105
+ var EPSILON = 1;
106
+ function canScrollFurther(element, axis, direction, host) {
107
+ const style = host.getComputedStyle(element);
108
+ if (axis === "y") {
109
+ if (!SCROLLABLE.has(style.overflowY)) return false;
110
+ const max2 = element.scrollHeight - element.clientHeight;
111
+ if (max2 <= EPSILON) return false;
112
+ return direction === 1 ? element.scrollTop < max2 - EPSILON : element.scrollTop > EPSILON;
113
+ }
114
+ if (!SCROLLABLE.has(style.overflowX)) return false;
115
+ const max = element.scrollWidth - element.clientWidth;
116
+ if (max <= EPSILON) return false;
117
+ const left = element.scrollLeft;
118
+ if (style.direction === "rtl") return direction === 1 ? left < -EPSILON : left > -max + EPSILON;
119
+ return direction === 1 ? left < max - EPSILON : left > EPSILON;
120
+ }
121
+ var isElement = (node) => typeof node === "object" && node !== null && typeof node.getAttribute === "function";
122
+ function elementOf(target) {
123
+ if (isElement(target)) return target;
124
+ const parent = typeof target === "object" && target !== null ? target.parentElement : null;
125
+ return isElement(parent) ? parent : null;
126
+ }
127
+ var token = (input, axis, direction) => `${input === "wheel" ? "w" : ""}${axis}${direction === 1 ? "+" : "-"}`;
128
+ function pagedSwipeOn(element, options) {
129
+ const config = { ...PAGED_SWIPE_DEFAULTS, ...options.config };
130
+ const axis = config.along;
131
+ const host = options.host ?? globalThis;
132
+ const edgeZone = options.edgeZone ?? SWIPE_EDGE_ZONE_PX;
133
+ const touchOn = options.touch !== false;
134
+ const wheelOn = options.wheel === true;
135
+ const swipe = createPagedSwipe({ clock: options.clock, config });
136
+ const now = () => options.clock.now();
137
+ const size = () => {
138
+ const extent = axis === "y" ? element.clientHeight : element.clientWidth;
139
+ return extent > 0 ? extent : void 0;
140
+ };
141
+ const nearerGoes = (target, direction, input) => {
142
+ const wanted = token(input, axis, direction);
143
+ for (let node = elementOf(target); node !== null; node = node.parentElement) {
144
+ if (canScrollFurther(node, axis, direction, host)) return true;
145
+ if (node === element) return false;
146
+ const pages = node.getAttribute(SWIPE_PAGES_ATTRIBUTE);
147
+ if (pages !== null && pages.split(" ").includes(wanted)) return true;
148
+ }
149
+ return false;
150
+ };
151
+ const kept = (target) => {
152
+ for (let node = elementOf(target); node !== null && node !== element; node = node.parentElement) {
153
+ const keep = node.getAttribute(SWIPE_KEEP_ATTRIBUTE);
154
+ if (keep !== null && (keep === "" || keep === axis)) return true;
155
+ }
156
+ return false;
157
+ };
158
+ const inEdgeZone = (point) => {
159
+ const at = axis === "y" ? point.clientY : point.clientX;
160
+ const extent = axis === "y" ? host.innerHeight : host.innerWidth;
161
+ return edgeZone > 0 && (at < edgeZone || at > extent - edgeZone);
162
+ };
163
+ let shownPages = null;
164
+ const showPages = (state) => {
165
+ const ways = [];
166
+ const open = !state.context.blocked;
167
+ const wrapsAny = open && config.wrap && (state.context.hasPrev || state.context.hasNext);
168
+ const next = open && (wrapsAny || state.context.hasNext);
169
+ const prev = open && (wrapsAny || state.context.hasPrev);
170
+ const band = open && config.band === true;
171
+ if (touchOn && (band || next)) ways.push(token("touch", axis, 1));
172
+ if (touchOn && (band || prev)) ways.push(token("touch", axis, -1));
173
+ if (wheelOn && next) ways.push(token("wheel", axis, 1));
174
+ if (wheelOn && prev) ways.push(token("wheel", axis, -1));
175
+ const shown = ways.join(" ");
176
+ if (shown === shownPages) return;
177
+ shownPages = shown;
178
+ element.setAttribute(SWIPE_PAGES_ATTRIBUTE, shown);
179
+ };
180
+ showPages(swipe.peek());
181
+ let touch = null;
182
+ const tracked = (event) => {
183
+ if (touch === null) return null;
184
+ for (let index = 0; index < event.changedTouches.length; index += 1) {
185
+ const point = event.changedTouches[index];
186
+ if (point !== void 0 && point.identifier === touch.id) return point;
187
+ }
188
+ return null;
189
+ };
190
+ const cancelTouch = () => {
191
+ if (touch === null) return;
192
+ touch = null;
193
+ swipe.send({ type: "cancel" });
194
+ };
195
+ let lift = null;
196
+ const endLift = () => {
197
+ if (lift === null) return;
198
+ const { t, timer } = lift;
199
+ lift = null;
200
+ options.clock.clearTimer(timer);
201
+ swipe.send({ type: "touch-end", t });
202
+ };
203
+ const onTouchStart = (event) => {
204
+ endLift();
205
+ if (event.touches.length > 1) {
206
+ cancelTouch();
207
+ return;
208
+ }
209
+ const point = event.changedTouches[0];
210
+ if (point === void 0) return;
211
+ touch = { id: point.identifier, target: event.target, x: point.clientX, y: point.clientY };
212
+ swipe.send({ type: "touch-start", x: point.clientX, y: point.clientY, t: now(), size: size(), claimed: inEdgeZone(point) || kept(event.target) });
213
+ };
214
+ const onTouchMove = (event) => {
215
+ if (touch === null) return;
216
+ if (event.touches.length > 1) {
217
+ cancelTouch();
218
+ return;
219
+ }
220
+ const point = tracked(event);
221
+ if (point === null) return;
222
+ const state = swipe.peek();
223
+ const travel = axis === "y" ? touch.y - point.clientY : touch.x - point.clientX;
224
+ const goes = state.phase === "armed" && travel !== 0 ? nearerGoes(touch.target, travel > 0 ? 1 : -1, "touch") : false;
225
+ swipe.send({ type: "touch-move", x: point.clientX, y: point.clientY, t: now(), canScrollFurther: goes, size: size() });
226
+ };
227
+ const onTouchEnd = (event) => {
228
+ if (tracked(event) === null) return;
229
+ touch = null;
230
+ endLift();
231
+ lift = { t: now(), timer: options.clock.setTimer(endLift, SWIPE_LIFT_WAIT_MS) };
232
+ };
233
+ const onTouchCancel = (event) => {
234
+ if (tracked(event) !== null) cancelTouch();
235
+ };
236
+ const onScroll = (event) => {
237
+ if (isElement(event.target) && !element.contains(event.target)) return;
238
+ swipe.send({ type: "scrolled", t: now() });
239
+ };
240
+ let wheelPassive = true;
241
+ const onWheel = (event) => {
242
+ const delta = wheelDelta(event.deltaX, event.deltaY, event.deltaMode === 1 || event.deltaMode === 2 ? event.deltaMode : 0);
243
+ const main = axis === "y" ? delta.y : delta.x;
244
+ const before = swipe.peek();
245
+ const holdable = !wheelPassive;
246
+ const goes = main !== 0 && (before.phase === "idle" || before.phase === "armed") ? nearerGoes(event.target, main > 0 ? 1 : -1, "wheel") : false;
247
+ const after = swipe.send({
248
+ type: "wheel",
249
+ dx: delta.x,
250
+ dy: delta.y,
251
+ t: now(),
252
+ modifiers: { ctrl: event.ctrlKey, meta: event.metaKey, alt: event.altKey, shift: event.shiftKey },
253
+ canScrollFurther: goes,
254
+ size: size()
255
+ });
256
+ if (holdable && after.phase === "tracking" && after.input === "wheel" && event.cancelable !== false) event.preventDefault();
257
+ };
258
+ const attachWheel = (passive) => {
259
+ element.removeEventListener("wheel", onWheel);
260
+ element.addEventListener("wheel", onWheel, { passive });
261
+ wheelPassive = passive;
262
+ };
263
+ const unsubscribe = swipe.subscribe((next, previous) => {
264
+ if (next.context !== previous.context) showPages(next);
265
+ if (next.phase === "settling" && previous.phase !== "settling" && next.outcome === "cancel" && next.progress === 0) swipe.send({ type: "settled" });
266
+ const holding = next.phase === "tracking" && next.input === "wheel";
267
+ if (wheelOn && holding === wheelPassive) attachWheel(!holding);
268
+ });
269
+ if (touchOn) {
270
+ element.addEventListener("touchstart", onTouchStart, { passive: true });
271
+ element.addEventListener("touchmove", onTouchMove, { passive: true });
272
+ element.addEventListener("touchend", onTouchEnd, { passive: true });
273
+ element.addEventListener("touchcancel", onTouchCancel, { passive: true });
274
+ host.addEventListener("scroll", onScroll, { passive: true, capture: true });
275
+ }
276
+ if (wheelOn) attachWheel(true);
277
+ let disposed = false;
278
+ return {
279
+ swipe,
280
+ dispose: () => {
281
+ if (disposed) return;
282
+ disposed = true;
283
+ if (lift !== null) options.clock.clearTimer(lift.timer);
284
+ lift = null;
285
+ unsubscribe();
286
+ if (touchOn) {
287
+ element.removeEventListener("touchstart", onTouchStart);
288
+ element.removeEventListener("touchmove", onTouchMove);
289
+ element.removeEventListener("touchend", onTouchEnd);
290
+ element.removeEventListener("touchcancel", onTouchCancel);
291
+ host.removeEventListener("scroll", onScroll, { capture: true });
292
+ }
293
+ if (wheelOn) element.removeEventListener("wheel", onWheel);
294
+ element.removeAttribute(SWIPE_PAGES_ATTRIBUTE);
295
+ swipe.dispose();
296
+ }
297
+ };
298
+ }
90
299
  export {
300
+ SWIPE_EDGE_ZONE_PX,
301
+ SWIPE_KEEP_ATTRIBUTE,
302
+ SWIPE_LIFT_WAIT_MS,
303
+ SWIPE_PAGES_ATTRIBUTE,
304
+ canScrollFurther,
91
305
  createBrowserClock,
92
306
  domDrawable,
93
307
  drawBox,
94
308
  flip,
95
309
  layOutBox,
310
+ pagedSwipeOn,
96
311
  prefersReducedMotion,
97
312
  rectOf
98
313
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/browser/browser-clock.ts","../src/browser/dom.ts","../src/browser/flip.ts"],"sourcesContent":["import type { ClockPort } from \"../clock/port\";\n\n/**\n * The parts of a browser global this adapter uses. Typed here instead of\n * through lib.dom, so the package builds without DOM types and a test (or a\n * worker, or a server) can pass its own host.\n */\nexport interface BrowserHost {\n requestAnimationFrame?(callback: (time: number) => void): number;\n cancelAnimationFrame?(handle: number): void;\n setTimeout(callback: () => void, ms?: number): unknown;\n clearTimeout(handle: unknown): void;\n readonly performance?: { now(): number };\n matchMedia?(query: string): { readonly matches: boolean };\n}\n\n/** Options of {@link createBrowserClock}. */\nexport interface BrowserClockOptions {\n /** The global to use. Default `globalThis`. */\n readonly host?: BrowserHost;\n /** Frame interval when the host has no requestAnimationFrame. Default 1000/60. */\n readonly fallbackFrameInterval?: number;\n}\n\n/**\n * A {@link ClockPort} on requestAnimationFrame, performance.now and\n * setTimeout. Without requestAnimationFrame (a worker, a server) frames come\n * from setTimeout at `fallbackFrameInterval`; without performance, time comes from\n * Date.now.\n */\nexport function createBrowserClock(options: BrowserClockOptions = {}): ClockPort {\n const host = options.host ?? (globalThis as unknown as BrowserHost);\n const fallbackFrameInterval = options.fallbackFrameInterval ?? 1000 / 60;\n const performance = host.performance;\n const now = performance !== undefined ? () => performance.now() : () => Date.now();\n\n // Timer handles are numbers in browsers and objects in Node; the port\n // promises numbers, so keep our own.\n let nextTimer = 1;\n const timers = new Map<number, unknown>();\n\n const setTimer = (callback: () => void, ms: number): number => {\n const id = nextTimer++;\n timers.set(\n id,\n host.setTimeout(() => {\n timers.delete(id);\n callback();\n }, Math.max(0, ms)),\n );\n return id;\n };\n\n const clearTimer = (id: number): void => {\n const handle = timers.get(id);\n if (handle === undefined) return;\n timers.delete(id);\n host.clearTimeout(handle);\n };\n\n const raf = host.requestAnimationFrame;\n const caf = host.cancelAnimationFrame;\n if (raf !== undefined && caf !== undefined) {\n return {\n now,\n requestFrame: (callback) => raf.call(host, () => callback()),\n cancelFrame: (handle) => caf.call(host, handle),\n setTimer,\n clearTimer,\n };\n }\n return {\n now,\n requestFrame: (callback) => setTimer(callback, fallbackFrameInterval),\n cancelFrame: clearTimer,\n setTimer,\n clearTimer,\n };\n}\n\n/**\n * The user's reduced-motion preference as a function, for a motion value's\n * `reducedMotion` option. It reads the media query on each call, so a change\n * in the system setting applies to the next target and the next frame.\n * Without matchMedia it always returns `false`.\n */\nexport function prefersReducedMotion(host: BrowserHost = globalThis as unknown as BrowserHost): () => boolean {\n const query = host.matchMedia?.(\"(prefers-reduced-motion: reduce)\");\n return () => query?.matches ?? false;\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"../layout\";\n\n/**\n * The style properties the layout motion writes, as strings (a DOM node's `style` has them all). Structural: the\n * library needs no DOM types.\n */\nexport interface StyleLike {\n left: string;\n top: string;\n width: string;\n height: string;\n transform: string;\n opacity: string;\n clipPath: string;\n visibility: string;\n}\n\n/** Something with a writable {@link StyleLike} `style`: a DOM node. */\nexport interface Styled {\n readonly style: StyleLike;\n}\n\n/**\n * The nodes of a drawn box: `node` is laid out at the box and moved to the drawn rect; `frame` (background, border,\n * shadow) is drawn at the drawn size; `content` is clipped to it. With no `frame` and `content`, `node` itself is\n * clipped (its content laid out at the box, never stretched).\n */\nexport interface BoxNodes {\n readonly node: Styled;\n readonly frame?: Styled;\n readonly content?: Styled;\n}\n\n/** Lay `node` out at `box`: its position and size, in its offset parent's coordinates. */\nexport function layOutBox(node: Styled, box: Rect): void {\n const s = node.style;\n s.left = `${box.x}px`;\n s.top = `${box.y}px`;\n s.width = `${box.width}px`;\n s.height = `${box.height}px`;\n}\n\n/**\n * Draw one frame of a box laid out by {@link layOutBox}: one transform (the move to the drawn rect, and the uniform\n * appearance about its center), the frame at the drawn size, the content clipped (reveal); hidden when gone.\n */\nexport function drawBox(nodes: BoxNodes, frame: DrawFrame): void {\n const { reveal: r, pop } = frame;\n const cx = frame.drawn.width / 2;\n const cy = frame.drawn.height / 2;\n const s = nodes.node.style;\n s.transform =\n pop.scale === 1 ? `translate(${r.dx}px, ${r.dy}px)` : `translate(${r.dx}px, ${r.dy}px) translate(${cx}px, ${cy}px) scale(${pop.scale}) translate(${-cx}px, ${-cy}px)`;\n s.opacity = pop.opacity === 1 ? \"\" : String(pop.opacity);\n if (nodes.frame) {\n nodes.frame.style.width = `${r.width}px`;\n nodes.frame.style.height = `${r.height}px`;\n }\n const clipped = nodes.content ?? (nodes.frame ? null : nodes.node);\n if (clipped) clipped.style.clipPath = r.clipRight || r.clipBottom ? `inset(0 ${r.clipRight}px ${r.clipBottom}px 0)` : \"\";\n // All the way gone: out of sight and out of the way of the pointer.\n s.visibility = frame.gone ? \"hidden\" : \"\";\n}\n\n/** A {@link Drawable} for DOM nodes: {@link layOutBox} on a new box, {@link drawBox} on every frame. */\nexport function domDrawable(nodes: BoxNodes): Drawable {\n return {\n layOut: (box) => layOutBox(nodes.node, box),\n draw: (frame) => drawBox(nodes, frame),\n };\n}\n","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"../layout\";\n\n/** A rect as a DOM rect reports it (`getBoundingClientRect()`): left, top, width, height. */\nexport interface RectLike {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Anything that can say where it is drawn: a DOM node, or a test's stand-in. */\nexport interface Measurable {\n getBoundingClientRect(): RectLike;\n}\n\n/** A {@link RectLike} as a {@link Rect}. */\nexport const rectOf = (r: RectLike): Rect => ({ x: r.left, y: r.top, width: r.width, height: r.height });\n\n/** One member of a {@link flip}: an item, the node it draws, and where it goes once the DOM has changed. */\nexport interface FlipEntry {\n readonly item: LayoutItem;\n readonly node: Measurable;\n /**\n * Once the DOM has changed: the old rect (as measured before, in page coordinates) in the item's own coordinates\n * now, and its new place there.\n */\n readonly place: (before: Rect) => { readonly from: Rect; readonly to: Rect };\n}\n\n/**\n * FLIP for DOM groups, on settle: record where each node is drawn (first), change the DOM (`change`: move nodes to\n * other parents, reorder them), then each item is drawn at its old rect and settles to its new place (last, invert,\n * play). No transform tween: a settle from the rect it was drawn at, so it never jumps or overshoots, and its size\n * changes through reveal.\n */\nexport function flip(entries: readonly FlipEntry[], change: () => void): void {\n const before = entries.map((e) => rectOf(e.node.getBoundingClientRect()));\n change();\n entries.forEach((e, i) => {\n const { from, to } = e.place(before[i]!);\n e.item.glideFrom(from, to);\n });\n}\n"],"mappings":";AA8BO,SAAS,mBAAmB,UAA+B,CAAC,GAAc;AAC/E,QAAM,OAAO,QAAQ,QAAS;AAC9B,QAAM,wBAAwB,QAAQ,yBAAyB,MAAO;AACtE,QAAM,cAAc,KAAK;AACzB,QAAM,MAAM,gBAAgB,SAAY,MAAM,YAAY,IAAI,IAAI,MAAM,KAAK,IAAI;AAIjF,MAAI,YAAY;AAChB,QAAM,SAAS,oBAAI,IAAqB;AAExC,QAAM,WAAW,CAAC,UAAsB,OAAuB;AAC7D,UAAM,KAAK;AACX,WAAO;AAAA,MACL;AAAA,MACA,KAAK,WAAW,MAAM;AACpB,eAAO,OAAO,EAAE;AAChB,iBAAS;AAAA,MACX,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,CAAC,OAAqB;AACvC,UAAM,SAAS,OAAO,IAAI,EAAE;AAC5B,QAAI,WAAW,OAAW;AAC1B,WAAO,OAAO,EAAE;AAChB,SAAK,aAAa,MAAM;AAAA,EAC1B;AAEA,QAAM,MAAM,KAAK;AACjB,QAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,UAAa,QAAQ,QAAW;AAC1C,WAAO;AAAA,MACL;AAAA,MACA,cAAc,CAAC,aAAa,IAAI,KAAK,MAAM,MAAM,SAAS,CAAC;AAAA,MAC3D,aAAa,CAAC,WAAW,IAAI,KAAK,MAAM,MAAM;AAAA,MAC9C;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,cAAc,CAAC,aAAa,S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QAAQ,UAAU,MAAM,MAAM,GAAG;AAAA,IAC1C,MAAM,CAAC,UAAU,QAAQ,OAAO,KAAK;AAAA,EACvC;AACF;;;ACtDO,IAAM,SAAS,CAAC,OAAuB,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,OAAO;AAmB/F,SAAS,KAAK,SAA+B,QAA0B;AAC5E,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM,OAAO,EAAE,KAAK,sBAAsB,CAAC,CAAC;AACxE,SAAO;AACP,UAAQ,QAAQ,CAAC,GAAG,MAAM;AACxB,UAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,OAAO,CAAC,CAAE;AACvC,MAAE,KAAK,UAAU,MAAM,EAAE;AAAA,EAC3B,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/browser/browser-clock.ts","../src/browser/dom.ts","../src/browser/flip.ts","../src/browser/paged-swipe-on.ts"],"sourcesContent":["import type { ClockPort } from \"../clock/port\";\n\n/**\n * The parts of a browser global this adapter uses. Typed here instead of\n * through lib.dom, so the package builds without DOM types and a test (or a\n * worker, or a server) can pass its own host.\n */\nexport interface BrowserHost {\n requestAnimationFrame?(callback: (time: number) => void): number;\n cancelAnimationFrame?(handle: number): void;\n setTimeout(callback: () => void, ms?: number): unknown;\n clearTimeout(handle: unknown): void;\n readonly performance?: { now(): number };\n matchMedia?(query: string): { readonly matches: boolean };\n}\n\n/** Options of {@link createBrowserClock}. */\nexport interface BrowserClockOptions {\n /** The global to use. Default `globalThis`. */\n readonly host?: BrowserHost;\n /** Frame interval when the host has no requestAnimationFrame. Default 1000/60. */\n readonly fallbackFrameInterval?: number;\n}\n\n/**\n * A {@link ClockPort} on requestAnimationFrame, performance.now and\n * setTimeout. Without requestAnimationFrame (a worker, a server) frames come\n * from setTimeout at `fallbackFrameInterval`; without performance, time comes from\n * Date.now.\n */\nexport function createBrowserClock(options: BrowserClockOptions = {}): ClockPort {\n const host = options.host ?? (globalThis as unknown as BrowserHost);\n const fallbackFrameInterval = options.fallbackFrameInterval ?? 1000 / 60;\n const performance = host.performance;\n const now = performance !== undefined ? () => performance.now() : () => Date.now();\n\n // Timer handles are numbers in browsers and objects in Node; the port\n // promises numbers, so keep our own.\n let nextTimer = 1;\n const timers = new Map<number, unknown>();\n\n const setTimer = (callback: () => void, ms: number): number => {\n const id = nextTimer++;\n timers.set(\n id,\n host.setTimeout(() => {\n timers.delete(id);\n callback();\n }, Math.max(0, ms)),\n );\n return id;\n };\n\n const clearTimer = (id: number): void => {\n const handle = timers.get(id);\n if (handle === undefined) return;\n timers.delete(id);\n host.clearTimeout(handle);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `raf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const raf = host.requestAnimationFrame;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `caf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const caf = host.cancelAnimationFrame;\n if (raf !== undefined && caf !== undefined) {\n return {\n now,\n requestFrame: (callback) => raf.call(host, () => callback()),\n cancelFrame: (handle) => caf.call(host, handle),\n setTimer,\n clearTimer,\n };\n }\n return {\n now,\n requestFrame: (callback) => setTimer(callback, fallbackFrameInterval),\n cancelFrame: clearTimer,\n setTimer,\n clearTimer,\n };\n}\n\n/**\n * The user's reduced-motion preference as a function, for a motion value's\n * `reducedMotion` option. It reads the media query on each call, so a change\n * in the system setting applies to the next target and the next frame.\n * Without matchMedia it always returns `false`.\n */\nexport function prefersReducedMotion(host: BrowserHost = globalThis as unknown as BrowserHost): () => boolean {\n const query = host.matchMedia?.(\"(prefers-reduced-motion: reduce)\");\n return () => query?.matches ?? false;\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"../layout\";\n\n/**\n * The style properties the layout motion writes, as strings (a DOM node's `style` has them all). Structural: the\n * library needs no DOM types.\n */\nexport interface StyleLike {\n left: string;\n top: string;\n width: string;\n height: string;\n transform: string;\n opacity: string;\n clipPath: string;\n visibility: string;\n}\n\n/** Something with a writable {@link StyleLike} `style`: a DOM node. */\nexport interface Styled {\n readonly style: StyleLike;\n}\n\n/**\n * The nodes of a drawn box: `node` is laid out at the box and moved to the drawn rect; `frame` (background, border,\n * shadow) is drawn at the drawn size; `content` is clipped to it. With no `frame` and `content`, `node` itself is\n * clipped (its content laid out at the box, never stretched).\n */\nexport interface BoxNodes {\n readonly node: Styled;\n readonly frame?: Styled;\n readonly content?: Styled;\n}\n\n/** Lay `node` out at `box`: its position and size, in its offset parent's coordinates. */\nexport function layOutBox(node: Styled, box: Rect): void {\n const s = node.style;\n s.left = `${box.x}px`;\n s.top = `${box.y}px`;\n s.width = `${box.width}px`;\n s.height = `${box.height}px`;\n}\n\n/**\n * Draw one frame of a box laid out by {@link layOutBox}: one transform (the move to the drawn rect, and the uniform\n * appearance about its center), the frame at the drawn size, the content clipped (reveal); hidden when gone.\n */\nexport function drawBox(nodes: BoxNodes, frame: DrawFrame): void {\n const { reveal: r, pop } = frame;\n const cx = frame.drawn.width / 2;\n const cy = frame.drawn.height / 2;\n const s = nodes.node.style;\n s.transform =\n pop.scale === 1 ? `translate(${r.dx}px, ${r.dy}px)` : `translate(${r.dx}px, ${r.dy}px) translate(${cx}px, ${cy}px) scale(${pop.scale}) translate(${-cx}px, ${-cy}px)`;\n s.opacity = pop.opacity === 1 ? \"\" : String(pop.opacity);\n if (nodes.frame) {\n nodes.frame.style.width = `${r.width}px`;\n nodes.frame.style.height = `${r.height}px`;\n }\n const clipped = nodes.content ?? (nodes.frame ? null : nodes.node);\n if (clipped) clipped.style.clipPath = r.clipRight || r.clipBottom ? `inset(0 ${r.clipRight}px ${r.clipBottom}px 0)` : \"\";\n // All the way gone: out of sight and out of the way of the pointer.\n s.visibility = frame.gone ? \"hidden\" : \"\";\n}\n\n/** A {@link Drawable} for DOM nodes: {@link layOutBox} on a new box, {@link drawBox} on every frame. */\nexport function domDrawable(nodes: BoxNodes): Drawable {\n return {\n layOut: (box) => layOutBox(nodes.node, box),\n draw: (frame) => drawBox(nodes, frame),\n };\n}\n","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"../layout\";\n\n/** A rect as a DOM rect reports it (`getBoundingClientRect()`): left, top, width, height. */\nexport interface RectLike {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Anything that can say where it is drawn: a DOM node, or a test's stand-in. */\nexport interface Measurable {\n getBoundingClientRect(): RectLike;\n}\n\n/** A {@link RectLike} as a {@link Rect}. */\nexport const rectOf = (r: RectLike): Rect => ({ x: r.left, y: r.top, width: r.width, height: r.height });\n\n/** One member of a {@link flip}: an item, the node it draws, and where it goes once the DOM has changed. */\nexport interface FlipEntry {\n readonly item: LayoutItem;\n readonly node: Measurable;\n /**\n * Once the DOM has changed: the old rect (as measured before, in page coordinates) in the item's own coordinates\n * now, and its new place there.\n */\n readonly place: (before: Rect) => { readonly from: Rect; readonly to: Rect };\n}\n\n/**\n * FLIP for DOM groups, on settle: record where each node is drawn (first), change the DOM (`change`: move nodes to\n * other parents, reorder them), then each item is drawn at its old rect and settles to its new place (last, invert,\n * play). No transform tween: a settle from the rect it was drawn at, so it never jumps or overshoots, and its size\n * changes through reveal.\n */\nexport function flip(entries: readonly FlipEntry[], change: () => void): void {\n const before = entries.map((e) => rectOf(e.node.getBoundingClientRect()));\n change();\n entries.forEach((e, i) => {\n const { from, to } = e.place(before[i]!);\n e.item.glideFrom(from, to);\n });\n}\n","import type { TimerSource } from \"../clock\";\nimport { createPagedSwipe, PAGED_SWIPE_DEFAULTS, wheelDelta, type Machine, type PagedSwipeConfig, type PagedSwipeInput, type PagedSwipeState } from \"../gestures\";\n\n/**\n * Put on an element whose content keeps its own gestures (a map, a carousel, a slider): a swipe that starts on it\n * never pages. Empty for both axes, or `\"x\"` / `\"y\"` for one.\n */\nexport const SWIPE_KEEP_ATTRIBUTE = \"data-swipe-keep\";\n\n/**\n * Kept on every element a {@link pagedSwipeOn} runs on: the ways it can page, per input, space-separated. A finger's\n * are `x+`, `x-`, `y+`, `y-` (the scroll direction a swipe there has: a finger moving left is `x+`); a wheel run's\n * carry a `w` before them (`wx+`). Another swipe further out reads it the way it reads a scroller that can still\n * scroll, for the input in hand, so the nearest one that can take that gesture does. It lives in the DOM, not in\n * module memory, so two copies of this module in one page still see each other.\n */\nexport const SWIPE_PAGES_ATTRIBUTE = \"data-swipe-pages\";\n\n/** The px at the viewport's edges (along the swipe) where the system takes swipes: a finger that starts there never pages. */\nexport const SWIPE_EDGE_ZONE_PX = 24;\n\n/**\n * ms a finger's lift waits before it ends the swipe: the scroll events of the frame the finger lifted in arrive after\n * the lift, and a swipe during which something scrolled must not commit. Two frames at 60 Hz.\n */\nexport const SWIPE_LIFT_WAIT_MS = 34;\n\n/** A DOM listener as `addEventListener` takes it. Typed `any` so a real element or window (lib.dom) can be passed. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- lib.dom's listeners take each event's own type; this shape must accept them all\ntype SwipeListener = (event: any) => void;\n\n/** An element as the driver uses it (typed by shape, so the package builds without lib.dom). */\nexport interface SwipeElement {\n readonly parentElement: SwipeElement | null;\n readonly scrollLeft: number;\n readonly scrollTop: number;\n readonly scrollWidth: number;\n readonly scrollHeight: number;\n readonly clientWidth: number;\n readonly clientHeight: number;\n getAttribute(name: string): string | null;\n setAttribute(name: string, value: string): void;\n removeAttribute(name: string): void;\n contains(other: unknown): boolean;\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener): void;\n}\n\n/** The global the driver reads: the viewport, computed styles, and the document-wide scroll events. */\nexport interface SwipeHost {\n readonly innerWidth: number;\n readonly innerHeight: number;\n getComputedStyle(element: SwipeElement): { readonly overflowX: string; readonly overflowY: string; readonly direction: string };\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean; readonly capture?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener, options?: { readonly capture?: boolean }): void;\n}\n\ninterface TouchPoint {\n readonly identifier: number;\n readonly clientX: number;\n readonly clientY: number;\n}\ninterface TouchLike {\n readonly target: unknown;\n readonly touches: { readonly length: number };\n readonly changedTouches: { readonly length: number; readonly [index: number]: TouchPoint | undefined };\n}\ninterface WheelLike {\n readonly target: unknown;\n readonly deltaX: number;\n readonly deltaY: number;\n readonly deltaMode: number;\n readonly ctrlKey: boolean;\n readonly metaKey: boolean;\n readonly altKey: boolean;\n readonly shiftKey: boolean;\n readonly cancelable?: boolean;\n preventDefault(): void;\n}\ninterface ScrollLike {\n readonly target: unknown;\n}\n\n/** Options of {@link pagedSwipeOn}. */\nexport interface PagedSwipeOnOptions {\n /** The machine's clock: its `now()` stamps every sample. */\n readonly clock: TimerSource;\n readonly config?: Partial<PagedSwipeConfig>;\n /** A finger swipes. Default true. */\n readonly touch?: boolean;\n /** A trackpad's two-finger scroll (a wheel run) swipes. Default false. */\n readonly wheel?: boolean;\n /** Default {@link SWIPE_EDGE_ZONE_PX}. */\n readonly edgeZone?: number;\n /** Default `globalThis`. */\n readonly host?: SwipeHost;\n}\n\n/** What {@link pagedSwipeOn} returns: the running machine (send it `context`, `block`, `settled`), and the way out. */\nexport interface PagedSwipeOn {\n readonly swipe: Machine<PagedSwipeState, PagedSwipeInput>;\n dispose(): void;\n}\n\nconst SCROLLABLE: ReadonlySet<string> = new Set([\"auto\", \"scroll\", \"overlay\"]);\nconst EPSILON = 1;\n\n/** Whether one element can still scroll along `axis` towards `direction` (1: right / down), right-to-left included. */\nexport function canScrollFurther(element: SwipeElement, axis: \"x\" | \"y\", direction: 1 | -1, host: SwipeHost): boolean {\n const style = host.getComputedStyle(element);\n if (axis === \"y\") {\n if (!SCROLLABLE.has(style.overflowY)) return false;\n const max = element.scrollHeight - element.clientHeight;\n if (max <= EPSILON) return false;\n return direction === 1 ? element.scrollTop < max - EPSILON : element.scrollTop > EPSILON;\n }\n if (!SCROLLABLE.has(style.overflowX)) return false;\n const max = element.scrollWidth - element.clientWidth;\n if (max <= EPSILON) return false;\n const left = element.scrollLeft;\n if (style.direction === \"rtl\") return direction === 1 ? left < -EPSILON : left > -max + EPSILON;\n return direction === 1 ? left < max - EPSILON : left > EPSILON;\n}\n\nconst isElement = (node: unknown): node is SwipeElement =>\n typeof node === \"object\" && node !== null && typeof (node as { getAttribute?: unknown }).getAttribute === \"function\";\n\n/** The element an event target stands for (a text node's parent). */\nfunction elementOf(target: unknown): SwipeElement | null {\n if (isElement(target)) return target;\n const parent = typeof target === \"object\" && target !== null ? (target as { parentElement?: unknown }).parentElement : null;\n return isElement(parent) ? parent : null;\n}\n\n/** The way a swipe pages, for one input, as {@link SWIPE_PAGES_ATTRIBUTE} writes it. */\nconst token = (input: \"touch\" | \"wheel\", axis: \"x\" | \"y\", direction: 1 | -1): string => `${input === \"wheel\" ? \"w\" : \"\"}${axis}${direction === 1 ? \"+\" : \"-\"}`;\n\n/**\n * A paged swipe on an element: the machine ({@link createPagedSwipe}) and the DOM that feeds it.\n *\n * - **The nearest thing that way takes the gesture.** From the touched element out to this one, the first of: a\n * scroller that can still scroll that way, or another paged swipe ({@link SWIPE_PAGES_ATTRIBUTE}) with a page that\n * way for the same input, takes it; this swipe then doesn't arm. One with `band` takes every finger's swipe along its\n * axis.\n * - **Claimed starts (a finger only):** a finger that goes down within `edgeZone` of the viewport's edges along the\n * swipe (where the system takes swipes: back, the home bar), or on an element marked {@link SWIPE_KEEP_ATTRIBUTE},\n * never pages. A wheel run ignores both.\n * - **Scrolls:** a scroll inside this element, or of the page, while or just before a finger swipes is sent as\n * `scrolled` (the machine's rest rule). A lift ends the swipe {@link SWIPE_LIFT_WAIT_MS} later, so the scroll events\n * of its last frame still count.\n * - A second finger, or the browser taking the touch, cancels. A cancel that has nothing to animate back (progress 0)\n * ends at once; any other settle waits for the host's `settled`.\n * - Touch listeners are passive; the wheel listener is passive except while a wheel run is tracking, when it holds the\n * page still (`preventDefault`).\n *\n * The page size is the element's client extent along the swipe. The host sends `context` (which pages there are),\n * `block` (a drag owns the pointer), and `settled` when its page transition is done.\n */\nexport function pagedSwipeOn(element: SwipeElement, options: PagedSwipeOnOptions): PagedSwipeOn {\n const config: PagedSwipeConfig = { ...PAGED_SWIPE_DEFAULTS, ...options.config };\n const axis = config.along;\n const host: SwipeHost = options.host ?? (globalThis as unknown as SwipeHost);\n const edgeZone = options.edgeZone ?? SWIPE_EDGE_ZONE_PX;\n const touchOn = options.touch !== false;\n const wheelOn = options.wheel === true;\n const swipe = createPagedSwipe({ clock: options.clock, config });\n const now = (): number => options.clock.now();\n // An element with no layout yet (0) gives no size: the context's or the config's is used.\n const size = (): number | undefined => {\n const extent = axis === \"y\" ? element.clientHeight : element.clientWidth;\n return extent > 0 ? extent : undefined;\n };\n\n /** Whether something between `target` and this element (or this element as a scroller) goes that way first. */\n const nearerGoes = (target: unknown, direction: 1 | -1, input: \"touch\" | \"wheel\"): boolean => {\n const wanted = token(input, axis, direction);\n for (let node = elementOf(target); node !== null; node = node.parentElement) {\n if (canScrollFurther(node, axis, direction, host)) return true;\n if (node === element) return false;\n const pages = node.getAttribute(SWIPE_PAGES_ATTRIBUTE);\n if (pages !== null && pages.split(\" \").includes(wanted)) return true;\n }\n return false;\n };\n\n /** Whether content on the way from `target` to this element keeps its gestures on this axis. */\n const kept = (target: unknown): boolean => {\n for (let node = elementOf(target); node !== null && node !== element; node = node.parentElement) {\n const keep = node.getAttribute(SWIPE_KEEP_ATTRIBUTE);\n if (keep !== null && (keep === \"\" || keep === axis)) return true;\n }\n return false;\n };\n\n const inEdgeZone = (point: TouchPoint): boolean => {\n const at = axis === \"y\" ? point.clientY : point.clientX;\n const extent = axis === \"y\" ? host.innerHeight : host.innerWidth;\n return edgeZone > 0 && (at < edgeZone || at > extent - edgeZone);\n };\n\n // The ways this swipe pages, per input, kept on its element for swipes further out.\n let shownPages: string | null = null;\n const showPages = (state: PagedSwipeState): void => {\n const ways: string[] = [];\n // Blocked (a drag owns the pointer), it pages nowhere: a swipe further out must not yield to it.\n const open = !state.context.blocked;\n const wrapsAny = open && config.wrap && (state.context.hasPrev || state.context.hasNext);\n const next = open && (wrapsAny || state.context.hasNext);\n const prev = open && (wrapsAny || state.context.hasPrev);\n const band = open && config.band === true;\n // A finger's band takes every swipe along the axis; a wheel run never arms towards nothing.\n if (touchOn && (band || next)) ways.push(token(\"touch\", axis, 1));\n if (touchOn && (band || prev)) ways.push(token(\"touch\", axis, -1));\n if (wheelOn && next) ways.push(token(\"wheel\", axis, 1));\n if (wheelOn && prev) ways.push(token(\"wheel\", axis, -1));\n const shown = ways.join(\" \");\n if (shown === shownPages) return;\n shownPages = shown;\n element.setAttribute(SWIPE_PAGES_ATTRIBUTE, shown);\n };\n showPages(swipe.peek());\n\n let touch: { readonly id: number; readonly target: unknown; readonly x: number; readonly y: number } | null = null;\n const tracked = (event: TouchLike): TouchPoint | null => {\n if (touch === null) return null;\n for (let index = 0; index < event.changedTouches.length; index += 1) {\n const point = event.changedTouches[index];\n if (point !== undefined && point.identifier === touch.id) return point;\n }\n return null;\n };\n const cancelTouch = (): void => {\n if (touch === null) return;\n touch = null;\n swipe.send({ type: \"cancel\" });\n };\n // A lift waits SWIPE_LIFT_WAIT_MS, stamped with its own time, so the scrolls of its last frame are seen first.\n let lift: { readonly t: number; readonly timer: number } | null = null;\n const endLift = (): void => {\n if (lift === null) return;\n const { t, timer } = lift;\n lift = null;\n options.clock.clearTimer(timer);\n swipe.send({ type: \"touch-end\", t });\n };\n\n const onTouchStart = (event: TouchLike): void => {\n // A new finger before the last lift was judged: judge it now.\n endLift();\n if (event.touches.length > 1) {\n // A second finger: a pinch, not a swipe.\n cancelTouch();\n return;\n }\n const point = event.changedTouches[0];\n if (point === undefined) return;\n touch = { id: point.identifier, target: event.target, x: point.clientX, y: point.clientY };\n swipe.send({ type: \"touch-start\", x: point.clientX, y: point.clientY, t: now(), size: size(), claimed: inEdgeZone(point) || kept(event.target) });\n };\n const onTouchMove = (event: TouchLike): void => {\n if (touch === null) return;\n if (event.touches.length > 1) {\n cancelTouch();\n return;\n }\n const point = tracked(event);\n if (point === null) return;\n const state = swipe.peek();\n // The walk matters only at arming; a finger moving towards smaller x (or y) heads to `next`, scroll direction 1.\n const travel = axis === \"y\" ? touch.y - point.clientY : touch.x - point.clientX;\n const goes = state.phase === \"armed\" && travel !== 0 ? nearerGoes(touch.target, travel > 0 ? 1 : -1, \"touch\") : false;\n swipe.send({ type: \"touch-move\", x: point.clientX, y: point.clientY, t: now(), canScrollFurther: goes, size: size() });\n };\n const onTouchEnd = (event: TouchLike): void => {\n if (tracked(event) === null) return;\n touch = null;\n endLift();\n lift = { t: now(), timer: options.clock.setTimer(endLift, SWIPE_LIFT_WAIT_MS) };\n };\n const onTouchCancel = (event: TouchLike): void => {\n if (tracked(event) !== null) cancelTouch();\n };\n const onScroll = (event: ScrollLike): void => {\n // A scroll inside this swipe, or of the page itself (its target is the document, not an element).\n if (isElement(event.target) && !element.contains(event.target)) return;\n swipe.send({ type: \"scrolled\", t: now() });\n };\n\n let wheelPassive = true;\n const onWheel = (event: WheelLike): void => {\n const delta = wheelDelta(event.deltaX, event.deltaY, event.deltaMode === 1 || event.deltaMode === 2 ? event.deltaMode : 0);\n const main = axis === \"y\" ? delta.y : delta.x;\n const before = swipe.peek();\n // `preventDefault` only works on a non-passive registration: the one this sample arrived on.\n const holdable = !wheelPassive;\n const goes = main !== 0 && (before.phase === \"idle\" || before.phase === \"armed\") ? nearerGoes(event.target, main > 0 ? 1 : -1, \"wheel\") : false;\n const after = swipe.send({\n type: \"wheel\",\n dx: delta.x,\n dy: delta.y,\n t: now(),\n modifiers: { ctrl: event.ctrlKey, meta: event.metaKey, alt: event.altKey, shift: event.shiftKey },\n canScrollFurther: goes,\n size: size(),\n });\n if (holdable && after.phase === \"tracking\" && after.input === \"wheel\" && event.cancelable !== false) event.preventDefault();\n };\n const attachWheel = (passive: boolean): void => {\n element.removeEventListener(\"wheel\", onWheel);\n element.addEventListener(\"wheel\", onWheel, { passive });\n wheelPassive = passive;\n };\n\n const unsubscribe = swipe.subscribe((next, previous) => {\n if (next.context !== previous.context) showPages(next);\n // A cancel with nothing drawn away from rest has nothing to animate back: it ends at once.\n if (next.phase === \"settling\" && previous.phase !== \"settling\" && next.outcome === \"cancel\" && next.progress === 0) swipe.send({ type: \"settled\" });\n // Non-passive only while a wheel run tracks, so page scrolling never waits on this listener.\n const holding = next.phase === \"tracking\" && next.input === \"wheel\";\n if (wheelOn && holding === wheelPassive) attachWheel(!holding);\n });\n\n if (touchOn) {\n element.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n element.addEventListener(\"touchmove\", onTouchMove, { passive: true });\n element.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n element.addEventListener(\"touchcancel\", onTouchCancel, { passive: true });\n host.addEventListener(\"scroll\", onScroll, { passive: true, capture: true });\n }\n if (wheelOn) attachWheel(true);\n\n let disposed = false;\n return {\n swipe,\n dispose: (): void => {\n if (disposed) return;\n disposed = true;\n if (lift !== null) options.clock.clearTimer(lift.timer);\n lift = null;\n unsubscribe();\n if (touchOn) {\n element.removeEventListener(\"touchstart\", onTouchStart);\n element.removeEventListener(\"touchmove\", onTouchMove);\n element.removeEventListener(\"touchend\", onTouchEnd);\n element.removeEventListener(\"touchcancel\", onTouchCancel);\n host.removeEventListener(\"scroll\", onScroll, { capture: true });\n }\n if (wheelOn) element.removeEventListener(\"wheel\", onWheel);\n element.removeAttribute(SWIPE_PAGES_ATTRIBUTE);\n swipe.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;AA8BO,SAAS,mBAAmB,UAA+B,CAAC,GAAc;AAC/E,QAAM,OAAO,QAAQ,QAAS;AAC9B,QAAM,wBAAwB,QAAQ,yBAAyB,MAAO;AACtE,QAAM,cAAc,KAAK;AACzB,QAAM,MAAM,gBAAgB,SAAY,MAAM,YAAY,IAAI,IAAI,MAAM,KAAK,IAAI;AAIjF,MAAI,YAAY;AAChB,QAAM,SAAS,oBAAI,IAAqB;AAExC,QAAM,WAAW,C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