@n-uf/motion 26.11.63 → 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.
- package/CHANGELOG.md +53 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/{chunk-ZHDCLM3J.js → chunk-F5FNGVQT.js} +37 -14
- package/dist/chunk-F5FNGVQT.js.map +1 -0
- package/dist/{chunk-K6TAWCGL.js → chunk-GDV76P2H.js} +63 -9
- package/dist/chunk-GDV76P2H.js.map +1 -0
- package/dist/{chunk-NI7JLDWZ.js → chunk-I4TKJWCD.js} +2 -2
- package/dist/chunk-I4TKJWCD.js.map +1 -0
- package/dist/{chunk-ALYH6YQK.js → chunk-MTSGXDVI.js} +60 -6
- package/dist/chunk-MTSGXDVI.js.map +1 -0
- package/dist/{chunk-RWDYRT3H.js → chunk-TJC6AXFM.js} +12 -2
- package/dist/chunk-TJC6AXFM.js.map +1 -0
- package/dist/{chunk-5EMLVHP3.js → chunk-ZVFIWSC4.js} +2 -2
- package/dist/drag.d.ts +33 -9
- package/dist/drag.js +2 -2
- package/dist/gestures.d.ts +2 -2
- package/dist/gestures.js +6 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -6
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +2 -2
- package/dist/{paged-swipe-CIzjr2DQ.d.ts → paged-swipe-DIukqKlE.d.ts} +70 -1
- package/dist/{settle-7C9xxbFg.d.ts → settle-BvkDVDhE.d.ts} +39 -9
- package/dist/values.d.ts +8 -4
- package/dist/values.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ALYH6YQK.js.map +0 -1
- package/dist/chunk-K6TAWCGL.js.map +0 -1
- package/dist/chunk-NI7JLDWZ.js.map +0 -1
- package/dist/chunk-RWDYRT3H.js.map +0 -1
- package/dist/chunk-ZHDCLM3J.js.map +0 -1
- /package/dist/{chunk-5EMLVHP3.js.map → chunk-ZVFIWSC4.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,59 @@ within the month), the same scheme as `@n-uf/hypr-tiling`.
|
|
|
5
5
|
|
|
6
6
|
Unreleased entries live in `changes/` until a release joins them.
|
|
7
7
|
|
|
8
|
+
## 26.12.0
|
|
9
|
+
|
|
10
|
+
- A paged swipe's `settling` state now has `releaseVelocity`: how fast the swipe was moving when it ended, in px per ms
|
|
11
|
+
(like `peak` and `commitVelocity`), positive towards `next` like `travel`. A value's velocity is per second, so pass
|
|
12
|
+
`releaseVelocity * 1000`; if you draw the page at `-travel`, pass `-releaseVelocity * 1000`, as in
|
|
13
|
+
`page.set(target, { velocity: -state.releaseVelocity * 1000 })`.
|
|
14
|
+
- It is the travel over the swipe's last `releaseWindow` ms (new, default 50), and a span between the first and last
|
|
15
|
+
sample read that is shorter than 16 ms counts as 16 ms. Samples less than 1 ms apart count once, a sample stamped earlier than the one before it is left out, and at
|
|
16
|
+
most the newest 64 are read. It is 0 when the pointer stood still for `flickRest` before the end; a wheel run ends
|
|
17
|
+
`idle` after its last sample, so with the default timings it ends at 0. It is also 0 when the swipe gives way to
|
|
18
|
+
something else (`block`, `scrolled`, `cancel`).
|
|
19
|
+
- `tracking` and `settling` keep the samples as `samples`. The new `releaseVelocity(samples, endedAt, { lookback, rest })`
|
|
20
|
+
is the same rule for any gesture that ends in a throw (`lookback`: the window, in ms), and the state's field is that
|
|
21
|
+
function on the state's own samples. If you draw the page as some other function of `travel`, map each sample's
|
|
22
|
+
`travel` through it and call `releaseVelocity` on the result: you get the speed of what you draw. Also `RELEASE_RULE` (50 and 100 ms) and the types
|
|
23
|
+
`ReleaseSample` and `ReleaseRule`.
|
|
24
|
+
- The new fields are optional, so states and configs written before them still compile; the reducer always sets
|
|
25
|
+
`samples` and `releaseVelocity`.
|
|
26
|
+
- **Changed (breaking, behavior):** every settle now takes a velocity that is not a finite number as 0. NaN used to make the value NaN, and an infinite
|
|
27
|
+
velocity away from the target made it infinite; an infinite velocity toward the target, which was capped at the
|
|
28
|
+
launch speed, is 0 now too.
|
|
29
|
+
- A settle can be kept between two values: `within: { min, max }` in its config, in `settleValue`'s options and in
|
|
30
|
+
`configure`. It limits how far a set velocity can carry the value: with the value and the target inside `min`…`max`,
|
|
31
|
+
the value never leaves. It doesn't move the value or the target, and a target outside is still reached. It works per
|
|
32
|
+
component, in the value's shape; `-Infinity` or `Infinity` leaves a side open. The range's type is `SettleRange`, and a
|
|
33
|
+
range with `min` above `max`, a NaN side, a `min` of `Infinity` or a `max` of `-Infinity` throws a `RangeError`.
|
|
34
|
+
- A settle never passes its target, but a speed set away from the target (`setVelocity`, or `set(target, { velocity })`)
|
|
35
|
+
makes the value go on, stop and come back. With `within`, that speed is lowered just enough for the value to stop
|
|
36
|
+
before the bound; a value already at the bound starts from rest. A speed toward the target, a new target, reduced
|
|
37
|
+
motion (the value goes to the target at once) and a settle without `within` work as before. Clearing `within` later
|
|
38
|
+
doesn't give back a speed it lowered. `Settle.within` reads the range back.
|
|
39
|
+
- `SettleConfig` takes the value's type as an optional parameter (`SettleConfig<number>`, `SettleConfig<Rect>`). A plain
|
|
40
|
+
`SettleConfig` has no range, so code that creates, configures or drives a settle compiles as it is. A class or a test
|
|
41
|
+
double that implements the `Settle` interface itself gains the `within` member to add.
|
|
42
|
+
|
|
43
|
+
## 26.11.64
|
|
44
|
+
|
|
45
|
+
- The landing model: no distance that reaches into a lane is more than a third of that lane's thickness. A new optional
|
|
46
|
+
margin, `laneShare` (a third in `LANDING_MARGINS` and `LANDING_TOUCH_MARGINS`), caps the depth gate
|
|
47
|
+
(`min(depth, laneShare × thickness)`) and the held lane's exit margin into a lane that touches it
|
|
48
|
+
(`min(exit, laneShare × thickness)`, the other lane's thickness). A toolbar resting at the middle of a 24 px title bar
|
|
49
|
+
now enters it and shows its guide there, where the 12 px hold used to keep it in the strip below. Lanes of 36 px or
|
|
50
|
+
more (48 with the touch margins) keep the 12 px hold, and lanes of 24 px or more the 8 px depth; a lane that doesn't
|
|
51
|
+
touch the held one, open space and the far refusal keep the full `exit`. At a corner the thinnest touching lane's third
|
|
52
|
+
sets the margin, and each touching lane is entered only by its own gate. A place that takes nothing gets the same cap:
|
|
53
|
+
where no touching lane lies under the pointer, the hold reaches at most a third into a blocked or refused rect that
|
|
54
|
+
touches the held lane (its thickness the way the pointer reaches into it: across a bar beside the held lane, along a
|
|
55
|
+
rect past its end), so a full title bar, which is no lane, shows "Can't go here" from its middle third on; such a rect
|
|
56
|
+
that doesn't touch the held lane keeps the full `exit`. Between two columns with a gutter that takes nothing, the
|
|
57
|
+
column you leave lets go a third into the gutter (4 px of a 12 px gutter), and once the pointer has been seen there, a
|
|
58
|
+
release before the next column is entered goes home instead of floating at the pointer (a step that jumps the whole
|
|
59
|
+
gutter between two frames floats as before). The cap only lets go sooner. A share that isn't a positive number takes the default.
|
|
60
|
+
|
|
8
61
|
## 26.11.63
|
|
9
62
|
|
|
10
63
|
- The paged swipe takes the rules a finger needs. A `touch-start` marked `claimed` (the system's screen edge, content that keeps its gestures) never arms. A new `scrolled` input takes a finger's swipe in progress, and a finger that goes down within `idle` of one never arms, so a flick that ran a scroll to its end doesn't page on the next flick. A finger that rested `flickRest` (new, 100 ms) before lifting is no flick. With `band` (new, off by default) a finger also tracks towards a side with no page, at progress 0, never committing there, and the new `rubberBand(over, size, strength?)` gives the distance to draw. `PagedSwipeContext` gains `scrolledAt`.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ClockPort, T as TimerSource } from './port-CmlUctqx.js';
|
|
2
2
|
import { R as Rect } from './shapes-EbQlwbCu.js';
|
|
3
3
|
import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion-sElR1A_c.js';
|
|
4
|
-
import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-
|
|
4
|
+
import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-DIukqKlE.js';
|
|
5
5
|
import './frame-loop-f0V4b464.js';
|
|
6
6
|
import './reveal-Dg5fqoWS.js';
|
|
7
7
|
import './keys-BpcrOp4S.js';
|
package/dist/browser.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
PAGED_SWIPE_DEFAULTS,
|
|
3
3
|
createPagedSwipe,
|
|
4
4
|
wheelDelta
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GDV76P2H.js";
|
|
6
6
|
import "./chunk-OOKRBVMB.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-TJC6AXFM.js";
|
|
8
8
|
|
|
9
9
|
// src/browser/browser-clock.ts
|
|
10
10
|
function createBrowserClock(options = {}) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DOUBLE_CLICK,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
SAME_SAMPLE,
|
|
4
|
+
isHeld,
|
|
5
|
+
sampleOrder
|
|
6
|
+
} from "./chunk-TJC6AXFM.js";
|
|
5
7
|
|
|
6
8
|
// src/drag/intent.ts
|
|
7
9
|
var DRAG_DEFAULTS = {
|
|
@@ -277,7 +279,6 @@ function createDragIntent(options) {
|
|
|
277
279
|
var HAND_SLOW_STEP = 3;
|
|
278
280
|
var HAND_SPEED = { span: 48, steps: 5, gap: 40, slowStep: HAND_SLOW_STEP, still: 20, carry: 0.5, fill: 2.5, accelerating: 1.5, gathering: 1.25 };
|
|
279
281
|
var FILL_MAX = 32;
|
|
280
|
-
var SAME_SAMPLE = 1;
|
|
281
282
|
function createHandSpeed(options = {}) {
|
|
282
283
|
const o = { ...HAND_SPEED, ...options };
|
|
283
284
|
let samples = [];
|
|
@@ -325,7 +326,7 @@ function createHandSpeed(options = {}) {
|
|
|
325
326
|
return;
|
|
326
327
|
}
|
|
327
328
|
const dt = t - last.t;
|
|
328
|
-
if (
|
|
329
|
+
if (sampleOrder(last.t, t) !== "next") {
|
|
329
330
|
if (dt > -Math.max(o.gap, SAME_SAMPLE)) return;
|
|
330
331
|
if (behind === null || t < behind) behind = t;
|
|
331
332
|
if (t - behind < Math.max(o.still, SAME_SAMPLE)) return;
|
|
@@ -412,8 +413,23 @@ function planOf(mode, shown, room, slotted) {
|
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
// src/drag/landing.ts
|
|
415
|
-
var
|
|
416
|
-
var
|
|
416
|
+
var LANE_SHARE = 1 / 3;
|
|
417
|
+
var LANDING_MARGINS = { exit: 12, spot: 6, edge: 48, lift: 16, laneShare: LANE_SHARE };
|
|
418
|
+
var LANDING_TOUCH_MARGINS = { exit: 16, spot: 8, edge: 48, lift: 16, laneShare: LANE_SHARE };
|
|
419
|
+
function intoRect(rect, axis, px, share) {
|
|
420
|
+
return capBy(axis === "x" ? rect.height : rect.width, px, share);
|
|
421
|
+
}
|
|
422
|
+
function capBy(t, px, share) {
|
|
423
|
+
if (!(t > 0) || share === Infinity) return px;
|
|
424
|
+
return Math.min(px, t / (1 / share));
|
|
425
|
+
}
|
|
426
|
+
function reachInto(rect, from, p, px, share) {
|
|
427
|
+
let m = px;
|
|
428
|
+
if (p.x < from.x || p.x > from.x + from.width) m = capBy(rect.width, m, share);
|
|
429
|
+
if (p.y < from.y || p.y > from.y + from.height) m = capBy(rect.height, m, share);
|
|
430
|
+
return m;
|
|
431
|
+
}
|
|
432
|
+
var intoLane = (lane, px, share) => intoRect(lane.rect, lane.axis, px, share);
|
|
417
433
|
var LANDING_GATES = { path: 40, depth: 8, stillSpeed: 0.1875, stepSpeed: 0.375, trail: 40, rest: 22, pause: 60, slideSpeed: 2 };
|
|
418
434
|
var LANDING_APPROACH = { reach: LANDING_MARGINS.exit, keep: LANDING_MARGINS.exit, nearer: 16 };
|
|
419
435
|
var LANDING_MODIFIERS = { on: DRAG_DEFAULTS.modifiers.on, floatKey: DRAG_DEFAULTS.modifiers.floatKey };
|
|
@@ -442,6 +458,7 @@ function ontoStage(stage, p, reach) {
|
|
|
442
458
|
function createLandingModel(options) {
|
|
443
459
|
const margins = { ...LANDING_MARGINS, ...options.margins };
|
|
444
460
|
const gates = { ...LANDING_GATES, ...options.gates };
|
|
461
|
+
const laneShare = typeof margins.laneShare === "number" && margins.laneShare > 0 ? margins.laneShare : LANE_SHARE;
|
|
445
462
|
const approach = { ...LANDING_APPROACH, ...options.approach };
|
|
446
463
|
const modifiers = { ...LANDING_MODIFIERS, ...options.modifiers };
|
|
447
464
|
const guidesLevel = guidesOf(options.preview ?? DRAG_PREVIEW_DEFAULT);
|
|
@@ -630,10 +647,16 @@ function createLandingModel(options) {
|
|
|
630
647
|
laneId = spotId = null;
|
|
631
648
|
} else {
|
|
632
649
|
const held2 = laneIn(regions, laneId);
|
|
633
|
-
const gate = (l) => (pathIn.get(l.id) ?? 0) >= gates.path || depthIn(l, p, regions.stage) >= gates.depth && step <= gates.stillSpeed && settled;
|
|
634
|
-
const
|
|
635
|
-
const
|
|
636
|
-
const
|
|
650
|
+
const gate = (l) => (pathIn.get(l.id) ?? 0) >= gates.path || depthIn(l, p, regions.stage) >= intoLane(l, gates.depth, laneShare) && step <= gates.stillSpeed && settled;
|
|
651
|
+
const touchingAll = held2 ? regions.lanes.filter((l) => l.id !== held2.id && strictlyIn(l.rect, p) && touches(l.rect, held2.rect)) : [];
|
|
652
|
+
const exitInto = touchingAll.reduce((m, l) => intoLane(l, m, laneShare), margins.exit);
|
|
653
|
+
const touchingHere = held2 && !inside(held2.rect, p, exitInto) ? touchingAll : [];
|
|
654
|
+
const touching = touchingHere[0];
|
|
655
|
+
const holdExit = held2 && touchingAll.length === 0 ? [...regions.blocked, ...regions.refused].filter((b) => strictlyIn(b, p) && touches(b, held2.rect)).reduce((m, b) => reachInto(b, held2.rect, p, m, laneShare), margins.exit) : margins.exit;
|
|
656
|
+
const slid = (l) => {
|
|
657
|
+
const sl = slide.get(l.id);
|
|
658
|
+
return !!sl && sl.along >= gates.path && sl.across * 3 <= sl.along && hand.speed <= gates.slideSpeed;
|
|
659
|
+
};
|
|
637
660
|
const liftR = margins.lift ?? 16;
|
|
638
661
|
if (liftAt) {
|
|
639
662
|
const far = Math.hypot(p.x - liftAt.x, p.y - liftAt.y);
|
|
@@ -646,14 +669,14 @@ function createLandingModel(options) {
|
|
|
646
669
|
const lanesHere = regions.lanes.filter((l) => strictlyIn(l.rect, p) && !(l.owns && nearLift));
|
|
647
670
|
const within2 = (b, l) => b.x >= l.rect.x - 1 && b.y >= l.rect.y - 1 && b.x + b.width <= l.rect.x + l.rect.width + 1 && b.y + b.height <= l.rect.y + l.rect.height + 1;
|
|
648
671
|
const overRefused = (l) => Number.isFinite(step) && step <= gates.stepSpeed && settled && lanesHere.length === 1 && [...regions.blocked, ...regions.refused].some((b) => strictlyIn(b, p) && !within2(b, l));
|
|
649
|
-
const next = homeHere ? void 0 : owner ?? (
|
|
650
|
-
if (!(held2 && !homeHere && !next && (touching || inside(held2.rect, p,
|
|
672
|
+
const next = homeHere ? void 0 : owner ?? touchingHere.find((l) => gate(l) || slid(l) || overRefused(l));
|
|
673
|
+
if (!(held2 && !homeHere && !next && (touching || inside(held2.rect, p, holdExit)))) farHeld = false;
|
|
651
674
|
if (homeHere) {
|
|
652
675
|
const s = spotIn(homeHere, options.home.spot) ?? pick(homeHere, alongOf(homeHere, p));
|
|
653
676
|
laneId = homeHere.id;
|
|
654
677
|
spotId = s?.id ?? null;
|
|
655
678
|
region = s ? "lane" : "refused";
|
|
656
|
-
} else if (held2 && !next && (touching || inside(held2.rect, p,
|
|
679
|
+
} else if (held2 && !next && (touching || inside(held2.rect, p, holdExit))) {
|
|
657
680
|
const d = distanceTo2(held2.rect, p);
|
|
658
681
|
farHeld = farHeld ? d > margins.exit + gates.path - margins.spot : d > margins.exit + gates.path;
|
|
659
682
|
const far = farHeld;
|
|
@@ -955,4 +978,4 @@ export {
|
|
|
955
978
|
MIN_BOX_LENGTH,
|
|
956
979
|
guideRects
|
|
957
980
|
};
|
|
958
|
-
//# sourceMappingURL=chunk-
|
|
981
|
+
//# sourceMappingURL=chunk-F5FNGVQT.js.map
|