@n-uf/motion 26.11.64 → 26.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shapes.ts","../src/values/step.ts","../src/values/settle.ts","../src/values/reveal.ts"],"sourcesContent":["/** A point or a 2D vector. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** An axis-aligned rectangle. */\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Any number of components. */\nexport type Vector = readonly number[];\n\n/** The value shapes springs and tweens move: plain numbers, nothing else. */\nexport type Animatable = number | Point | Rect | Vector;\n\n/** The shape type of an {@link Animatable}: literal numbers widen to `number`. */\nexport type Widen<T> = T extends number\n ? number\n : T extends Vector\n ? Vector\n : T extends Rect\n ? Rect\n : T extends Point\n ? Point\n : never;\n\nconst SCALAR = 0;\nconst VECTOR = 1;\nconst POINT = 2;\nconst RECT = 3;\n\n/** How a shape maps onto a flat list of numbers. Internal to values/. */\nexport interface Layout {\n readonly kind: typeof SCALAR | typeof VECTOR | typeof POINT | typeof RECT;\n readonly size: number;\n}\n\nconst SCALAR_LAYOUT: Layout = { kind: SCALAR, size: 1 };\nconst POINT_LAYOUT: Layout = { kind: POINT, size: 2 };\nconst RECT_LAYOUT: Layout = { kind: RECT, size: 4 };\n\nexport function layoutOf(value: Animatable): Layout {\n if (typeof value === \"number\") return SCALAR_LAYOUT;\n if (Array.isArray(value)) return { kind: VECTOR, size: value.length };\n if (\"width\" in value) return RECT_LAYOUT;\n return POINT_LAYOUT;\n}\n\nexport function sameLayout(a: Layout, b: Layout): boolean {\n return a.kind === b.kind && a.size === b.size;\n}\n\n/** Copy `value`'s components into `out`. */\nexport function writeComponents(value: Animatable, out: Float64Array): void {\n if (typeof value === \"number\") {\n out[0] = value;\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) out[i] = value[i]!;\n } else if (\"width\" in value) {\n out[0] = value.x;\n out[1] = value.y;\n out[2] = value.width;\n out[3] = value.height;\n } else {\n const point = value as Point;\n out[0] = point.x;\n out[1] = point.y;\n }\n}\n\n/** A fresh value of `layout`'s shape from `components`. */\nexport function makeValue(layout: Layout, components: Float64Array): Animatable {\n switch (layout.kind) {\n case SCALAR:\n return components[0]!;\n case POINT:\n return { x: components[0]!, y: components[1]! };\n case RECT:\n return { x: components[0]!, y: components[1]!, width: components[2]!, height: components[3]! };\n default:\n return Array.from(components);\n }\n}\n\n/** Component-wise equality of two values of the same shape. */\nexport function shapeEquals(a: Animatable, b: Animatable): boolean {\n if (typeof a === \"number\" || typeof b === \"number\") return a === b;\n if (Array.isArray(a) || Array.isArray(b)) {\n const u = a as Vector;\n const v = b as Vector;\n if (u.length !== v.length) return false;\n for (let i = 0; i < u.length; i++) if (u[i] !== v[i]) return false;\n return true;\n }\n const p = a as Partial<Rect>;\n const q = b as Partial<Rect>;\n return p.x === q.x && p.y === q.y && p.width === q.width && p.height === q.height;\n}\n","import type { Animatable, Layout } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\n\n/**\n * The exact critically damped step for one component, shared by the spring and the settle: displacement `d0` from the\n * target and velocity `v0` (per second) after `t` seconds, with `e` = e^(−w·t) worked out once per step. Writes into\n * out[0], out[1]: d(t) = e·(d0 + b·t), v(t) = e·(v0 − w·b·t), b = v0 + w·d0.\n */\nexport function criticalStep(w: number, e: number, d0: number, v0: number, t: number, out: Float64Array): void {\n const b = v0 + w * d0;\n out[0] = e * (d0 + b * t);\n out[1] = e * (v0 - w * b * t);\n}\n\n/**\n * What the spring and the settle share: a value of any {@link Animatable} shape kept as components (position, velocity\n * and target), its shape check, the rest test of a step, jump and snap. Each one adds only its own law: `begin` (what a\n * step works out once), `advance` (one component over `t` seconds) and `rests` (when a component counts as arrived).\n */\nexport abstract class ComponentAnimator implements Animator<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly v: Float64Array;\n readonly goal: Float64Array;\n readonly scratch = new Float64Array(2);\n settled = true;\n cachedValue: Animatable | null = null;\n /** How errors call it (\"spring\", \"settle\"). */\n private readonly name: string;\n\n constructor(initial: Animatable, name: string) {\n this.name = name;\n this.layout = layoutOf(initial);\n this.x = new Float64Array(this.layout.size);\n this.v = new Float64Array(this.layout.size);\n this.goal = new Float64Array(this.layout.size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.goal);\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 velocity(): Animatable {\n return makeValue(this.layout, this.v);\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`${this.name}: ${what} has a different shape than the ${this.name}'s value`);\n }\n }\n\n /** At rest exactly when on the target and not moving. */\n updateSettled(): void {\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i] || this.v[i] !== 0) {\n this.settled = false;\n return;\n }\n }\n this.settled = true;\n }\n\n abstract setTarget(target: Animatable): void;\n\n abstract setVelocity(velocity: Animatable): void;\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n /** Work out what every component's step of `t` seconds shares. */\n protected abstract begin(t: number): void;\n /** One component, `d0` from its target at `v0` per second, after `t` seconds: into out[0], out[1]. */\n protected abstract advance(d0: number, v0: number, t: number, out: Float64Array): void;\n /** Whether component `i`, now `d` from its target at `v` per second, counts as arrived. */\n protected abstract rests(i: number, d: number, v: number): boolean;\n\n step(dt: number): boolean {\n if (this.settled) return false;\n if (!(dt > 0)) return true;\n const t = dt / 1000;\n const { x, v, goal, scratch } = this;\n this.begin(t);\n let resting = true;\n for (let i = 0; i < x.length; i++) {\n this.advance(x[i]! - goal[i]!, v[i]!, t, scratch);\n x[i] = goal[i]! + scratch[0]!;\n v[i] = scratch[1]!;\n if (resting && !this.rests(i, scratch[0]!, scratch[1]!)) resting = false;\n }\n this.cachedValue = null;\n if (resting) this.snap();\n return !this.settled;\n }\n}\n","import type { Animatable, Widen } from \"../shapes\";\nimport { makeValue, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\n\n/**\n * Tempos for {@link createSettle}, in 1/s: a settle covers 90 % of the way in\n * ln(10)/omega seconds and is within 1 % in twice that.\n *\n * - `calm` 20: 90 % in 115 ms, done in 230 ms.\n * - `default` 25: 90 % in 92 ms, done in 184 ms.\n * - `quick` 37: 90 % in 62 ms, done in 124 ms (a fast Hyprland setup).\n */\nexport const SETTLE_TEMPO = { calm: 20, default: 25, quick: 37 } as const;\n\n/** The values a settle is kept between, per component, in the value's shape (see {@link SettleConfig.within}). */\nexport interface SettleRange<T> {\n readonly min: T;\n readonly max: T;\n}\n\n/**\n * Settings of {@link createSettle}. `T` is the value's shape (`SettleConfig<number>`, `SettleConfig<Rect>`); a plain\n * `SettleConfig` has no range, and passes to a settle of any shape.\n */\nexport interface SettleConfig<T = never> {\n /** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */\n readonly omega?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n /**\n * Limits how far a set velocity can carry the value: with the value and the target inside `min`…`max`, the value\n * never leaves. It does not move the value or the target; a target outside is still reached.\n *\n * A velocity set away from the target (`setVelocity`, or a value's `set(target, { velocity })`) makes the value go\n * on, stop and come back; with a range, that speed is lowered just enough for the value to stop before the bound\n * (to 0 when the value already stands at it, or the range has no width). A speed toward the target, a new target and\n * the rest are as without one. Per component; a side may be `-Infinity` or `Infinity` (open). `null` clears it.\n * Under reduced motion a value goes to its target at once, inside or not. Clearing the range later doesn't give back\n * a speed it lowered. A `min` above `max`, a side that is NaN, a `min` of `Infinity` or a `max` of `-Infinity`\n * throw a `RangeError`, and the settle is left as it was.\n */\n readonly within?: SettleRange<T> | null;\n}\n\n/**\n * The one curve for things that move to a new place: a window's rect between\n * layout targets, a drawer, a camera. Fast at the start, gentle at the end,\n * and it never passes its target.\n *\n * It is a critically damped spring (stiffness omega², damping 2·omega) with\n * one rule on its velocity, per component:\n *\n * - **Launch.** On a new target, each component gets the velocity\n * omega · distance toward it, from wherever it is drawn: standing still,\n * moving toward it, or moving away (it turns at once rather than drifting\n * further first). From there the spring follows `distance · e^(−omega·t)`\n * exactly: most of the move happens at once, the rest eases in.\n * - **Clamp.** That speed is also the most it may have toward the target, so a\n * velocity set by hand (`setVelocity`, a fling) toward the target is capped\n * there instead of shooting past.\n * - **Carry.** A velocity set by hand away from the target is kept, and the\n * value turns around; a critically damped spring turning around never\n * crosses the target either. With a range ({@link SettleConfig.within}) it\n * is lowered just enough for the value to stop before the bound on its side.\n * - **A velocity that is not a finite number** (NaN, ±Infinity, either way) is\n * taken as 0.\n *\n * So after a new target every component goes straight from where it is drawn\n * to the target and never past it: no overshoot on position, no wobble on\n * size, whatever the retargets. A new target starts from the drawn value,\n * never from the old start.\n *\n * Holding (a pointer owns the value): call `jumpTo(value)` on each move. The\n * value sits exactly there, at rest; the next `setTarget` launches from it.\n */\nexport interface Settle<T> extends Animator<T> {\n /** The tempo in 1/s. */\n readonly omega: number;\n /** The range in force ({@link SettleConfig.within}), or null. */\n readonly within: SettleRange<T> | null;\n /**\n * Set the velocity, in units per second (a gesture's release velocity in px per ms is `* 1000`); a component moving\n * toward the target is clamped as in the launch rule, one moving away is kept or, with a range, lowered.\n */\n setVelocity(velocity: T): void;\n /** Change the tempo, rest distance or range mid-flight; the value and velocity carry on, re-clamped and re-lowered. */\n configure(config: SettleConfig<T>): void;\n}\n\n/** Defaults of {@link SettleConfig}. */\nexport const SETTLE_DEFAULTS = { omega: SETTLE_TEMPO.default, restDelta: 0.1 } as const;\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`settle: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\n/** How far from its target a settle `a` (≥ 0) from it, moving away at `speed` (≥ 0), gets before it turns back. */\nfunction reach(a: number, speed: number, omega: number): number {\n // d(t) = (a + k·t)·e^(−omega·t), k = speed + omega·a, peaks at t* = speed / (omega·k).\n const k = speed + omega * a;\n return k > 0 ? (k / omega) * Math.exp(-speed / k) : a;\n}\n\n/**\n * The speed a settle `a` (≥ 0) from its target keeps when it moves away at `speed` (≥ 0) with `room` (≥ 0, Infinity:\n * none) between the target and the bound on that side: `speed` when its reach fits, 0 when it already stands at the\n * bound or past it, else the largest speed whose reach is at most `room` less a margin (so the sampled values stay\n * inside despite rounding), by bisection (the reach grows steadily with the speed).\n *\n * The margin, a billionth of the room, covers every rounding: the step's own error is a few float steps of the distance,\n * the room (bound − target) is exact when the two lie close and a half float step of the room otherwise, and the drawn\n * value, target + distance, can't pass target + room = the bound while the distance stays under the room, since float\n * addition keeps order.\n */\nfunction rangedSpeed(a: number, speed: number, room: number, omega: number): number {\n if (!(room < Infinity)) return speed;\n const inside = room - 1e-9 * room;\n if (a >= inside) return 0;\n if (reach(a, speed, omega) <= inside) return speed;\n // The reach grows with the distance too, so it is at least the reach from the target, speed / (omega·e): no speed\n // above omega·e·inside fits. Bisecting from there keeps a huge speed's answer as close as a small one's.\n let low = 0;\n let high = Math.min(speed, omega * Math.E * inside);\n for (let k = 0; k < 60; k += 1) {\n const mid = (low + high) / 2;\n if (reach(a, mid, omega) <= inside) low = mid;\n else high = mid;\n }\n return low;\n}\n\n/** A range's sides as components, checked: the error names what is wrong, and nothing is written on a throw. */\nfunction readRange(settle: SettleAnimator, range: SettleRange<Animatable>): { min: Float64Array; max: Float64Array } {\n settle.check(range.min, \"within's min\");\n settle.check(range.max, \"within's max\");\n const min = new Float64Array(settle.x.length);\n const max = new Float64Array(settle.x.length);\n writeComponents(range.min, min);\n writeComponents(range.max, max);\n for (let i = 0; i < min.length; i++) {\n const lo = min[i]!;\n const hi = max[i]!;\n if (Number.isNaN(lo) || Number.isNaN(hi) || lo > hi || lo === Infinity || hi === -Infinity) {\n throw new RangeError(`settle: within needs min <= max, each a number, min below Infinity and max above -Infinity; got ${lo} and ${hi}`);\n }\n }\n return { min, max };\n}\n\nclass SettleAnimator extends ComponentAnimator implements Settle<Animatable> {\n omega: number;\n restDelta: number;\n // One step's shared numbers (`begin`): e^(−omega·t) and the rest speed.\n private e = 1;\n private restSpeed = 0;\n private range: { min: Float64Array; max: Float64Array } | null = null;\n\n constructor(initial: Animatable, config: SettleConfig<Animatable>) {\n super(initial, \"settle\");\n this.omega = positive(\"omega\", config.omega ?? SETTLE_DEFAULTS.omega);\n this.restDelta = positive(\"restDelta\", config.restDelta ?? SETTLE_DEFAULTS.restDelta);\n if (config.within != null) this.range = readRange(this, config.within);\n }\n\n get within(): SettleRange<Animatable> | null {\n const range = this.range;\n return range === null ? null : { min: makeValue(this.layout, range.min), max: makeValue(this.layout, range.max) };\n }\n\n /** The launch/clamp/carry rule on component `i`: `launch` for a new target, else clamp or carry. */\n rule(i: number, launch: boolean): void {\n const d = this.x[i]! - this.goal[i]!;\n const limit = d === 0 ? 0 : -this.omega * d;\n if (launch) {\n this.v[i] = limit;\n return;\n }\n let v = this.v[i]!;\n if (!Number.isFinite(v)) this.v[i] = v = 0;\n if (v === 0) return;\n // Moving away from the target (d and v the same sign), or off it: carry, within the range if there is one.\n if (d === 0 || d * v > 0) {\n const range = this.range;\n if (range === null) return;\n const goal = this.goal[i]!;\n const bound = v > 0 ? range.max[i]! : range.min[i]!;\n const room = Math.max(0, v > 0 ? bound - goal : goal - bound);\n const kept = rangedSpeed(Math.abs(d), Math.abs(v), room, this.omega);\n // A plain 0 when lowered to nothing, never −0.\n this.v[i] = kept === 0 ? 0 : Math.sign(v) * kept;\n return;\n }\n // Moving toward it: no faster than a launch from here.\n if (Math.abs(v) > Math.abs(limit)) this.v[i] = limit;\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n for (let i = 0; i < this.x.length; i++) this.rule(i, true);\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n this.updateSettled();\n }\n\n configure(config: SettleConfig<Animatable>): void {\n // Everything is checked before anything changes.\n const range = config.within === undefined ? this.range : config.within === null ? null : readRange(this, config.within);\n const omega = config.omega === undefined ? this.omega : positive(\"omega\", config.omega);\n const restDelta = config.restDelta === undefined ? this.restDelta : positive(\"restDelta\", config.restDelta);\n this.omega = omega;\n this.restDelta = restDelta;\n this.range = range;\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n }\n\n protected begin(t: number): void {\n this.e = Math.exp(-this.omega * t);\n // At rest when every component is within restDelta and no faster than a launch from there would be.\n this.restSpeed = this.omega * this.restDelta * 1.000001;\n }\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n criticalStep(this.omega, this.e, d0, v0, t, out);\n }\n\n protected rests(i: number, d: number, v: number): boolean {\n // Within a few float steps of the goal counts as arrived too: a restDelta finer than that would never be met.\n const near = Math.max(this.restDelta, 4 * Number.EPSILON * Math.abs(this.goal[i]!));\n return !(Math.abs(d) > near || Math.abs(v) > Math.max(this.restSpeed, this.omega * near));\n }\n}\n\n/**\n * A settle starting at rest on `initial` (a number, a vector, a point or a\n * rect; targets, velocities and a range must have the same shape). See\n * {@link Settle}.\n */\nexport function createSettle<T extends Animatable>(initial: T, config: SettleConfig<Widen<T>> = {}): Settle<Widen<T>> {\n return new SettleAnimator(initial, config as SettleConfig<Animatable>) as unknown as Settle<Widen<T>>;\n}\n","import type { Rect } from \"../shapes\";\n\n/**\n * How to draw a window whose rect is gliding without stretching its content.\n *\n * The content is laid out once at the target size and never scaled. The\n * window's element sits at its target in the layout; to draw it at the\n * gliding rect:\n *\n * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;\n * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;\n * - clip the content by `clipRight` and `clipBottom` so it fits a frame\n * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).\n *\n * A window that shrinks shows a band of its own background closing in at the\n * right and bottom; one that grows reveals content already laid out at its\n * new size. Text is never stretched. One transform and one clip per frame, no\n * layout per frame.\n */\nexport interface RevealFrame {\n /** Move the element (laid out at the target) right by this much. */\n readonly dx: number;\n /** Move the element (laid out at the target) down by this much. */\n readonly dy: number;\n /** The frame's width: the drawn rect's. */\n readonly width: number;\n /** The frame's height: the drawn rect's. */\n readonly height: number;\n /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */\n readonly clipRight: number;\n /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */\n readonly clipBottom: number;\n}\n\n/** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */\nexport function reveal(drawn: Rect, target: Rect): RevealFrame {\n return {\n dx: drawn.x - target.x,\n dy: drawn.y - target.y,\n width: Math.max(0, drawn.width),\n height: Math.max(0, drawn.height),\n clipRight: Math.max(0, target.width - drawn.width),\n clipBottom: Math.max(0, target.height - drawn.height),\n };\n}\n\n/** A uniform pop-in (or pop-out, run backwards): scale about the center and opacity. */\nexport interface PopIn {\n /** Scale about the window's center: the same on both axes, so nothing is stretched. */\n readonly scale: number;\n readonly opacity: number;\n}\n\n/**\n * Opening and closing: the window grows from `from` of its size to full, about\n * its center, while fading in. `progress` runs 0 to 1 (take it from a settle\n * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for\n * pixels and would snap the last 10 %; or from a tween); closing runs it from\n * 1 to 0. Hyprland's default is `popin 87%`.\n */\nexport function popIn(progress: number, from = 0.87): PopIn {\n const p = Math.min(1, Math.max(0, progress));\n return { scale: from + (1 - from) * p, opacity: p };\n}\n"],"mappings":";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B;AAC7D,SAAO;AAAA,IACL,IAAI,MAAM,IAAI,OAAO;AAAA,IACrB,IAAI,MAAM,IAAI,OAAO;AAAA,IACrB,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK;AAAA,IAC9B,QAAQ,KAAK,IAAI,GAAG,MAAM,MAAM;AAAA,IAChC,WAAW,KAAK,IAAI,GAAG,OAAO,QAAQ,MAAM,KAAK;AAAA,IACjD,YAAY,KAAK,IAAI,GAAG,OAAO,SAAS,MAAM,MAAM;AAAA,EACtD;AACF;AAgBO,SAAS,MAAM,UAAkB,OAAO,MAAa;AAC1D,QAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,CAAC;AAC3C,SAAO,EAAE,OAAO,QAAQ,IAAI,QAAQ,GAAG,SAAS,EAAE;AACpD;","names":[]}
@@ -7,8 +7,18 @@ function isHeld(modifiers, key) {
7
7
  return key === "mod" ? !!(modifiers.meta || modifiers.ctrl) : !!modifiers[key];
8
8
  }
