@n-uf/motion 26.11.53 → 26.11.54
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 +77 -0
- package/README.md +22 -29
- package/dist/browser.d.ts +79 -3
- package/dist/browser.js +49 -3
- package/dist/browser.js.map +1 -1
- package/dist/chunk-4XGH5367.js +379 -0
- package/dist/chunk-4XGH5367.js.map +1 -0
- package/dist/{chunk-SIAZRWYD.js → chunk-ALYH6YQK.js} +4 -7
- package/dist/chunk-ALYH6YQK.js.map +1 -0
- package/dist/{chunk-BVPVUJ42.js → chunk-G5EJSZ3B.js} +77 -30
- package/dist/chunk-G5EJSZ3B.js.map +1 -0
- package/dist/chunk-IT2FMZOM.js +989 -0
- package/dist/chunk-IT2FMZOM.js.map +1 -0
- package/dist/{chunk-V7DEXKBZ.js → chunk-NI7JLDWZ.js} +35 -8
- package/dist/chunk-NI7JLDWZ.js.map +1 -0
- package/dist/{chunk-7EAAKM6U.js → chunk-QMGPJ2FG.js} +37 -89
- package/dist/chunk-QMGPJ2FG.js.map +1 -0
- package/dist/chunk-RWDYRT3H.js +14 -0
- package/dist/chunk-RWDYRT3H.js.map +1 -0
- package/dist/clock.d.ts +40 -7
- package/dist/clock.js +3 -1
- package/dist/double-click-DBfbiP2U.d.ts +39 -0
- package/dist/drag.d.ts +155 -190
- package/dist/drag.js +24 -912
- package/dist/drag.js.map +1 -1
- package/dist/{frame-loop-C88dc9xw.d.ts → frame-loop-f0V4b464.d.ts} +11 -11
- package/dist/gestures.d.ts +40 -74
- package/dist/gestures.js +8 -7
- package/dist/index.d.ts +10 -6
- package/dist/index.js +60 -10
- package/dist/layout.d.ts +9 -233
- package/dist/layout.js +7 -427
- package/dist/layout.js.map +1 -1
- package/dist/motion-sElR1A_c.d.ts +163 -0
- package/dist/reveal-Dg5fqoWS.d.ts +51 -0
- package/dist/{reveal-C-ewJfFn.d.ts → settle-7C9xxbFg.d.ts} +7 -57
- package/dist/values.d.ts +15 -7
- package/dist/values.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-7EAAKM6U.js.map +0 -1
- package/dist/chunk-BVPVUJ42.js.map +0 -1
- package/dist/chunk-IJSIYH2D.js +0 -7
- package/dist/chunk-IJSIYH2D.js.map +0 -1
- package/dist/chunk-SIAZRWYD.js.map +0 -1
- package/dist/chunk-V7DEXKBZ.js.map +0 -1
- package/dist/double-click-jtUSNuHL.d.ts +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/values/easing.ts","../src/values/spring.ts","../src/values/tween.ts","../src/values/motion-value.ts"],"sourcesContent":["/** Maps progress in [0, 1] to eased progress (0 at 0, 1 at 1). */\nexport type Easing = (progress: number) => number;\n\n/** No easing. */\nexport const linear: Easing = (t) => t;\n\nconst EPSILON = 1e-7;\n\n/**\n * The CSS `cubic-bezier(x1, y1, x2, y2)` curve as a function, solved\n * numerically (Newton steps, then bisection). `x1` and `x2` must be in [0, 1].\n */\nexport function cubicBezier(x1: number, y1: number, x2: number, y2: number): Easing {\n if (!(x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1)) {\n throw new RangeError(`cubicBezier: x1 and x2 must be in [0, 1], got ${x1} and ${x2}`);\n }\n if (x1 === y1 && x2 === y2) return linear;\n const cx = 3 * x1;\n const bx = 3 * (x2 - x1) - cx;\n const ax = 1 - cx - bx;\n const cy = 3 * y1;\n const by = 3 * (y2 - y1) - cy;\n const ay = 1 - cy - by;\n const sampleX = (t: number): number => ((ax * t + bx) * t + cx) * t;\n const sampleY = (t: number): number => ((ay * t + by) * t + cy) * t;\n const slopeX = (t: number): number => (3 * ax * t + 2 * bx) * t + cx;\n const solveX = (x: number): number => {\n let t = x;\n for (let i = 0; i < 8; i++) {\n const error = sampleX(t) - x;\n if (Math.abs(error) < EPSILON) return t;\n const slope = slopeX(t);\n if (Math.abs(slope) < 1e-6) break;\n t -= error / slope;\n }\n let low = 0;\n let high = 1;\n t = x;\n for (let i = 0; i < 40; i++) {\n const value = sampleX(t);\n if (Math.abs(value - x) < EPSILON) return t;\n if (x > value) low = t;\n else high = t;\n t = (low + high) / 2;\n }\n return t;\n };\n return (progress) => (progress <= 0 ? 0 : progress >= 1 ? 1 : sampleY(solveX(progress)));\n}\n\n/** CSS `ease`. */\nexport const ease: Easing = /* @__PURE__ */ cubicBezier(0.25, 0.1, 0.25, 1);\n/** CSS `ease-in`. */\nexport const easeIn: Easing = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);\n/** CSS `ease-out`. */\nexport const easeOut: Easing = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);\n/** CSS `ease-in-out`. */\nexport const easeInOut: Easing = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);\n/** Cubic ease-out: fast start, gentle stop. The tween default. */\nexport const easeOutCubic: Easing = (t) => 1 - (1 - t) ** 3;\n/** Cubic ease-in-out. */\nexport const easeInOutCubic: Easing = (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2);\n","import type { Animatable, Widen } from \"../shapes\";\nimport { writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\n\n/**\n * Spring settings. Time is in milliseconds everywhere in the API; the physics\n * runs in seconds, so velocity is in units per second.\n */\nexport interface SpringConfig {\n /** Spring constant k. Higher is snappier. Default 300. */\n readonly stiffness?: number;\n /** Damping coefficient c. When set it wins over `dampingRatio`. */\n readonly damping?: number;\n /**\n * Damping as a fraction of critical damping: 1 is critical (the fastest\n * approach with no overshoot), below 1 overshoots and rings, above 1 is\n * sluggish. Default 1.\n */\n readonly dampingRatio?: number;\n /** Mass m. Default 1. */\n readonly mass?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n /** Speed, in units per second, that counts as stopped. Default 1 (tuned for pixels). */\n readonly restSpeed?: number;\n}\n\n/** A {@link SpringConfig} with every field resolved. */\nexport interface SpringParams {\n readonly stiffness: number;\n readonly damping: number;\n readonly dampingRatio: number;\n readonly mass: number;\n readonly restDelta: number;\n readonly restSpeed: number;\n}\n\n/** Defaults of {@link SpringConfig}: critically damped. */\nexport const SPRING_DEFAULTS: SpringParams = {\n stiffness: 300,\n damping: 2 * Math.sqrt(300),\n dampingRatio: 1,\n mass: 1,\n restDelta: 0.1,\n restSpeed: 1,\n};\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`spring: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\n/** Resolve a {@link SpringConfig} over the defaults. Throws on a non-positive field. */\nexport function resolveSpring(config: SpringConfig = {}): SpringParams {\n const stiffness = positive(\"stiffness\", config.stiffness ?? SPRING_DEFAULTS.stiffness);\n const mass = positive(\"mass\", config.mass ?? SPRING_DEFAULTS.mass);\n const critical = 2 * Math.sqrt(stiffness * mass);\n const damping = positive(\n config.damping !== undefined ? \"damping\" : \"dampingRatio\",\n config.damping ?? (config.dampingRatio ?? SPRING_DEFAULTS.dampingRatio) * critical,\n );\n return {\n stiffness,\n damping,\n dampingRatio: damping / critical,\n mass,\n restDelta: positive(\"restDelta\", config.restDelta ?? SPRING_DEFAULTS.restDelta),\n restSpeed: positive(\"restSpeed\", config.restSpeed ?? SPRING_DEFAULTS.restSpeed),\n };\n}\n\nconst UNDERDAMPED = 0;\nconst CRITICAL = 1;\nconst OVERDAMPED = 2;\n\n/** The closed-form solution's constants for one set of params. */\ninterface Solver {\n readonly mode: typeof UNDERDAMPED | typeof CRITICAL | typeof OVERDAMPED;\n readonly omega: number;\n readonly decay: number;\n readonly omegaD: number;\n readonly r1: number;\n readonly r2: number;\n}\n\nfunction solverFor(params: SpringParams): Solver {\n const omega = Math.sqrt(params.stiffness / params.mass);\n const zeta = params.dampingRatio;\n if (Math.abs(zeta - 1) < 1e-6) return { mode: CRITICAL, omega, decay: omega, omegaD: 0, r1: 0, r2: 0 };\n if (zeta < 1) {\n return { mode: UNDERDAMPED, omega, decay: zeta * omega, omegaD: omega * Math.sqrt(1 - zeta * zeta), r1: 0, r2: 0 };\n }\n const root = Math.sqrt(zeta * zeta - 1);\n return { mode: OVERDAMPED, omega, decay: 0, omegaD: 0, r1: -omega * (zeta - root), r2: -omega * (zeta + root) };\n}\n\n/**\n * Advance one component exactly: displacement `d0` from the target and\n * velocity `v0` (per second) after `t` seconds. Writes into out[0], out[1].\n * Exact for any `t`, so the curve doesn't depend on the frame rate.\n */\nfunction advance(solver: Solver, d0: number, v0: number, t: number, out: Float64Array): void {\n if (solver.mode === CRITICAL) {\n criticalStep(solver.omega, Math.exp(-solver.omega * t), d0, v0, t, out);\n } else if (solver.mode === UNDERDAMPED) {\n const a = solver.decay;\n const wd = solver.omegaD;\n const e = Math.exp(-a * t);\n const cos = Math.cos(wd * t);\n const sin = Math.sin(wd * t);\n out[0] = e * (d0 * cos + ((v0 + a * d0) / wd) * sin);\n out[1] = e * (v0 * cos - ((a * v0 + solver.omega * solver.omega * d0) / wd) * sin);\n } else {\n const { r1, r2 } = solver;\n const c2 = (v0 - r1 * d0) / (r2 - r1);\n const c1 = d0 - c2;\n const e1 = Math.exp(r1 * t);\n const e2 = Math.exp(r2 * t);\n out[0] = c1 * e1 + c2 * e2;\n out[1] = c1 * r1 * e1 + c2 * r2 * e2;\n }\n}\n\n/** A scalar spring's position and velocity (units per second). */\nexport interface SpringState {\n readonly value: number;\n readonly velocity: number;\n}\n\n/**\n * One pure spring step for a scalar: where `state` is after `dt` ms heading for\n * `target`. Doesn't settle or snap; {@link createSpring} does that.\n */\nexport function springStep(state: SpringState, target: number, params: SpringParams, dt: number): SpringState {\n const out = new Float64Array(2);\n advance(solverFor(params), state.value - target, state.velocity, dt / 1000, out);\n return { value: target + out[0]!, velocity: out[1]! };\n}\n\n/** A spring over any {@link Animatable} shape, stepped by hand or by `motionValue`. */\nexport interface Spring<T> extends Animator<T> {\n /** The resolved settings. */\n readonly params: SpringParams;\n /** Set the velocity in units per second (a gesture's release velocity). */\n setVelocity(velocity: T): void;\n /** Change settings mid-flight; position and velocity carry on. */\n configure(config: SpringConfig): void;\n}\n\nclass SpringAnimator extends ComponentAnimator implements Spring<Animatable> {\n config: SpringConfig;\n params: SpringParams;\n solver: Solver;\n\n constructor(initial: Animatable, config: SpringConfig) {\n super(initial, \"spring\");\n this.config = config;\n this.params = resolveSpring(config);\n this.solver = solverFor(this.params);\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n // Position and velocity stay as they are: a retarget carries the motion on.\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n this.updateSettled();\n }\n\n configure(config: SpringConfig): void {\n this.config = { ...this.config, ...config };\n this.params = resolveSpring(this.config);\n this.solver = solverFor(this.params);\n }\n\n protected begin(): void {}\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n advance(this.solver, d0, v0, t, out);\n }\n\n protected rests(_i: number, d: number, v: number): boolean {\n return !(Math.abs(d) > this.params.restDelta || Math.abs(v) > this.params.restSpeed);\n }\n}\n\n/**\n * A spring starting at rest on `initial`. `initial` fixes the shape: a\n * number, a vector (array), a point `{ x, y }` or a rect `{ x, y, width,\n * height }`; targets and velocities must have the same shape.\n */\nexport function createSpring<T extends Animatable>(initial: T, config: SpringConfig = {}): Spring<Widen<T>> {\n return new SpringAnimator(initial, config) as unknown as Spring<Widen<T>>;\n}\n","import type { Animatable, Layout, Widen } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { easeOutCubic, type Easing } from \"./easing\";\n\n/** Tween settings. */\nexport interface TweenConfig {\n /** Length of a run in ms. Default 250. 0 jumps to the target on the next step. */\n readonly duration?: number;\n /** Easing of the run. Default {@link easeOutCubic}. */\n readonly easing?: Easing;\n}\n\n/** A tween over any {@link Animatable} shape. */\nexport interface Tween<T> extends Animator<T> {\n /** Run progress in [0, 1]. */\n readonly progress: number;\n /** Change duration or easing; applies from the next target. */\n configure(config: TweenConfig): void;\n}\n\nclass TweenAnimator implements Tween<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly from: Float64Array;\n readonly goal: Float64Array;\n duration: number;\n easing: Easing;\n elapsed = 0;\n settled = true;\n cachedValue: Animatable | null = null;\n\n constructor(initial: Animatable, config: TweenConfig) {\n this.layout = layoutOf(initial);\n const size = this.layout.size;\n this.x = new Float64Array(size);\n this.from = new Float64Array(size);\n this.goal = new Float64Array(size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.from);\n writeComponents(initial, this.goal);\n this.duration = 250;\n this.easing = easeOutCubic;\n this.configure(config);\n }\n\n get value(): Animatable {\n if (this.cachedValue === null) this.cachedValue = makeValue(this.layout, this.x);\n return this.cachedValue;\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n get progress(): number {\n if (this.settled) return 1;\n return this.duration <= 0 ? 0 : Math.min(1, this.elapsed / this.duration);\n }\n\n /** The eased curve's slope at the current progress, as units per second. */\n get velocity(): Animatable {\n const out = new Float64Array(this.layout.size);\n if (!this.settled && this.duration > 0) {\n const p = this.progress;\n const h = 1e-3;\n const lo = Math.max(0, p - h);\n const hi = Math.min(1, p + h);\n const slope = (this.easing(hi) - this.easing(lo)) / (hi - lo);\n const perSecond = (slope / this.duration) * 1000;\n for (let i = 0; i < out.length; i++) out[i] = (this.goal[i]! - this.from[i]!) * perSecond;\n }\n return makeValue(this.layout, out);\n }\n\n configure(config: TweenConfig): void {\n if (config.duration !== undefined) {\n if (!(config.duration >= 0) || !Number.isFinite(config.duration)) {\n throw new RangeError(`tween: duration must be a finite number >= 0, got ${config.duration}`);\n }\n this.duration = config.duration;\n }\n if (config.easing !== undefined) this.easing = config.easing;\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`tween: ${what} has a different shape than the tween's value`);\n }\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n // A new run starts from wherever the value is now (no jump).\n this.from.set(this.x);\n this.elapsed = 0;\n this.settled = true;\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i]) {\n this.settled = false;\n break;\n }\n }\n }\n\n /** A tween's run is its duration and easing: a velocity set by hand changes nothing. */\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n }\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.from);\n writeComponents(value, this.goal);\n this.cachedValue = null;\n this.settled = true;\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.from.set(this.goal);\n this.cachedValue = null;\n this.settled = true;\n }\n\n step(dt: number): boolean {\n if (this.settled) return false;\n this.elapsed += Math.max(0, dt);\n const p = this.duration <= 0 ? 1 : Math.min(1, this.elapsed / this.duration);\n if (p >= 1) {\n this.snap();\n return false;\n }\n const eased = this.easing(p);\n for (let i = 0; i < this.x.length; i++) {\n this.x[i] = this.from[i]! + (this.goal[i]! - this.from[i]!) * eased;\n }\n this.cachedValue = null;\n return true;\n }\n}\n\n/**\n * A tween starting at rest on `initial` (same shapes as `createSpring`).\n * Velocity doesn't carry over a retarget: a new target starts a new run from\n * the current value. Use a spring where motion must stay continuous.\n */\nexport function createTween<T extends Animatable>(initial: T, config: TweenConfig = {}): Tween<Widen<T>> {\n return new TweenAnimator(initial, config) as unknown as Tween<Widen<T>>;\n}\n","import type { FrameInfo, FrameLoop, Phase } from \"../clock/frame-loop\";\nimport type { Animatable, Widen } from \"../shapes\";\nimport { shapeEquals } from \"../shapes\";\nimport { batch, effect, signal, untracked, type ReadonlySignal, type Signal } from \"../signals/signals\";\nimport type { Animator } from \"./animator\";\nimport { createSettle, type Settle, type SettleConfig } from \"./settle\";\nimport { createSpring, type Spring, type SpringConfig } from \"./spring\";\nimport { createTween, type Tween, type TweenConfig } from \"./tween\";\n\n/** Options of {@link motionValue}. */\nexport interface MotionOptions {\n /**\n * The frame phase that steps the value. Default `\"layout\"`: it steps after\n * that phase's one-shot tasks, so a target set in input, update or layout\n * moves the value in the same frame, and `write` sees the new value.\n */\n readonly phase?: Phase;\n /**\n * The reduced-motion switch: while it is (or returns) `true`, every new\n * target is reached at once, and a value in flight snaps on its next frame.\n * A function is read on each `set` and each frame, so it can read a signal\n * or a media query.\n */\n readonly reducedMotion?: boolean | (() => boolean);\n}\n\n/** Options of {@link MotionValue.set}. */\nexport interface SetOptions<T> {\n /** Start with this velocity (units per second), e.g. a gesture's release velocity. Springs and settles (a settle caps it toward the target); tweens ignore it. */\n readonly velocity?: T;\n}\n\n/**\n * An animated value on a frame loop. Reading `value` inside a computed or an\n * effect tracks it; it changes once per frame while moving and the loop goes\n * idle when it settles.\n */\nexport interface MotionValue<T, A extends Animator<unknown> = Animator<T>> extends ReadonlySignal<T> {\n /** Where the value is heading. */\n readonly target: T;\n /** The current velocity, units per second. */\n readonly velocity: T;\n /** Whether it is moving (reactive). */\n readonly moving: boolean;\n /** The spring, settle or tween underneath. Change it through this value (`jump`, not the animator's `jumpTo`), so the signal and the loop follow. */\n readonly animator: A;\n /** Head for `target`; a spring keeps its velocity, a settle launches from where it is drawn, a tween restarts. */\n set(target: T, options?: SetOptions<T>): void;\n /** Put the value at `value` at once, at rest. */\n jump(value: T): void;\n /** Finish now: put the value on its target, at rest. */\n snap(): void;\n /**\n * Keep heading for whatever `source` returns. `source` is tracked like an\n * effect, and re-read in this value's phase at most once per frame. Returns\n * a stop function.\n */\n follow(source: () => T): () => void;\n /**\n * Call `listener` each time the value comes to rest: on the frame it\n * settles, or at once when `set` (under reduced motion), `snap` or `jump`\n * leaves it at rest. Returns an unsubscribe function.\n */\n onSettle(listener: (value: T) => void): () => void;\n /**\n * Call `listener` after each change of the value (once per frame while it moves, and when `set`, `snap` or `jump`\n * moves it), with the new value; not at once, and not for a write that leaves it the same. The plain way to follow a\n * value: no signals needed. Returns an unsubscribe function.\n */\n subscribe(listener: (value: T) => void): () => void;\n /** Stop stepping, drop listeners and follows. */\n dispose(): void;\n}\n\nclass Motion<T> implements MotionValue<T> {\n readonly loop: FrameLoop;\n readonly animator: Animator<T>;\n readonly phase: Phase;\n readonly reduced: () => boolean;\n readonly current: Signal<T>;\n readonly movingSignal: Signal<boolean>;\n readonly listeners = new Set<(value: T) => void>();\n readonly changes = new Set<(value: T) => void>();\n readonly follows = new Set<() => void>();\n stop: (() => void) | null = null;\n disposed = false;\n\n constructor(loop: FrameLoop, animator: Animator<T>, options: MotionOptions) {\n this.loop = loop;\n this.animator = animator;\n this.phase = options.phase ?? \"layout\";\n const reducedMotion = options.reducedMotion ?? false;\n this.reduced = typeof reducedMotion === \"function\" ? reducedMotion : () => reducedMotion;\n this.current = signal(animator.value, {\n equals: shapeEquals as (a: T, b: T) => boolean,\n });\n this.movingSignal = signal(false);\n if (!animator.settled) this.start();\n }\n\n get value(): T {\n return this.current.value;\n }\n\n peek(): T {\n return this.current.peek();\n }\n\n get target(): T {\n return this.animator.target;\n }\n\n get velocity(): T {\n return this.animator.velocity;\n }\n\n get moving(): boolean {\n return this.movingSignal.value;\n }\n\n /** Tell the change listeners when the value is no longer `before`. */\n changed(before: T): void {\n const now = this.current.peek();\n if (now !== before) for (const listener of Array.from(this.changes)) listener(now);\n }\n\n /** Publish the animator's value, and tell the change listeners. */\n publish(): void {\n const before = this.current.peek();\n this.current.value = this.animator.value;\n this.changed(before);\n }\n\n readonly tick = (frame: FrameInfo): boolean => {\n if (this.reduced()) this.animator.snap();\n else this.animator.step(frame.delta);\n if (!this.animator.settled) {\n this.publish();\n return true;\n }\n this.stop = null;\n this.rest();\n return false;\n };\n\n start(): void {\n if (this.stop !== null || this.disposed) return;\n this.stop = this.loop.repeat(this.phase, this.tick);\n this.movingSignal.value = true;\n }\n\n halt(): void {\n if (this.stop === null) return;\n this.stop();\n this.stop = null;\n }\n\n /** Publish the resting value and tell the listeners. */\n rest(): void {\n const before = this.current.peek();\n batch(() => {\n this.current.value = this.animator.value;\n this.movingSignal.value = false;\n });\n this.changed(before);\n const value = this.animator.value;\n for (const listener of Array.from(this.listeners)) listener(value);\n }\n\n set(target: T, options?: SetOptions<T>): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.setTarget(target);\n if (options?.velocity !== undefined) this.animator.setVelocity(options.velocity);\n if (this.reduced()) this.animator.snap();\n if (this.animator.settled) {\n this.halt();\n this.rest();\n } else {\n this.start();\n }\n });\n }\n\n jump(value: T): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.jumpTo(value);\n this.halt();\n this.rest();\n });\n }\n\n snap(): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.snap();\n this.halt();\n this.rest();\n });\n }\n\n follow(source: () => T): () => void {\n if (this.disposed) return () => {};\n const dispose = effect(\n () => {\n const target = source();\n this.set(target);\n },\n { schedule: this.loop.scheduler(this.phase) },\n );\n const stop = (): void => {\n dispose();\n this.follows.delete(stop);\n };\n this.follows.add(stop);\n return stop;\n }\n\n onSettle(listener: (value: T) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n subscribe(listener: (value: T) => void): () => void {\n if (this.disposed) return () => {};\n this.changes.add(listener);\n return () => {\n this.changes.delete(listener);\n };\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.halt();\n for (const stop of Array.from(this.follows)) stop();\n this.listeners.clear();\n this.changes.clear();\n this.movingSignal.value = false;\n }\n}\n\n/** The value type an animator moves. */\nexport type AnimatorValue<A> = A extends Animator<infer T> ? T : never;\n\n/** Step `animator` on `loop` while it moves, and expose it as a signal. */\nexport function motionValue<A extends Animator<unknown>>(\n loop: FrameLoop,\n animator: A,\n options: MotionOptions = {},\n): MotionValue<AnimatorValue<A>, A> {\n return new Motion(loop, animator, options) as unknown as MotionValue<AnimatorValue<A>, A>;\n}\n\n/** A spring-driven {@link MotionValue}: `createSpring` plus `motionValue`. */\nexport function springValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SpringConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Spring<Widen<T>>> {\n return motionValue(loop, createSpring(initial, options), options) as MotionValue<Widen<T>, Spring<Widen<T>>>;\n}\n\n/**\n * A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The\n * one curve for things moving to a new place (see {@link Settle}). To hold it\n * to a pointer, `jump` it on each move; the next `set` launches from there.\n */\nexport function settleValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SettleConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Settle<Widen<T>>> {\n return motionValue(loop, createSettle(initial, options), options) as MotionValue<Widen<T>, Settle<Widen<T>>>;\n}\n\n/** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */\nexport function tweenValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: TweenConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Tween<Widen<T>>> {\n return motionValue(loop, createTween(initial, options), options) as MotionValue<Widen<T>, Tween<Widen<T>>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIO,IAAM,SAAiB,CAAC,MAAM;AAErC,IAAM,UAAU;AAMT,SAAS,YAAY,IAAY,IAAY,IAAY,IAAoB;AAClF,MAAI,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,IAAI;AAC/C,UAAM,IAAI,WAAW,iDAAiD,EAAE,QAAQ,EAAE,EAAE;AAAA,EACtF;AACA,MAAI,OAAO,MAAM,OAAO,GAAI,QAAO;AACnC,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,UAAU,CAAC,QAAwB,KAAK,IAAI,MAAM,IAAI,MAAM;AAClE,QAAM,UAAU,CAAC,QAAwB,KAA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EACF;AAAA,EAEA,UAAU,UAA0C;AAClD,QAAI,KAAK,SAAU,QAAO,MAAM;AAAA,IAAC;AACjC,SAAK,QAAQ,IAAI,QAAQ;AACzB,WAAO,MAAM;AACX,WAAK,QAAQ,OAAO,QAAQ;AAAA,IAC9B;AAAA,EACF;AAAA,EAEA,UAAgB;AACd,QAAI,KAAK,SAAU;AACnB,SAAK,WAAW;AAChB,SAAK,KAAK;AACV,eAAW,QAAQ,MAAM,KAAK,KAAK,OAAO,EAAG,MAAK;AAClD,SAAK,UAAU,MAAM;AACrB,SAAK,QAAQ,MAAM;AACnB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;AAMO,SAAS,YACd,MACA,UACA,UAAyB,CAAC,GACQ;AAClC,SAAO,IAAI,OAAO,MAAM,UAAU,OAAO;AAC3C;AAGO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAOO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAGO,SAAS,WACd,MACA,SACA,UAAuC,CAAC,GACA;AACxC,SAAO,YAAY,MAAM,YAAY,SAAS,OAAO,GAAG,OAAO;AACjE;","names":[]}
|
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
signal
|
|
3
3
|
} from "./chunk-OOKRBVMB.js";
|
|
4
4
|
import {
|
|
5
|
-
DOUBLE_CLICK
|
|
6
|
-
|
|
5
|
+
DOUBLE_CLICK,
|
|
6
|
+
isHeld
|
|
7
|
+
} from "./chunk-RWDYRT3H.js";
|
|
7
8
|
|
|
8
9
|
// src/gestures/types.ts
|
|
9
10
|
var NO_MODIFIERS = Object.freeze({ shift: false, alt: false, meta: false, ctrl: false });
|
|
@@ -20,11 +21,9 @@ function resolveDragModifier(config, platform) {
|
|
|
20
21
|
if (config === null) return null;
|
|
21
22
|
return config ?? defaultDragModifier(platform);
|
|
22
23
|
}
|
|
23
|
-
function isHeld(modifiers, key) {
|
|
24
|
-
return key !== null && modifiers[key];
|
|
25
|
-
}
|
|
26
24
|
function platformButton(press, platform, dragModifier) {
|
|
27
|
-
|
|
25
|
+
const ctrlDrags = dragModifier === "ctrl" || dragModifier === "mod";
|
|
26
|
+
return platform === "mac" && press.kind === "mouse" && press.button === 0 && press.modifiers.ctrl && !ctrlDrags ? 2 : press.button;
|
|
28
27
|
}
|
|
29
28
|
function modHeld(modifiers, platform) {
|
|
30
29
|
return platform === "mac" ? modifiers.meta : modifiers.ctrl;
|
|
@@ -32,7 +31,7 @@ function modHeld(modifiers, platform) {
|
|
|
32
31
|
|
|
33
32
|
// src/gestures/wheel.ts
|
|
34
33
|
var WHEEL_DEFAULTS = Object.freeze({ lineHeight: 40, pageHeight: 800, zoomSensitivity: 300 });
|
|
35
|
-
function
|
|
34
|
+
function wheelDelta(deltaX, deltaY, deltaMode, opts = WHEEL_DEFAULTS) {
|
|
36
35
|
const k = deltaMode === 1 ? opts.lineHeight : deltaMode === 2 ? opts.pageHeight : 1;
|
|
37
36
|
return { x: finite(deltaX) * k, y: finite(deltaY) * k };
|
|
38
37
|
}
|
|
@@ -87,9 +86,10 @@ function createRecognizer(options, emit) {
|
|
|
87
86
|
const pinchCfg = { ...RECOGNIZER_DEFAULTS.pinch, ...options.pinch };
|
|
88
87
|
const wheelCfg = { ...WHEEL_DEFAULTS, ...options.wheel };
|
|
89
88
|
const timers = options.timers;
|
|
90
|
-
const
|
|
89
|
+
const stale = options.stale ?? 1e3;
|
|
91
90
|
let dragModifier = options.dragModifier ?? null;
|
|
92
91
|
const platform = options.platform ?? "other";
|
|
92
|
+
const toCanvas = options.toCanvas ?? ((p) => ({ x: p.x, y: p.y }));
|
|
93
93
|
let press = null;
|
|
94
94
|
let pinch = null;
|
|
95
95
|
const touches = /* @__PURE__ */ new Map();
|
|
@@ -102,7 +102,7 @@ function createRecognizer(options, emit) {
|
|
|
102
102
|
const screen = finitePoint(e.screen);
|
|
103
103
|
return {
|
|
104
104
|
screen,
|
|
105
|
-
canvas:
|
|
105
|
+
canvas: toCanvas(screen),
|
|
106
106
|
kind: kindOf(e.pointerType),
|
|
107
107
|
buttons: e.buttons,
|
|
108
108
|
modifiers: toModifiers(e.modifiers),
|
|
@@ -154,7 +154,7 @@ function createRecognizer(options, emit) {
|
|
|
154
154
|
phase,
|
|
155
155
|
source,
|
|
156
156
|
kind,
|
|
157
|
-
center: { screen: center, canvas:
|
|
157
|
+
center: { screen: center, canvas: toCanvas(center) },
|
|
158
158
|
scale,
|
|
159
159
|
pan,
|
|
160
160
|
modifiers,
|
|
@@ -202,7 +202,7 @@ function createRecognizer(options, emit) {
|
|
|
202
202
|
if (p) {
|
|
203
203
|
const same = p.origin.pointerId === e.pointerId;
|
|
204
204
|
const mixed = kind !== "touch" || p.origin.kind !== "touch";
|
|
205
|
-
if (same || mixed && e.time - p.last.time >
|
|
205
|
+
if (same || mixed && e.time - p.last.time > stale) cancelPress("missed-up");
|
|
206
206
|
}
|
|
207
207
|
if (kind !== "touch") return;
|
|
208
208
|
if (touches.has(e.pointerId)) {
|
|
@@ -211,7 +211,7 @@ function createRecognizer(options, emit) {
|
|
|
211
211
|
}
|
|
212
212
|
for (const [id, t] of touches) {
|
|
213
213
|
const busy = press?.origin.pointerId === id || !!pinch?.ids.includes(id);
|
|
214
|
-
if (!busy && e.time - t.time >
|
|
214
|
+
if (!busy && e.time - t.time > stale) touches.delete(id);
|
|
215
215
|
}
|
|
216
216
|
if (touches.size === 0) touchLocked = false;
|
|
217
217
|
};
|
|
@@ -239,14 +239,11 @@ function createRecognizer(options, emit) {
|
|
|
239
239
|
if (touches.size > 2) return;
|
|
240
240
|
}
|
|
241
241
|
if (press || pinch) return;
|
|
242
|
-
const candidate = isHeld(pointer.modifiers, dragModifier) ? pointer.button === 0 ? "move" : pointer.button === 2 ? "resize" : null : null;
|
|
243
242
|
const p = {
|
|
244
243
|
origin: pointer,
|
|
245
244
|
last: pointer,
|
|
246
245
|
dragging: false,
|
|
247
246
|
longPressed: false,
|
|
248
|
-
candidate,
|
|
249
|
-
modifierDrag: null,
|
|
250
247
|
timer: void 0
|
|
251
248
|
};
|
|
252
249
|
press = p;
|
|
@@ -258,7 +255,7 @@ function createRecognizer(options, emit) {
|
|
|
258
255
|
emit({ type: "longPress", pointer: p.last, origin: p.origin });
|
|
259
256
|
}, longPressMs);
|
|
260
257
|
}
|
|
261
|
-
emit({ type: "press", pointer
|
|
258
|
+
emit({ type: "press", pointer });
|
|
262
259
|
};
|
|
263
260
|
const onMove = (e) => {
|
|
264
261
|
const kind = kindOf(e.pointerType);
|
|
@@ -287,8 +284,7 @@ function createRecognizer(options, emit) {
|
|
|
287
284
|
if (dist(pointer.screen, p.origin.screen) <= thresholds[p.origin.kind]) return;
|
|
288
285
|
p.dragging = true;
|
|
289
286
|
clearTimer(p);
|
|
290
|
-
|
|
291
|
-
emit({ type: "dragStart", pointer, origin: p.origin, modifierDrag: p.modifierDrag });
|
|
287
|
+
emit({ type: "dragStart", pointer, origin: p.origin });
|
|
292
288
|
return;
|
|
293
289
|
}
|
|
294
290
|
emit({ type: "move", pointer, origin: p.origin });
|
|
@@ -328,8 +324,8 @@ function createRecognizer(options, emit) {
|
|
|
328
324
|
const onWheel = (e) => {
|
|
329
325
|
const modifiers = toModifiers(e.modifiers);
|
|
330
326
|
const screen = finitePoint(e.screen);
|
|
331
|
-
const at = { screen, canvas:
|
|
332
|
-
const intent = classifyWheel(
|
|
327
|
+
const at = { screen, canvas: toCanvas(screen) };
|
|
328
|
+
const intent = classifyWheel(wheelDelta(e.deltaX, e.deltaY, e.deltaMode, wheelCfg), modifiers, wheelCfg);
|
|
333
329
|
if (intent.kind === "zoom") {
|
|
334
330
|
if (intent.factor !== 1) emit({ type: "zoom", factor: intent.factor, at, modifiers, time: e.time });
|
|
335
331
|
return;
|
|
@@ -417,52 +413,6 @@ function createRecognizer(options, emit) {
|
|
|
417
413
|
};
|
|
418
414
|
}
|
|
419
415
|
|
|
420
|
-
// src/gestures/coalescer.ts
|
|
421
|
-
function createFrameCoalescer(onFrame, frames, options = {}) {
|
|
422
|
-
const merge = options.merge;
|
|
423
|
-
let handle = null;
|
|
424
|
-
let sample;
|
|
425
|
-
let count = 0;
|
|
426
|
-
const deliver = () => {
|
|
427
|
-
const delivered = sample;
|
|
428
|
-
const folded = count;
|
|
429
|
-
sample = void 0;
|
|
430
|
-
count = 0;
|
|
431
|
-
onFrame(delivered, folded);
|
|
432
|
-
};
|
|
433
|
-
const onFrameDue = () => {
|
|
434
|
-
handle = null;
|
|
435
|
-
if (count > 0) deliver();
|
|
436
|
-
};
|
|
437
|
-
return {
|
|
438
|
-
schedule(next) {
|
|
439
|
-
sample = count > 0 && merge !== void 0 ? merge(sample, next) : next;
|
|
440
|
-
count++;
|
|
441
|
-
if (handle === null) handle = frames.requestFrame(onFrameDue);
|
|
442
|
-
},
|
|
443
|
-
flush() {
|
|
444
|
-
if (handle !== null) {
|
|
445
|
-
frames.cancelFrame(handle);
|
|
446
|
-
handle = null;
|
|
447
|
-
}
|
|
448
|
-
if (count === 0) return false;
|
|
449
|
-
deliver();
|
|
450
|
-
return true;
|
|
451
|
-
},
|
|
452
|
-
cancel() {
|
|
453
|
-
if (handle !== null) {
|
|
454
|
-
frames.cancelFrame(handle);
|
|
455
|
-
handle = null;
|
|
456
|
-
}
|
|
457
|
-
sample = void 0;
|
|
458
|
-
count = 0;
|
|
459
|
-
},
|
|
460
|
-
get pending() {
|
|
461
|
-
return count > 0;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
416
|
// src/gestures/machine.ts
|
|
467
417
|
function createMachine(options) {
|
|
468
418
|
const { reducer, clock, deadline } = options;
|
|
@@ -543,7 +493,7 @@ function createMachine(options) {
|
|
|
543
493
|
}
|
|
544
494
|
|
|
545
495
|
// src/gestures/dwell.ts
|
|
546
|
-
var DWELL_DEFAULTS = {
|
|
496
|
+
var DWELL_DEFAULTS = { dwell: 500 };
|
|
547
497
|
var DWELL_IDLE = { phase: "idle" };
|
|
548
498
|
function dwellReducer(state, event, config = DWELL_DEFAULTS) {
|
|
549
499
|
switch (event.type) {
|
|
@@ -555,7 +505,7 @@ function dwellReducer(state, event, config = DWELL_DEFAULTS) {
|
|
|
555
505
|
if (state.phase === "dwelling" && Object.is(state.key, event.key)) return state;
|
|
556
506
|
return { phase: "dwelling", key: event.key, since: event.t, payload: event.payload };
|
|
557
507
|
case "tick":
|
|
558
|
-
if (state.phase !== "dwelling" || event.t - state.since < config.
|
|
508
|
+
if (state.phase !== "dwelling" || event.t - state.since < config.dwell) return state;
|
|
559
509
|
return { phase: "fired", key: state.key, since: state.since, firedAt: event.t, payload: state.payload };
|
|
560
510
|
default:
|
|
561
511
|
return state;
|
|
@@ -563,7 +513,7 @@ function dwellReducer(state, event, config = DWELL_DEFAULTS) {
|
|
|
563
513
|
}
|
|
564
514
|
function dwellDeadline(state, config = DWELL_DEFAULTS) {
|
|
565
515
|
if (state.phase !== "dwelling") return null;
|
|
566
|
-
return { at: state.since + config.
|
|
516
|
+
return { at: state.since + config.dwell, event: (t) => ({ type: "tick", t }) };
|
|
567
517
|
}
|
|
568
518
|
function createDwellMachine(options) {
|
|
569
519
|
const config = { ...DWELL_DEFAULTS, ...options.config };
|
|
@@ -576,7 +526,7 @@ function createDwellMachine(options) {
|
|
|
576
526
|
}
|
|
577
527
|
|
|
578
528
|
// src/gestures/touch-press.ts
|
|
579
|
-
var TOUCH_PRESS_DEFAULTS = { lift: 6, scrollEscape: 10, scroll: "y",
|
|
529
|
+
var TOUCH_PRESS_DEFAULTS = { lift: 6, scrollEscape: 10, scroll: "y", hold: 220 };
|
|
580
530
|
var TOUCH_PRESS_IDLE = { phase: "idle" };
|
|
581
531
|
function touchPressReducer(state, event, config = TOUCH_PRESS_DEFAULTS) {
|
|
582
532
|
switch (event.type) {
|
|
@@ -585,7 +535,7 @@ function touchPressReducer(state, event, config = TOUCH_PRESS_DEFAULTS) {
|
|
|
585
535
|
case "press":
|
|
586
536
|
return state.phase === "idle" ? { phase: "pressed", from: { x: event.point.x, y: event.point.y }, since: event.t } : state;
|
|
587
537
|
case "tick":
|
|
588
|
-
if (state.phase !== "pressed" || event.t - state.since < config.
|
|
538
|
+
if (state.phase !== "pressed" || event.t - state.since < config.hold) return state;
|
|
589
539
|
return { phase: "lifted", from: state.from, at: state.from };
|
|
590
540
|
case "move": {
|
|
591
541
|
if (state.phase !== "pressed") return state;
|
|
@@ -603,7 +553,7 @@ function touchPressReducer(state, event, config = TOUCH_PRESS_DEFAULTS) {
|
|
|
603
553
|
}
|
|
604
554
|
function touchPressDeadline(state, config = TOUCH_PRESS_DEFAULTS) {
|
|
605
555
|
if (state.phase !== "pressed") return null;
|
|
606
|
-
return { at: state.since + config.
|
|
556
|
+
return { at: state.since + config.hold, event: (t) => ({ type: "tick", t }) };
|
|
607
557
|
}
|
|
608
558
|
function createTouchPress(options) {
|
|
609
559
|
const config = { ...TOUCH_PRESS_DEFAULTS, ...options.config };
|
|
@@ -617,11 +567,11 @@ function createTouchPress(options) {
|
|
|
617
567
|
|
|
618
568
|
// src/gestures/paged-swipe.ts
|
|
619
569
|
var PAGED_SWIPE_DEFAULTS = {
|
|
620
|
-
|
|
570
|
+
threshold: 24,
|
|
621
571
|
commitFraction: 0.35,
|
|
622
572
|
commitVelocity: 0.6,
|
|
623
|
-
|
|
624
|
-
|
|
573
|
+
idle: 120,
|
|
574
|
+
lockout: 350,
|
|
625
575
|
wrap: false,
|
|
626
576
|
size: 800,
|
|
627
577
|
modifier: null,
|
|
@@ -689,14 +639,14 @@ function pagedSwipeReducer(state, event, config = PAGED_SWIPE_DEFAULTS) {
|
|
|
689
639
|
case "idle": {
|
|
690
640
|
if (event.type === "wheel") {
|
|
691
641
|
if (state.context.blocked) return state;
|
|
692
|
-
const fresh = state.lastWheel === null || event.t - state.lastWheel >= config.
|
|
642
|
+
const fresh = state.lastWheel === null || event.t - state.lastWheel >= config.idle;
|
|
693
643
|
if (!fresh && state.claimed) return { ...state, lastWheel: event.t };
|
|
694
644
|
const main = y ? event.dy : event.dx;
|
|
695
645
|
const cross = y ? event.dx : event.dy;
|
|
696
646
|
const side = arming(state.context, main, cross, config, wheelGates(event, config));
|
|
697
647
|
const c = withSize(state.context, event.size);
|
|
698
648
|
if (side === null) return idle(c, event.t, true);
|
|
699
|
-
if (Math.abs(main) >= config.
|
|
649
|
+
if (Math.abs(main) >= config.threshold) return track(c, "wheel", { x: 0, y: 0 }, main, event.t, 0, sizeOf(c, event.size, config), config);
|
|
700
650
|
return { phase: "armed", context: c, input: "wheel", origin: { x: 0, y: 0 }, travel: main, cross, last: event.t, progress: 0, target: null };
|
|
701
651
|
}
|
|
702
652
|
if (event.type === "touch-start") {
|
|
@@ -715,20 +665,20 @@ function pagedSwipeReducer(state, event, config = PAGED_SWIPE_DEFAULTS) {
|
|
|
715
665
|
const travel = state.travel + main;
|
|
716
666
|
const crossTravel = state.cross + cross;
|
|
717
667
|
if (Math.abs(crossTravel) > Math.abs(travel) / 2) return idle(c, event.t, true);
|
|
718
|
-
if (Math.abs(travel) < config.
|
|
668
|
+
if (Math.abs(travel) < config.threshold) return { ...state, context: c, travel, cross: crossTravel, last: event.t };
|
|
719
669
|
return track(c, "wheel", state.origin, travel, event.t, towards(main, event.t - state.last, sideOf(travel)), sizeOf(c, event.size, config), config);
|
|
720
670
|
}
|
|
721
671
|
if (event.type === "touch-move") {
|
|
722
672
|
if (state.input !== "touch") return state;
|
|
723
673
|
const main = y ? state.origin.y - event.y : state.origin.x - event.x;
|
|
724
674
|
const cross = y ? event.x - state.origin.x : event.y - state.origin.y;
|
|
725
|
-
if (Math.hypot(main, cross) < config.
|
|
675
|
+
if (Math.hypot(main, cross) < config.threshold) return { ...state, last: event.t };
|
|
726
676
|
const side = arming(state.context, main, cross, config, { ctrl: false, modifierHeld: true, canScrollFurther: event.canScrollFurther ?? false });
|
|
727
677
|
if (side === null) return idle(state.context);
|
|
728
678
|
const c = withSize(state.context, event.size);
|
|
729
679
|
return track(c, "touch", state.origin, main, event.t, towards(main, event.t - state.last, side), sizeOf(c, event.size, config), config);
|
|
730
680
|
}
|
|
731
|
-
if (event.type === "tick") return state.input === "wheel" && event.t - state.last >= config.
|
|
681
|
+
if (event.type === "tick") return state.input === "wheel" && event.t - state.last >= config.idle ? idle(state.context) : state;
|
|
732
682
|
if (event.type === "touch-end") return state.input === "touch" ? idle(state.context) : state;
|
|
733
683
|
if (event.type === "touch-start") return { ...state, context: withSize(state.context, event.size), input: "touch", origin: { x: event.x, y: event.y }, travel: 0, cross: 0, last: event.t };
|
|
734
684
|
return state;
|
|
@@ -743,13 +693,13 @@ function pagedSwipeReducer(state, event, config = PAGED_SWIPE_DEFAULTS) {
|
|
|
743
693
|
const c = withSize(state.context, event.size);
|
|
744
694
|
return track(c, state.input, state.origin, travel, event.t, peak, sizeOf(c, event.size, config), config);
|
|
745
695
|
}
|
|
746
|
-
if (event.type === "tick") return state.input === "wheel" && event.t - state.last >= config.
|
|
696
|
+
if (event.type === "tick") return state.input === "wheel" && event.t - state.last >= config.idle ? end(state, event.t, config) : state;
|
|
747
697
|
if (event.type === "touch-end") return state.input === "touch" ? end(state, event.t, config) : state;
|
|
748
698
|
return state;
|
|
749
699
|
}
|
|
750
700
|
case "settling": {
|
|
751
701
|
if (event.type === "settled") {
|
|
752
|
-
if (state.outcome === "commit") return { phase: "lockout", context: state.context, until: state.ended + config.
|
|
702
|
+
if (state.outcome === "commit") return { phase: "lockout", context: state.context, until: state.ended + config.lockout, lastWheel: state.lastWheel, progress: 0, target: null };
|
|
753
703
|
return idle(state.context, state.lastWheel, false);
|
|
754
704
|
}
|
|
755
705
|
if (event.type === "wheel") return { ...state, lastWheel: event.t };
|
|
@@ -759,7 +709,7 @@ function pagedSwipeReducer(state, event, config = PAGED_SWIPE_DEFAULTS) {
|
|
|
759
709
|
if (event.type === "wheel") return event.t >= state.until ? idle(state.context, event.t, true) : { ...state, lastWheel: event.t };
|
|
760
710
|
if (event.type === "tick") {
|
|
761
711
|
if (event.t < state.until) return state;
|
|
762
|
-
return event.t - state.lastWheel < config.
|
|
712
|
+
return event.t - state.lastWheel < config.idle ? idle(state.context, state.lastWheel, true) : idle(state.context);
|
|
763
713
|
}
|
|
764
714
|
if (event.type === "touch-start") return pagedSwipeReducer(idle(state.context), event, config);
|
|
765
715
|
return state;
|
|
@@ -769,11 +719,11 @@ function pagedSwipeReducer(state, event, config = PAGED_SWIPE_DEFAULTS) {
|
|
|
769
719
|
}
|
|
770
720
|
}
|
|
771
721
|
function wheelGates(event, config) {
|
|
772
|
-
return { ctrl: event.modifiers.ctrl, modifierHeld: config.modifier === null || event.modifiers
|
|
722
|
+
return { ctrl: event.modifiers.ctrl, modifierHeld: config.modifier === null || isHeld(event.modifiers, config.modifier), canScrollFurther: event.canScrollFurther ?? false };
|
|
773
723
|
}
|
|
774
724
|
function pagedSwipeDeadline(state, config = PAGED_SWIPE_DEFAULTS) {
|
|
775
725
|
const tick = (t) => ({ type: "tick", t });
|
|
776
|
-
if ((state.phase === "armed" || state.phase === "tracking") && state.input === "wheel") return { at: state.last + config.
|
|
726
|
+
if ((state.phase === "armed" || state.phase === "tracking") && state.input === "wheel") return { at: state.last + config.idle, event: tick };
|
|
777
727
|
if (state.phase === "lockout") return { at: state.until, event: tick };
|
|
778
728
|
return null;
|
|
779
729
|
}
|
|
@@ -792,17 +742,15 @@ export {
|
|
|
792
742
|
toModifiers,
|
|
793
743
|
defaultDragModifier,
|
|
794
744
|
resolveDragModifier,
|
|
795
|
-
isHeld,
|
|
796
745
|
platformButton,
|
|
797
746
|
modHeld,
|
|
798
747
|
WHEEL_DEFAULTS,
|
|
799
|
-
|
|
748
|
+
wheelDelta,
|
|
800
749
|
classifyWheel,
|
|
801
750
|
WHEEL_PAN_DEFAULTS,
|
|
802
751
|
dampWheelPan,
|
|
803
752
|
RECOGNIZER_DEFAULTS,
|
|
804
753
|
createRecognizer,
|
|
805
|
-
createFrameCoalescer,
|
|
806
754
|
createMachine,
|
|
807
755
|
DWELL_DEFAULTS,
|
|
808
756
|
DWELL_IDLE,
|
|
@@ -822,4 +770,4 @@ export {
|
|
|
822
770
|
pagedSwipeDeadline,
|
|
823
771
|
createPagedSwipe
|
|
824
772
|
};
|
|
825
|
-
//# sourceMappingURL=chunk-
|
|
773
|
+
//# sourceMappingURL=chunk-QMGPJ2FG.js.map
|