9
9
 
10
+ // src/samples.ts
11
+ var SAME_SAMPLE = 1;
12
+ function sampleOrder(newest, t) {
13
+ const dt = t - newest;
14
+ if (dt < 0) return "behind";
15
+ return dt < SAME_SAMPLE ? "same" : "next";
16
+ }
17
+
10
18
  export {
11
19
  DOUBLE_CLICK,
12
- isHeld
20
+ isHeld,
21
+ SAME_SAMPLE,
22
+ sampleOrder
13
23
  };
14
- //# sourceMappingURL=chunk-RWDYRT3H.js.map
24
+ //# sourceMappingURL=chunk-TJC6AXFM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/double-click.ts","../src/keys.ts","../src/samples.ts"],"sourcesContent":["/**\n * A double click: two presses within `ms` of each other (press to press) and `px` of the first. One value for the whole\n * package: the gesture recognizer's `clickCount` (`RECOGNIZER_DEFAULTS.multiClick`) and a grip's double-activate\n * (`createGripPress`) both default to it.\n */\nexport interface DoubleClick {\n readonly ms: number;\n readonly px: number;\n}\n\n/**\n * 500 ms and 5 px: the desktop systems' own default interval (browsers don't expose the user's setting). A host that has\n * the platform's count (a `mousedown`'s `detail`) can pass it to `createGripPress`'s `down` instead.\n */\nexport const DOUBLE_CLICK: DoubleClick = Object.freeze({ ms: 500, px: 5 });\n","/**\n * Modifier keys, the package's one shape for them: the gesture stream's pointers carry `Modifiers`, a drag's samples a\n * partial set of them, and both name a key by `ModifierKey`. Here at the root of `src`, so `./drag` reads them without\n * loading `./gestures`.\n */\n\n/** Pointer modifiers, ctrl included (the drag modifier may be \"ctrl\") */\nexport interface Modifiers {\n shift: boolean;\n alt: boolean;\n meta: boolean;\n ctrl: boolean;\n}\n\n/**\n * A modifier key, the package's one name for it (the recognizer's drag modifier, a drag's float and arm keys): a field\n * of {@link Modifiers}, or `\"mod\"`: ⌘ (meta) or Ctrl, either one held counts, so no platform is needed.\n */\nexport type ModifierKey = keyof Modifiers | \"mod\";\n\n/**\n * Whether `key` is held in `modifiers` (a pointer's, or the keys a drag sample carries; absent fields are not held).\n * `\"mod\"`: ⌘ (meta) or Ctrl, either one. Null: never.\n */\nexport function isHeld(modifiers: Partial<Modifiers> | undefined, key: ModifierKey | null): boolean {\n if (key === null || !modifiers) return false;\n return key === \"mod\" ? !!(modifiers.meta || modifiers.ctrl) : !!modifiers[key];\n}\n","/**\n * How pointer samples are read in time, shared by every estimate of a pointer's speed (the landing model's hand speed,\n * a gesture's release velocity). Internal: not exported from any entry.\n */\n\n/**\n * The shortest interval between two samples that is two samples, ms. A sample under it past the newest one held (a\n * release read a fraction of a millisecond after the last frame, or two timestamps of one frame) is the same sample\n * seen twice: its distance over so short a time says nothing about how fast the pointer moves.\n */\nexport const SAME_SAMPLE = 1;\n\n/**\n * How a sample stamped `t` stands to the newest one held, stamped `newest` (ms): the `next` sample (at least\n * {@link SAME_SAMPLE} past it), the `same` sample (under that past it), or `behind` it (stamped earlier; times are\n * expected never to go back, so one that does is an event's time read against a frame's, or a clock that stepped back).\n * A stamp that is not a number compares as `next`: callers that can get one leave it out first.\n */\nexport function sampleOrder(newest: number, t: number): \"next\" | \"same\" | \"behind\" {\n const dt = t - newest;\n if (dt < 0) return \"behind\";\n return dt < SAME_SAMPLE ? \"same\" : \"next\";\n}\n"],"mappings":";AAcO,IAAM,eAA4B,OAAO,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC;;;ACUlE,SAAS,OAAO,WAA2C,KAAkC;AAClG,MAAI,QAAQ,QAAQ,CAAC,UAAW,QAAO;AACvC,SAAO,QAAQ,QAAQ,CAAC,EAAE,UAAU,QAAQ,UAAU,QAAQ,CAAC,CAAC,UAAU,GAAG;AAC/E;;;ACjBO,IAAM,cAAc;AAQpB,SAAS,YAAY,QAAgB,GAAuC;AACjF,QAAM,KAAK,IAAI;AACf,MAAI,KAAK,EAAG,QAAO;AACnB,SAAO,KAAK,cAAc,SAAS;AACrC;","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  createSettle,
4
4
  popIn,
5
5
  reveal
6
- } from "./chunk-ALYH6YQK.js";
6
+ } from "./chunk-MTSGXDVI.js";
7
7
 
8
8
  // src/layout/motion.ts
9
9
  var same = (a, b) => Math.abs(a.x - b.x) < 0.01 && Math.abs(a.y - b.y) < 0.01 && Math.abs(a.width - b.width) < 0.01 && Math.abs(a.height - b.height) < 0.01;
@@ -380,4 +380,4 @@ export {
380
380
  MORPH_TEMPO,
381
381
  anchoredMorph
382
382
  };
383
- //# sourceMappingURL=chunk-5EMLVHP3.js.map
383
+ //# sourceMappingURL=chunk-ZVFIWSC4.js.map
package/dist/drag.js CHANGED
@@ -19,10 +19,10 @@ import {
19
19
  pickRank,
20
20
  previewPlan,
21
21
  targetAt
22
- } from "./chunk-B53X43GW.js";
22
+ } from "./chunk-F5FNGVQT.js";
23
23
  import {
24
24
  isHeld
25
- } from "./chunk-RWDYRT3H.js";
25
+ } from "./chunk-TJC6AXFM.js";
26
26
  export {
27
27
  DRAG_DEFAULTS,
28
28
  DRAG_PREVIEW_DEFAULT,
@@ -4,8 +4,8 @@ import { P as Point } from './shapes-EbQlwbCu.js';
4
4
  import { a as DoubleClick } from './double-click-jtUSNuHL.js';
5
5
  export { D as DOUBLE_CLICK } from './double-click-jtUSNuHL.js';
6
6
  import { C as ClockPort, T as TimerSource } from './port-CmlUctqx.js';
7
- import { M as Machine, D as Deadline } from './paged-swipe-CIzjr2DQ.js';
8
- export { a as MachineOptions, P as PAGED_SWIPE_DEFAULTS, b as PAGED_SWIPE_EMPTY_CONTEXT, c as PAGED_SWIPE_IDLE, d as PagedSwipeConfig, e as PagedSwipeContext, f as PagedSwipeInput, g as PagedSwipeOptions, h as PagedSwipeState, S as SwipeSide, i as createMachine, j as createPagedSwipe, p as pagedSwipeDeadline, k as pagedSwipeReducer, r as rubberBand, s as swipeProgress } from './paged-swipe-CIzjr2DQ.js';
7
+ import { M as Machine, D as Deadline } from './paged-swipe-DIukqKlE.js';
8
+ export { a as MachineOptions, P as PAGED_SWIPE_DEFAULTS, b as PAGED_SWIPE_EMPTY_CONTEXT, c as PAGED_SWIPE_IDLE, d as PagedSwipeConfig, e as PagedSwipeContext, f as PagedSwipeInput, g as PagedSwipeOptions, h as PagedSwipeState, R as RELEASE_RULE, i as ReleaseRule, j as ReleaseSample, S as SwipeSide, k as createMachine, l as createPagedSwipe, p as pagedSwipeDeadline, m as pagedSwipeReducer, r as releaseVelocity, n as rubberBand, s as swipeProgress } from './paged-swipe-DIukqKlE.js';
9
9
 
10
10
  /**
11
11
  * Input types: plain event objects in, one gesture stream out. Nothing here
package/dist/gestures.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  PAGED_SWIPE_EMPTY_CONTEXT,
7
7
  PAGED_SWIPE_IDLE,
8
8
  RECOGNIZER_DEFAULTS,
9
+ RELEASE_RULE,
9
10
  TOUCH_PRESS_DEFAULTS,
10
11
  TOUCH_PRESS_IDLE,
11
12
  WHEEL_DEFAULTS,
@@ -24,6 +25,7 @@ import {
24
25
  pagedSwipeDeadline,
25
26
  pagedSwipeReducer,
26
27
  platformButton,
28
+ releaseVelocity,
27
29
  resolveDragModifier,
28
30
  rubberBand,
29
31
  swipeProgress,
@@ -31,12 +33,12 @@ import {
31
33
  touchPressDeadline,
32
34
  touchPressReducer,
33
35
  wheelDelta
34
- } from "./chunk-K6TAWCGL.js";
36
+ } from "./chunk-GDV76P2H.js";
35
37
  import "./chunk-OOKRBVMB.js";
36
38
  import {
37
39
  DOUBLE_CLICK,
38
40
  isHeld
39
- } from "./chunk-RWDYRT3H.js";
41
+ } from "./chunk-TJC6AXFM.js";
40
42
  export {
41
43
  DOUBLE_CLICK,
42
44
  DWELL_DEFAULTS,
@@ -46,6 +48,7 @@ export {
46
48
  PAGED_SWIPE_EMPTY_CONTEXT,
47
49
  PAGED_SWIPE_IDLE,
48
50
  RECOGNIZER_DEFAULTS,
51
+ RELEASE_RULE,
49
52
  TOUCH_PRESS_DEFAULTS,
50
53
  TOUCH_PRESS_IDLE,
51
54
  WHEEL_DEFAULTS,
@@ -65,6 +68,7 @@ export {
65
68
  pagedSwipeDeadline,
66
69
  pagedSwipeReducer,
67
70
  platformButton,
71
+ releaseVelocity,
68
72
  resolveDragModifier,
69
73
  rubberBand,
70
74
  swipeProgress,
package/dist/index.d.ts CHANGED
@@ -2,13 +2,13 @@ export { C as ClockPort, F as FrameSource, T as TimerSource } from './port-CmlUc
2
2
  export { CoalescerOptions, FakeClock, FakeClockOptions, FrameCoalescer, createFakeClock, createFrameCoalescer } from './clock.js';
3
3
  export { F as FrameInfo, a as FrameLoop, b as FrameLoopOptions, c as FrameStats, d as FrameTask, P as PHASES, e as Phase, R as RepeatingTask, S as ScheduleOptions, f as createFrameLoop } from './frame-loop-f0V4b464.js';
4
4
  export { EffectCleanup, EffectOptions, Equals, ReadonlySignal, Signal, SignalOptions, batch, computed, effect, isSignal, signal, untracked } from './signals.js';
5
- export { A as Animator, S as SETTLE_DEFAULTS, a as SETTLE_TEMPO, b as Settle, c as SettleConfig, d as createSettle } from './settle-7C9xxbFg.js';
5
+ export { A as Animator, S as SETTLE_DEFAULTS, a as SETTLE_TEMPO, b as Settle, c as SettleConfig, d as SettleRange, e as createSettle } from './settle-BvkDVDhE.js';
6
6
  export { A as Animatable, P as Point, R as Rect, V as Vector, W as Widen, s as shapeEquals } from './shapes-EbQlwbCu.js';
7
7
  export { AnimatorValue, Easing, MotionOptions, MotionValue, SPRING_DEFAULTS, SetOptions, Spring, SpringConfig, SpringParams, SpringState, Tween, TweenConfig, createSpring, createTween, cubicBezier, ease, easeIn, easeInOut, easeInOutCubic, easeOut, easeOutCubic, linear, motionValue, resolveSpring, settleValue, springStep, springValue, tweenValue } from './values.js';
8
8
  export { P as PopIn, R as RevealFrame, p as popIn, r as reveal } from './reveal-Dg5fqoWS.js';
9
9
  export { CancelReason, DWELL_DEFAULTS, DWELL_IDLE, DwellConfig, DwellInput, DwellMachineOptions, DwellState, GesturePointer, InputGesture, InputGestureType, NO_MODIFIERS, Platform, PointerKind, RECOGNIZER_DEFAULTS, RawInputEvent, RawPointerEvent, RawPointerType, RawSafariGestureEvent, RawWheelEvent, Recognizer, RecognizerOptions, RecognizerTimers, TOUCH_PRESS_DEFAULTS, TOUCH_PRESS_IDLE, TouchPressConfig, TouchPressInput, TouchPressOptions, TouchPressState, WHEEL_DEFAULTS, WHEEL_PAN_DEFAULTS, WheelIntent, WheelOptions, WheelPanOptions, classifyWheel, createDwellMachine, createRecognizer, createTouchPress, dampWheelPan, defaultDragModifier, dwellDeadline, dwellReducer, modHeld, platformButton, resolveDragModifier, toModifiers, touchPressDeadline, touchPressReducer, wheelDelta } from './gestures.js';
10
10
  export { D as DOUBLE_CLICK, a as DoubleClick } from './double-click-jtUSNuHL.js';
11
- export { D as Deadline, M as Machine, a as MachineOptions, P as PAGED_SWIPE_DEFAULTS, b as PAGED_SWIPE_EMPTY_CONTEXT, c as PAGED_SWIPE_IDLE, d as PagedSwipeConfig, e as PagedSwipeContext, f as PagedSwipeInput, g as PagedSwipeOptions, h as PagedSwipeState, S as SwipeSide, i as createMachine, j as createPagedSwipe, p as pagedSwipeDeadline, k as pagedSwipeReducer, r as rubberBand, s as swipeProgress } from './paged-swipe-CIzjr2DQ.js';
11
+ export { D as Deadline, M as Machine, a as MachineOptions, P as PAGED_SWIPE_DEFAULTS, b as PAGED_SWIPE_EMPTY_CONTEXT, c as PAGED_SWIPE_IDLE, d as PagedSwipeConfig, e as PagedSwipeContext, f as PagedSwipeInput, g as PagedSwipeOptions, h as PagedSwipeState, R as RELEASE_RULE, i as ReleaseRule, j as ReleaseSample, S as SwipeSide, k as createMachine, l as createPagedSwipe, p as pagedSwipeDeadline, m as pagedSwipeReducer, r as releaseVelocity, n as rubberBand, s as swipeProgress } from './paged-swipe-DIukqKlE.js';
12
12
  export { ClearRect, DRAG_DEFAULTS, DRAG_PREVIEW_DEFAULT, DragFrame, DragIntent, DragIntentOptions, DragIntentState, DragKeys, DragModifiers, DragPreview, DragTarget, DragTuning, GripPress, GripRelease, GuideRectsOptions, LANDING_APPROACH, LANDING_GATES, LANDING_MARGINS, LANDING_MODIFIERS, LANDING_TOUCH_MARGINS, LandingApproach, LandingFrame, LandingGates, LandingGeometry, LandingGuideRef, LandingHeld, LandingLane, LandingMargins, LandingModel, LandingModifiers, LandingOptions, LandingRegion, LandingRegions, LandingRelease, LandingSpot, LiftDecision, MIN_BOX_LENGTH, PLACE_GUIDES_DEFAULT, PlaceGuides, PlacedGuide, PreviewFrame, PreviewMode, PreviewPlan, REFUSAL_RANK, createDragIntent, createGripPress, createLandingModel, guideRects, guidesOf, inRect, liftDecision, pickRank, previewPlan, targetAt } from './drag.js';
13
13
  export { M as ModifierKey, a as Modifiers, i as isHeld } from './keys-BpcrOp4S.js';
14
14
  export { D as DrawEntry, a as DrawFrame, b as Drawable, L as LayoutItem, c as LayoutMotion, d as LayoutMotionOptions, e as LayoutTask, f as createLayoutMotion } from './motion-sElR1A_c.js';
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  springStep,
24
24
  springValue,
25
25
  tweenValue
26
- } from "./chunk-NI7JLDWZ.js";
26
+ } from "./chunk-I4TKJWCD.js";
27
27
  import {
28
28
  DWELL_DEFAULTS,
29
29
  DWELL_IDLE,
@@ -32,6 +32,7 @@ import {
32
32
  PAGED_SWIPE_EMPTY_CONTEXT,
33
33
  PAGED_SWIPE_IDLE,
34
34
  RECOGNIZER_DEFAULTS,
35
+ RELEASE_RULE,
35
36
  TOUCH_PRESS_DEFAULTS,
36
37
  TOUCH_PRESS_IDLE,
37
38
  WHEEL_DEFAULTS,
@@ -50,6 +51,7 @@ import {
50
51
  pagedSwipeDeadline,
51
52
  pagedSwipeReducer,
52
53
  platformButton,
54
+ releaseVelocity,
53
55
  resolveDragModifier,
54
56
  rubberBand,
55
57
  swipeProgress,
@@ -57,7 +59,7 @@ import {
57
59
  touchPressDeadline,
58
60
  touchPressReducer,
59
61
  wheelDelta
60
- } from "./chunk-K6TAWCGL.js";
62
+ } from "./chunk-GDV76P2H.js";
61
63
  import {
62
64
  batch,
63
65
  computed,
@@ -87,17 +89,17 @@ import {
87
89
  pickRank,
88
90
  previewPlan,
89
91
  targetAt
90
- } from "./chunk-B53X43GW.js";
92
+ } from "./chunk-F5FNGVQT.js";
91
93
  import {
92
94
  DOUBLE_CLICK,
93
95
  isHeld
94
- } from "./chunk-RWDYRT3H.js";
96
+ } from "./chunk-TJC6AXFM.js";
95
97
  import {
96
98
  MORPH_TEMPO,
97
99
  anchoredMorph,
98
100
  createLayoutMotion,
99
101
  holdItem
100
- } from "./chunk-5EMLVHP3.js";
102
+ } from "./chunk-ZVFIWSC4.js";
101
103
  import {
102
104
  SETTLE_DEFAULTS,
103
105
  SETTLE_TEMPO,
@@ -105,7 +107,7 @@ import {
105
107
  popIn,
106
108
  reveal,
107
109
  shapeEquals
108
- } from "./chunk-ALYH6YQK.js";
110
+ } from "./chunk-MTSGXDVI.js";
109
111
  export {
110
112
  DOUBLE_CLICK,
111
113
  DRAG_DEFAULTS,
@@ -127,6 +129,7 @@ export {
127
129
  PLACE_GUIDES_DEFAULT,
128
130
  RECOGNIZER_DEFAULTS,
129
131
  REFUSAL_RANK,
132
+ RELEASE_RULE,
130
133
  SETTLE_DEFAULTS,
131
134
  SETTLE_TEMPO,
132
135
  SPRING_DEFAULTS,
@@ -181,6 +184,7 @@ export {
181
184
  platformButton,
182
185
  popIn,
183
186
  previewPlan,
187
+ releaseVelocity,
184
188
  resolveDragModifier,
185
189
  resolveSpring,
186
190
  reveal,
package/dist/layout.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { L as LayoutItem } from './motion-sElR1A_c.js';
2
2
  export { D as DrawEntry, a as DrawFrame, b as Drawable, c as LayoutMotion, d as LayoutMotionOptions, e as LayoutTask, f as createLayoutMotion } from './motion-sElR1A_c.js';
3
3
  import { P as Point, R as Rect } from './shapes-EbQlwbCu.js';
4
- import { c as SettleConfig } from './settle-7C9xxbFg.js';
4
+ import { c as SettleConfig } from './settle-BvkDVDhE.js';
5
5
  import './frame-loop-f0V4b464.js';
6
6
  import './port-CmlUctqx.js';
7
7
  import './reveal-Dg5fqoWS.js';
package/dist/layout.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  anchoredMorph,
4
4
  createLayoutMotion,
5
5
  holdItem
6
- } from "./chunk-5EMLVHP3.js";
7
- import "./chunk-ALYH6YQK.js";
6
+ } from "./chunk-ZVFIWSC4.js";
7
+ import "./chunk-MTSGXDVI.js";
8
8
  export {
9
9
  MORPH_TEMPO,
10
10
  anchoredMorph,
@@ -41,6 +41,48 @@ interface Machine<S, E> {
41
41
  /** Run a pure machine on a clock: it arms and clears the deadline timer for you. */
42
42
  declare function createMachine<S, E>(options: MachineOptions<S, E>): Machine<S, E>;
43
43
 
44
+ /**
45
+ * The release velocity: how fast, and which way, a pointer was moving along one axis when its gesture ended, read from
46
+ * its last samples. A gesture that ends in a throw (a paged swipe, a drag let go) hands it to the value that carries
47
+ * on. It is a velocity, signed, always a number; the landing model's hand speed (a speed along the path, unsigned, for
48
+ * judging "fast or slow", and allowed to be unknown) is a different estimate. On straight, steady motion the two read
49
+ * the same size. Both read sample times the same way (`../samples`).
50
+ *
51
+ * The rule, over the samples (oldest first):
52
+ * - **Which samples count.** One whose time or travel is not a finite number is left out; so is one stamped earlier
53
+ * than the newest kept, and one under 1 ms past it (the same sample: in a run of such stamps, the first 1 ms or more
54
+ * past the newest kept counts). Of the rest, those no more than `lookback` ms older than the newest are read, at most
55
+ * the newest 64.
56
+ * - **The rest.** It is 0 when the gesture ended more than `rest` ms after the newest sample (the pointer stood still),
57
+ * or before it (a clock that stepped back), or when fewer than two samples are read.
58
+ * - **The velocity** is the travel from the oldest sample read to the newest over the time between them, read over
59
+ * 16 ms at least (a window shorter than one 60 Hz frame says little about speed), in px per ms. A result that is not
60
+ * a finite number is 0.
61
+ *
62
+ * Only the sample times decide which samples count, so a host that draws something other than the travel (a curve
63
+ * of it) maps the travels of its samples and calls this on them: the velocity of what it draws, by the same rule.
64
+ */
65
+ /** One sample of a moving pointer: the clock time (ms) and the travel along one axis (px). */
66
+ interface ReleaseSample {
67
+ readonly t: number;
68
+ readonly travel: number;
69
+ }
70
+ /** The two numbers the release velocity reads, both ms. */
71
+ interface ReleaseRule {
72
+ /** The samples of the last `lookback` ms count (the window). A value that is not a number above 0 means the default; above 1000 (Infinity too) it is 1000. */
73
+ readonly lookback: number;
74
+ /** A gesture that ended more than `rest` ms after its newest sample ends at 0. `Infinity`: never. NaN or a value below 0 means the default. */
75
+ readonly rest: number;
76
+ }
77
+ /** Defaults of {@link ReleaseRule}: a 50 ms window, a 100 ms rest. */
78
+ declare const RELEASE_RULE: ReleaseRule;
79
+ /**
80
+ * The release velocity of `samples` (oldest first) for a gesture that ended at `endedAt` (ms): px of travel per ms,
81
+ * signed like the travel. See the rule above. A value's velocity is per second: pass `releaseVelocity(…) * 1000` to
82
+ * `set(target, { velocity })`.
83
+ */
84
+ declare function releaseVelocity(samples: ReadonlyArray<ReleaseSample>, endedAt: number, rule?: Partial<ReleaseRule>): number;
85
+
44
86
  /**
45
87
  * A paged swipe: a trackpad's two-finger scroll or a finger swipes from one page to the previous or the next, the
46
88
  * pages following it, and commits or snaps back when it ends.
@@ -73,6 +115,11 @@ declare function createMachine<S, E>(options: MachineOptions<S, E>): Machine<S,
73
115
  * ran a scroll to its end doesn't page on the next flick. A finger that rested `flickRest` before lifting isn't flicking. With `band`, a
74
116
  * finger also tracks towards a side with no page (progress 0, never a commit), so the host can draw a rubber band
75
117
  * from `travel` ({@link rubberBand}).
118
+ * - **The release velocity.** Every tracked sample is recorded in `samples`, and `settling` carries `releaseVelocity`:
119
+ * {@link releaseVelocity} on those samples at `ended`, with `releaseWindow` as its window and `flickRest` as its rest
120
+ * (a wheel run's too: it ends `idle` after its last sample, so with the default timings it ends at 0). A swipe that
121
+ * gives way (`block`, `scrolled`, `cancel` while tracking) carries 0 and no samples: those events carry no time to
122
+ * judge a rest by, and the pointer is no longer the swipe's.
76
123
  *
77
124
  * Pure and timer-free: {@link pagedSwipeDeadline} says when the next `tick` is due ({@link createPagedSwipe} arms it).
78
125
  * Signs: a wheel delta > 0 along the swipe heads to `next`; a finger moving towards smaller x (or y) heads to `next`.
@@ -103,6 +150,12 @@ interface PagedSwipeConfig {
103
150
  readonly flickRest?: number;
104
151
  /** A finger may track towards a side with no page, never committing there (for a rubber band). Default false. */
105
152
  readonly band?: boolean;
153
+ /**
154
+ * ms: the release velocity reads the newest 64 samples within the swipe's last `releaseWindow` ms (see
155
+ * {@link releaseVelocity}). Default 50. A value that is not a number above 0 means the default; above 1000 (Infinity
156
+ * too) it is 1000.
157
+ */
158
+ readonly releaseWindow?: number;
106
159
  }
107
160
  /** Defaults of {@link PagedSwipeConfig}. */
108
161
  declare const PAGED_SWIPE_DEFAULTS: PagedSwipeConfig;
@@ -158,12 +211,28 @@ type PagedSwipeState = (Base & {
158
211
  readonly peak: number;
159
212
  /** The context the swipe armed with: its pages and size hold until it ends (a `context` meanwhile waits). */
160
213
  readonly held: PagedSwipeContext;
214
+ /**
215
+ * The tracked samples the release velocity will read, oldest first: the newest 64 within the last
216
+ * `releaseWindow` ms (the newest is the one that set `last` and `travel`, unless it was the same sample as the one
217
+ * before). The reducer always sets it; it is optional only so that a state written by hand still compiles (one
218
+ * without it counts `{ last, travel }` as its first sample).
219
+ */
220
+ readonly samples?: ReadonlyArray<ReleaseSample>;
161
221
  }) | (Base & {
162
222
  readonly phase: "settling";
163
223
  readonly input: Input;
164
224
  readonly outcome: "commit" | "cancel";
165
225
  readonly ended: number;
166
226
  readonly lastWheel: number;
227
+ /**
228
+ * px per ms, like `peak` and `commitVelocity`, signed like `travel` (positive towards `next`): how fast the swipe
229
+ * moved when it ended, {@link releaseVelocity} on `samples` at `ended`; 0 when it gave way. A value's velocity is
230
+ * per second: for a page drawn at `-travel`, `set(target, { velocity: -releaseVelocity * 1000 })`. The reducer
231
+ * always sets it; it is optional only so that a state written by hand still compiles.
232
+ */
233
+ readonly releaseVelocity?: number;
234
+ /** The samples it was read from (empty when the swipe gave way). Always set by the reducer, like `releaseVelocity`. */
235
+ readonly samples?: ReadonlyArray<ReleaseSample>;
167
236
  }) | (Base & {
168
237
  readonly phase: "lockout";
169
238
  readonly until: number;
@@ -241,4 +310,4 @@ interface PagedSwipeOptions {
241
310
  /** A paged swipe on a clock: the idle and lockout timers are armed for you. */
242
311
  declare function createPagedSwipe(options: PagedSwipeOptions): Machine<PagedSwipeState, PagedSwipeInput>;
243
312
 
244
- export { type Deadline as D, type Machine as M, PAGED_SWIPE_DEFAULTS as P, type SwipeSide as S, type MachineOptions as a, PAGED_SWIPE_EMPTY_CONTEXT as b, PAGED_SWIPE_IDLE as c, type PagedSwipeConfig as d, type PagedSwipeContext as e, type PagedSwipeInput as f, type PagedSwipeOptions as g, type PagedSwipeState as h, createMachine as i, createPagedSwipe as j, pagedSwipeReducer as k, pagedSwipeDeadline as p, rubberBand as r, swipeProgress as s };
313
+ export { type Deadline as D, type Machine as M, PAGED_SWIPE_DEFAULTS as P, RELEASE_RULE as R, type SwipeSide as S, type MachineOptions as a, PAGED_SWIPE_EMPTY_CONTEXT as b, PAGED_SWIPE_IDLE as c, type PagedSwipeConfig as d, type PagedSwipeContext as e, type PagedSwipeInput as f, type PagedSwipeOptions as g, type PagedSwipeState as h, type ReleaseRule as i, type ReleaseSample as j, createMachine as k, createPagedSwipe as l, pagedSwipeReducer as m, rubberBand as n, pagedSwipeDeadline as p, releaseVelocity as r, swipeProgress as s };
@@ -39,12 +39,33 @@ declare const SETTLE_TEMPO: {
39
39
  readonly default: 25;
40
40
  readonly quick: 37;
41
41
  };
42
- /** Settings of {@link createSettle}. */
43
- interface SettleConfig {
42
+ /** The values a settle is kept between, per component, in the value's shape (see {@link SettleConfig.within}). */
43
+ interface SettleRange<T> {
44
+ readonly min: T;
45
+ readonly max: T;
46
+ }
47
+ /**
48
+ * Settings of {@link createSettle}. `T` is the value's shape (`SettleConfig<number>`, `SettleConfig<Rect>`); a plain
49
+ * `SettleConfig` has no range, and passes to a settle of any shape.
50
+ */
51
+ interface SettleConfig<T = never> {
44
52
  /** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */
45
53
  readonly omega?: number;
46
54
  /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */
47
55
  readonly restDelta?: number;
56
+ /**
57
+ * Limits how far a set velocity can carry the value: with the value and the target inside `min`…`max`, the value
58
+ * never leaves. It does not move the value or the target; a target outside is still reached.
59
+ *
60
+ * A velocity set away from the target (`setVelocity`, or a value's `set(target, { velocity })`) makes the value go
61
+ * on, stop and come back; with a range, that speed is lowered just enough for the value to stop before the bound
62
+ * (to 0 when the value already stands at it, or the range has no width). A speed toward the target, a new target and
63
+ * the rest are as without one. Per component; a side may be `-Infinity` or `Infinity` (open). `null` clears it.
64
+ * Under reduced motion a value goes to its target at once, inside or not. Clearing the range later doesn't give back
65
+ * a speed it lowered. A `min` above `max`, a side that is NaN, a `min` of `Infinity` or a `max` of `-Infinity`
66
+ * throw a `RangeError`, and the settle is left as it was.
67
+ */
68
+ readonly within?: SettleRange<T> | null;
48
69
  }
49
70
  /**
50
71
  * The one curve for things that move to a new place: a window's rect between
@@ -64,7 +85,10 @@ interface SettleConfig {
64
85
  * there instead of shooting past.
65
86
  * - **Carry.** A velocity set by hand away from the target is kept, and the
66
87
  * value turns around; a critically damped spring turning around never
67
- * crosses the target either.
88
+ * crosses the target either. With a range ({@link SettleConfig.within}) it
89
+ * is lowered just enough for the value to stop before the bound on its side.
90
+ * - **A velocity that is not a finite number** (NaN, ±Infinity, either way) is
91
+ * taken as 0.
68
92
  *
69
93
  * So after a new target every component goes straight from where it is drawn
70
94
  * to the target and never past it: no overshoot on position, no wobble on
@@ -77,10 +101,15 @@ interface SettleConfig {
77
101
  interface Settle<T> extends Animator<T> {
78
102
  /** The tempo in 1/s. */
79
103
  readonly omega: number;
80
- /** Set the velocity (units per second); a component moving toward the target is clamped as in the launch rule. */
104
+ /** The range in force ({@link SettleConfig.within}), or null. */
105
+ readonly within: SettleRange<T> | null;
106
+ /**
107
+ * Set the velocity, in units per second (a gesture's release velocity in px per ms is `* 1000`); a component moving
108
+ * toward the target is clamped as in the launch rule, one moving away is kept or, with a range, lowered.
109
+ */
81
110
  setVelocity(velocity: T): void;
82
- /** Change the tempo or rest distance mid-flight; the value and velocity carry on, re-clamped. */
83
- configure(config: SettleConfig): void;
111
+ /** Change the tempo, rest distance or range mid-flight; the value and velocity carry on, re-clamped and re-lowered. */
112
+ configure(config: SettleConfig<T>): void;
84
113
  }
85
114
  /** Defaults of {@link SettleConfig}. */
86
115
  declare const SETTLE_DEFAULTS: {
@@ -89,8 +118,9 @@ declare const SETTLE_DEFAULTS: {
89
118
  };
90
119
  /**
91
120
  * A settle starting at rest on `initial` (a number, a vector, a point or a
92
- * rect; targets and velocities must have the same shape). See {@link Settle}.
121
+ * rect; targets, velocities and a range must have the same shape). See
122
+ * {@link Settle}.
93
123
  */
94
- declare function createSettle<T extends Animatable>(initial: T, config?: SettleConfig): Settle<Widen<T>>;
124
+ declare function createSettle<T extends Animatable>(initial: T, config?: SettleConfig<Widen<T>>): Settle<Widen<T>>;
95
125
 
96
- export { type Animator as A, SETTLE_DEFAULTS as S, SETTLE_TEMPO as a, type Settle as b, type SettleConfig as c, createSettle as d };
126
+ export { type Animator as A, SETTLE_DEFAULTS as S, SETTLE_TEMPO as a, type Settle as b, type SettleConfig as c, type SettleRange as d, createSettle as e };
package/dist/values.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Animator, c as SettleConfig, b as Settle } from './settle-7C9xxbFg.js';
2
- export { S as SETTLE_DEFAULTS, a as SETTLE_TEMPO, d as createSettle } from './settle-7C9xxbFg.js';
1
+ import { A as Animator, c as SettleConfig, b as Settle } from './settle-BvkDVDhE.js';
2
+ export { S as SETTLE_DEFAULTS, a as SETTLE_TEMPO, d as SettleRange, e as createSettle } from './settle-BvkDVDhE.js';
3
3
  import { A as Animatable, W as Widen } from './shapes-EbQlwbCu.js';
4
4
  export { P as Point, R as Rect, V as Vector } from './shapes-EbQlwbCu.js';
5
5
  export { P as PopIn, R as RevealFrame, p as popIn, r as reveal } from './reveal-Dg5fqoWS.js';
@@ -129,7 +129,10 @@ interface MotionOptions {
129
129
  }
130
130
  /** Options of {@link MotionValue.set}. */
131
131
  interface SetOptions<T> {
132
- /** 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. */
132
+ /**
133
+ * Start with this velocity, in units per second, e.g. a gesture's release velocity (px per ms: `* 1000`). Springs and
134
+ * settles (a settle caps it toward the target, and within its range lowers it away from the target); tweens ignore it.
135
+ */
133
136
  readonly velocity?: T;
134
137
  }
135
138
  /**
@@ -183,8 +186,9 @@ declare function springValue<T extends Animatable>(loop: FrameLoop, initial: T,
183
186
  * A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The
184
187
  * one curve for things moving to a new place (see {@link Settle}). To hold it
185
188
  * to a pointer, `jump` it on each move; the next `set` launches from there.
189
+ * A range (`within`) keeps a velocity given to `set` from carrying it out.
186
190
  */
187
- declare function settleValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: SettleConfig & MotionOptions): MotionValue<Widen<T>, Settle<Widen<T>>>;
191
+ declare function settleValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: SettleConfig<Widen<T>> & MotionOptions): MotionValue<Widen<T>, Settle<Widen<T>>>;
188
192
  /** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */
189
193
  declare function tweenValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: TweenConfig & MotionOptions): MotionValue<Widen<T>, Tween<Widen<T>>>;
190
194
 
package/dist/values.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  springStep,
17
17
  springValue,
18
18
  tweenValue
19
- } from "./chunk-NI7JLDWZ.js";
19
+ } from "./chunk-I4TKJWCD.js";
20
20
  import "./chunk-OOKRBVMB.js";
21
21
  import {
22
22
  SETTLE_DEFAULTS,
@@ -24,7 +24,7 @@ import {
24
24
  createSettle,
25
25
  popIn,
26
26
  reveal
27
- } from "./chunk-ALYH6YQK.js";
27
+ } from "./chunk-MTSGXDVI.js";
28
28
  export {
29
29
  SETTLE_DEFAULTS,
30
30
  SETTLE_TEMPO,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n-uf/motion",
3
- "version": "26.11.64",
3
+ "version": "26.12.0",
4
4
  "description": "How things move: one frame loop with an injected clock, springs, tweens and the settle curve, a DOM-free gesture recognizer, the drag intent and the landing model, and layout motion. No DOM, no framework.",
5
5
  "keywords": [
6
6
  "animation",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shapes.ts","../src/values/step.ts","../src/values/settle.ts","../src/values/reveal.ts"],"sourcesContent":["/** A point or a 2D vector. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** An axis-aligned rectangle. */\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Any number of components. */\nexport type Vector = readonly number[];\n\n/** The value shapes springs and tweens move: plain numbers, nothing else. */\nexport type Animatable = number | Point | Rect | Vector;\n\n/** The shape type of an {@link Animatable}: literal numbers widen to `number`. */\nexport type Widen<T> = T extends number\n ? number\n : T extends Vector\n ? Vector\n : T extends Rect\n ? Rect\n : T extends Point\n ? Point\n : never;\n\nconst SCALAR = 0;\nconst VECTOR = 1;\nconst POINT = 2;\nconst RECT = 3;\n\n/** How a shape maps onto a flat list of numbers. Internal to values/. */\nexport interface Layout {\n readonly kind: typeof SCALAR | typeof VECTOR | typeof POINT | typeof RECT;\n readonly size: number;\n}\n\nconst SCALAR_LAYOUT: Layout = { kind: SCALAR, size: 1 };\nconst POINT_LAYOUT: Layout = { kind: POINT, size: 2 };\nconst RECT_LAYOUT: Layout = { kind: RECT, size: 4 };\n\nexport function layoutOf(value: Animatable): Layout {\n if (typeof value === \"number\") return SCALAR_LAYOUT;\n if (Array.isArray(value)) return { kind: VECTOR, size: value.length };\n if (\"width\" in value) return RECT_LAYOUT;\n return POINT_LAYOUT;\n}\n\nexport function sameLayout(a: Layout, b: Layout): boolean {\n return a.kind === b.kind && a.size === b.size;\n}\n\n/** Copy `value`'s components into `out`. */\nexport function writeComponents(value: Animatable, out: Float64Array): void {\n if (typeof value === \"number\") {\n out[0] = value;\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) out[i] = value[i]!;\n } else if (\"width\" in value) {\n out[0] = value.x;\n out[1] = value.y;\n out[2] = value.width;\n out[3] = value.height;\n } else {\n const point = value as Point;\n out[0] = point.x;\n out[1] = point.y;\n }\n}\n\n/** A fresh value of `layout`'s shape from `components`. */\nexport function makeValue(layout: Layout, components: Float64Array): Animatable {\n switch (layout.kind) {\n case SCALAR:\n return components[0]!;\n case POINT:\n return { x: components[0]!, y: components[1]! };\n case RECT:\n return { x: components[0]!, y: components[1]!, width: components[2]!, height: components[3]! };\n default:\n return Array.from(components);\n }\n}\n\n/** Component-wise equality of two values of the same shape. */\nexport function shapeEquals(a: Animatable, b: Animatable): boolean {\n if (typeof a === \"number\" || typeof b === \"number\") return a === b;\n if (Array.isArray(a) || Array.isArray(b)) {\n const u = a as Vector;\n const v = b as Vector;\n if (u.length !== v.length) return false;\n for (let i = 0; i < u.length; i++) if (u[i] !== v[i]) return false;\n return true;\n }\n const p = a as Partial<Rect>;\n const q = b as Partial<Rect>;\n return p.x === q.x && p.y === q.y && p.width === q.width && p.height === q.height;\n}\n","import type { Animatable, Layout } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\n\n/**\n * The exact critically damped step for one component, shared by the spring and the settle: displacement `d0` from the\n * target and velocity `v0` (per second) after `t` seconds, with `e` = e^(−w·t) worked out once per step. Writes into\n * out[0], out[1]: d(t) = e·(d0 + b·t), v(t) = e·(v0 − w·b·t), b = v0 + w·d0.\n */\nexport function criticalStep(w: number, e: number, d0: number, v0: number, t: number, out: Float64Array): void {\n const b = v0 + w * d0;\n out[0] = e * (d0 + b * t);\n out[1] = e * (v0 - w * b * t);\n}\n\n/**\n * What the spring and the settle share: a value of any {@link Animatable} shape kept as components (position, velocity\n * and target), its shape check, the rest test of a step, jump and snap. Each one adds only its own law: `begin` (what a\n * step works out once), `advance` (one component over `t` seconds) and `rests` (when a component counts as arrived).\n */\nexport abstract class ComponentAnimator implements Animator<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly v: Float64Array;\n readonly goal: Float64Array;\n readonly scratch = new Float64Array(2);\n settled = true;\n cachedValue: Animatable | null = null;\n /** How errors call it (\"spring\", \"settle\"). */\n private readonly name: string;\n\n constructor(initial: Animatable, name: string) {\n this.name = name;\n this.layout = layoutOf(initial);\n this.x = new Float64Array(this.layout.size);\n this.v = new Float64Array(this.layout.size);\n this.goal = new Float64Array(this.layout.size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.goal);\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 velocity(): Animatable {\n return makeValue(this.layout, this.v);\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`${this.name}: ${what} has a different shape than the ${this.name}'s value`);\n }\n }\n\n /** At rest exactly when on the target and not moving. */\n updateSettled(): void {\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i] || this.v[i] !== 0) {\n this.settled = false;\n return;\n }\n }\n this.settled = true;\n }\n\n abstract setTarget(target: Animatable): void;\n\n abstract setVelocity(velocity: Animatable): void;\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n /** Work out what every component's step of `t` seconds shares. */\n protected abstract begin(t: number): void;\n /** One component, `d0` from its target at `v0` per second, after `t` seconds: into out[0], out[1]. */\n protected abstract advance(d0: number, v0: number, t: number, out: Float64Array): void;\n /** Whether component `i`, now `d` from its target at `v` per second, counts as arrived. */\n protected abstract rests(i: number, d: number, v: number): boolean;\n\n step(dt: number): boolean {\n if (this.settled) return false;\n if (!(dt > 0)) return true;\n const t = dt / 1000;\n const { x, v, goal, scratch } = this;\n this.begin(t);\n let resting = true;\n for (let i = 0; i < x.length; i++) {\n this.advance(x[i]! - goal[i]!, v[i]!, t, scratch);\n x[i] = goal[i]! + scratch[0]!;\n v[i] = scratch[1]!;\n if (resting && !this.rests(i, scratch[0]!, scratch[1]!)) resting = false;\n }\n this.cachedValue = null;\n if (resting) this.snap();\n return !this.settled;\n }\n}\n","import type { Animatable, Widen } from \"../shapes\";\nimport { writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\n\n/**\n * Tempos for {@link createSettle}, in 1/s: a settle covers 90 % of the way in\n * ln(10)/omega seconds and is within 1 % in twice that.\n *\n * - `calm` 20: 90 % in 115 ms, done in 230 ms.\n * - `default` 25: 90 % in 92 ms, done in 184 ms.\n * - `quick` 37: 90 % in 62 ms, done in 124 ms (a fast Hyprland setup).\n */\nexport const SETTLE_TEMPO = { calm: 20, default: 25, quick: 37 } as const;\n\n/** Settings of {@link createSettle}. */\nexport interface SettleConfig {\n /** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */\n readonly omega?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n}\n\n/**\n * The one curve for things that move to a new place: a window's rect between\n * layout targets, a drawer, a camera. Fast at the start, gentle at the end,\n * and it never passes its target.\n *\n * It is a critically damped spring (stiffness omega², damping 2·omega) with\n * one rule on its velocity, per component:\n *\n * - **Launch.** On a new target, each component gets the velocity\n * omega · distance toward it, from wherever it is drawn: standing still,\n * moving toward it, or moving away (it turns at once rather than drifting\n * further first). From there the spring follows `distance · e^(−omega·t)`\n * exactly: most of the move happens at once, the rest eases in.\n * - **Clamp.** That speed is also the most it may have toward the target, so a\n * velocity set by hand (`setVelocity`, a fling) toward the target is capped\n * there instead of shooting past.\n * - **Carry.** A velocity set by hand away from the target is kept, and the\n * value turns around; a critically damped spring turning around never\n * crosses the target either.\n *\n * So after a new target every component goes straight from where it is drawn\n * to the target and never past it: no overshoot on position, no wobble on\n * size, whatever the retargets. A new target starts from the drawn value,\n * never from the old start.\n *\n * Holding (a pointer owns the value): call `jumpTo(value)` on each move. The\n * value sits exactly there, at rest; the next `setTarget` launches from it.\n */\nexport interface Settle<T> extends Animator<T> {\n /** The tempo in 1/s. */\n readonly omega: number;\n /** Set the velocity (units per second); a component moving toward the target is clamped as in the launch rule. */\n setVelocity(velocity: T): void;\n /** Change the tempo or rest distance mid-flight; the value and velocity carry on, re-clamped. */\n configure(config: SettleConfig): void;\n}\n\n/** Defaults of {@link SettleConfig}. */\nexport const SETTLE_DEFAULTS = { omega: SETTLE_TEMPO.default, restDelta: 0.1 } as const;\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`settle: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\nclass SettleAnimator extends ComponentAnimator implements Settle<Animatable> {\n omega: number;\n restDelta: number;\n // One step's shared numbers (`begin`): e^(−omega·t) and the rest speed.\n private e = 1;\n private restSpeed = 0;\n\n constructor(initial: Animatable, config: SettleConfig) {\n super(initial, \"settle\");\n this.omega = positive(\"omega\", config.omega ?? SETTLE_DEFAULTS.omega);\n this.restDelta = positive(\"restDelta\", config.restDelta ?? SETTLE_DEFAULTS.restDelta);\n }\n\n /** The launch/clamp/carry rule on component `i`: `launch` for a new target, else clamp or carry. */\n rule(i: number, launch: boolean): void {\n const d = this.x[i]! - this.goal[i]!;\n const v = this.v[i]!;\n const limit = d === 0 ? 0 : -this.omega * d;\n if (launch) {\n this.v[i] = limit;\n return;\n }\n if (d === 0) return;\n // Moving away from the target (d and v the same sign): carry.\n if (d * v > 0) return;\n // Moving toward it: no faster than a launch from here.\n if (Math.abs(v) > Math.abs(limit)) this.v[i] = limit;\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n for (let i = 0; i < this.x.length; i++) this.rule(i, true);\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n this.updateSettled();\n }\n\n configure(config: SettleConfig): void {\n if (config.omega !== undefined) this.omega = positive(\"omega\", config.omega);\n if (config.restDelta !== undefined) this.restDelta = positive(\"restDelta\", config.restDelta);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n }\n\n protected begin(t: number): void {\n this.e = Math.exp(-this.omega * t);\n // At rest when every component is within restDelta and no faster than a launch from there would be.\n this.restSpeed = this.omega * this.restDelta * 1.000001;\n }\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n criticalStep(this.omega, this.e, d0, v0, t, out);\n }\n\n protected rests(i: number, d: number, v: number): boolean {\n // Within a few float steps of the goal counts as arrived too: a restDelta finer than that would never be met.\n const near = Math.max(this.restDelta, 4 * Number.EPSILON * Math.abs(this.goal[i]!));\n return !(Math.abs(d) > near || Math.abs(v) > Math.max(this.restSpeed, this.omega * near));\n }\n}\n\n/**\n * A settle starting at rest on `initial` (a number, a vector, a point or a\n * rect; targets and velocities must have the same shape). See {@link Settle}.\n */\nexport function createSettle<T extends Animatable>(initial: T, config: SettleConfig = {}): Settle<Widen<T>> {\n return new SettleAnimator(initial, config) as unknown as Settle<Widen<T>>;\n}\n","import type { Rect } from \"../shapes\";\n\n/**\n * How to draw a window whose rect is gliding without stretching its content.\n *\n * The content is laid out once at the target size and never scaled. The\n * window's element sits at its target in the layout; to draw it at the\n * gliding rect:\n *\n * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;\n * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;\n * - clip the content by `clipRight` and `clipBottom` so it fits a frame\n * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).\n *\n * A window that shrinks shows a band of its own background closing in at the\n * right and bottom; one that grows reveals content already laid out at its\n * new size. Text is never stretched. One transform and one clip per frame, no\n * layout per frame.\n */\nexport interface RevealFrame {\n /** Move the element (laid out at the target) right by this much. */\n readonly dx: number;\n /** Move the element (laid out at the target) down by this much. */\n readonly dy: number;\n /** The frame's width: the drawn rect's. */\n readonly width: number;\n /** The frame's height: the drawn rect's. */\n readonly height: number;\n /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */\n readonly clipRight: number;\n /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */\n readonly clipBottom: number;\n}\n\n/** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */\nexport function reveal(drawn: Rect, target: Rect): RevealFrame {\n return {\n dx: drawn.x - target.x,\n dy: drawn.y - target.y,\n width: Math.max(0, drawn.width),\n height: Math.max(0, drawn.height),\n clipRight: Math.max(0, target.width - drawn.width),\n clipBottom: Math.max(0, target.height - drawn.height),\n };\n}\n\n/** A uniform pop-in (or pop-out, run backwards): scale about the center and opacity. */\nexport interface PopIn {\n /** Scale about the window's center: the same on both axes, so nothing is stretched. */\n readonly scale: number;\n readonly opacity: number;\n}\n\n/**\n * Opening and closing: the window grows from `from` of its size to full, about\n * its center, while fading in. `progress` runs 0 to 1 (take it from a settle\n * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for\n * pixels and would snap the last 10 %; or from a tween); closing runs it from\n * 1 to 0. Hyprland's default is `popin 87%`.\n */\nexport function popIn(progress: number, from = 0.87): PopIn {\n const p = Math.min(1, Math.max(0, progress));\n return { scale: from + (1 - from) * p, opacity: p };\n}\n"],"mappings":";AA+BA,IAAM,SAAS;AACf,IAAM,SAAS;AACf,IAAM,QAAQ;AACd,IAAM,OAAO;AAQb,IAAM,gBAAwB,EAAE,MAAM,QAAQ,MAAM,EAAE;AACtD,IAAM,eAAuB,EAAE,MAAM,OAAO,MAAM,EAAE;AACpD,IAAM,cAAsB,EAAE,MAAM,MAAM,MAAM,EAAE;AAE3C,SAAS,SAAS,OAA2B;AAClD,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,EAAE,MAAM,QAAQ,MAAM,MAAM,OAAO;AACpE,MAAI,WAAW,MAAO,QAAO;AAC7B,SAAO;AACT;AAEO,SAAS,WAAW,GAAW,GAAoB;AACxD,SAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE;AAC3C;AAGO,SAAS,gBAAgB,OAAmB,KAAyB;AAC1E,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,IAAI;AAAA,EACX,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAK,KAAI,CAAC,IAAI,MAAM,CAAC;AAAA,EACzD,WAAW,WAAW,O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