@n-uf/motion 26.11.3 → 26.11.4

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/dist/layout.js ADDED
@@ -0,0 +1,312 @@
1
+ import {
2
+ SETTLE_TEMPO,
3
+ createSettle,
4
+ popIn,
5
+ reveal
6
+ } from "./chunk-WQQ2E25M.js";
7
+
8
+ // src/layout/motion.ts
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;
10
+ var copy = (r) => ({ x: r.x, y: r.y, width: r.width, height: r.height });
11
+ function createLayoutMotion(options) {
12
+ const { loop } = options;
13
+ const phase = options.phase ?? "layout";
14
+ const popFrom = options.popFrom ?? 0.87;
15
+ let omega = options.omega ?? SETTLE_TEMPO.default;
16
+ const items = /* @__PURE__ */ new Map();
17
+ const steps = /* @__PURE__ */ new Map();
18
+ const tasks = /* @__PURE__ */ new Set();
19
+ const frames = /* @__PURE__ */ new Set();
20
+ const idles = /* @__PURE__ */ new Set();
21
+ const tempos = /* @__PURE__ */ new Set();
22
+ const removers = /* @__PURE__ */ new Map();
23
+ let waiters = [];
24
+ let stop = null;
25
+ let woken = false;
26
+ const wake = () => {
27
+ woken = true;
28
+ if (stop) return;
29
+ stop = loop.repeat(phase, tick);
30
+ };
31
+ function tick(frame) {
32
+ let moving = woken;
33
+ woken = false;
34
+ for (const task of [...tasks]) if (task(frame)) moving = true;
35
+ for (const step of [...steps.values()]) if (step(frame.delta)) moving = true;
36
+ for (const listener of [...frames]) listener(frame);
37
+ if (moving || woken) return true;
38
+ stop = null;
39
+ const resolve = waiters;
40
+ waiters = [];
41
+ for (const r of resolve) r();
42
+ for (const listener of [...idles]) listener();
43
+ return false;
44
+ }
45
+ function add(id, drawable, at, opts = {}) {
46
+ if (items.has(id)) throw new Error(`layout motion: item "${id}" is already added (remove it first)`);
47
+ const rect = createSettle(copy(at), { omega });
48
+ const pop = createSettle(opts.shown === false ? 0 : 1, { omega, restDelta: 1e-3 });
49
+ let box = copy(at);
50
+ const frameOf = () => {
51
+ const drawn = rect.value;
52
+ return { drawn, box, reveal: reveal(drawn, box), pop: popIn(pop.value, popFrom), shown: pop.value, gone: pop.settled && pop.value === 0 };
53
+ };
54
+ const draw = () => drawable.draw(frameOf());
55
+ const layOut = (to) => {
56
+ box = copy(to);
57
+ drawable.layOut(box);
58
+ };
59
+ const tempo = () => {
60
+ rect.configure({ omega });
61
+ pop.configure({ omega });
62
+ };
63
+ const item = {
64
+ id,
65
+ get drawn() {
66
+ return rect.value;
67
+ },
68
+ get target() {
69
+ return rect.target;
70
+ },
71
+ get box() {
72
+ return box;
73
+ },
74
+ get settled() {
75
+ return rect.settled;
76
+ },
77
+ get shown() {
78
+ return pop.value;
79
+ },
80
+ get showing() {
81
+ return pop.target === 1;
82
+ },
83
+ get shownSettled() {
84
+ return pop.settled;
85
+ },
86
+ moveTo(to) {
87
+ if (same(box, to) && same(rect.target, to)) return;
88
+ layOut(to);
89
+ draw();
90
+ if (same(rect.target, to)) return;
91
+ rect.setTarget(copy(to));
92
+ wake();
93
+ },
94
+ jumpTo(to) {
95
+ layOut(to);
96
+ rect.jumpTo(copy(to));
97
+ draw();
98
+ },
99
+ glideFrom(from, to) {
100
+ rect.jumpTo(copy(from));
101
+ layOut(to);
102
+ draw();
103
+ rect.setTarget(copy(to));
104
+ wake();
105
+ },
106
+ hold(r) {
107
+ rect.hold(copy(r));
108
+ draw();
109
+ },
110
+ show(on, o = {}) {
111
+ const want = on ? 1 : 0;
112
+ if (o.now) pop.jumpTo(want);
113
+ else if (pop.target !== want) {
114
+ pop.setTarget(want);
115
+ wake();
116
+ }
117
+ draw();
118
+ },
119
+ redraw: draw
120
+ };
121
+ drawable.layOut(box);
122
+ draw();
123
+ items.set(id, item);
124
+ tempos.add(tempo);
125
+ steps.set(id, (dt) => {
126
+ const a = rect.step(dt);
127
+ const b = pop.step(dt);
128
+ draw();
129
+ return a || b;
130
+ });
131
+ removers.set(id, () => tempos.delete(tempo));
132
+ return item;
133
+ }
134
+ return {
135
+ add,
136
+ get: (id) => items.get(id),
137
+ remove(id) {
138
+ items.delete(id);
139
+ steps.delete(id);
140
+ removers.get(id)?.();
141
+ removers.delete(id);
142
+ },
143
+ items,
144
+ task(task) {
145
+ tasks.add(task);
146
+ wake();
147
+ return () => tasks.delete(task);
148
+ },
149
+ onFrame(listener) {
150
+ frames.add(listener);
151
+ return () => frames.delete(listener);
152
+ },
153
+ onIdle(listener) {
154
+ idles.add(listener);
155
+ return () => idles.delete(listener);
156
+ },
157
+ wake,
158
+ get running() {
159
+ return stop !== null;
160
+ },
161
+ configure(config) {
162
+ if (config.omega !== void 0) omega = config.omega;
163
+ for (const t of tempos) t();
164
+ },
165
+ idle: () => stop ? new Promise((r) => waiters.push(r)) : Promise.resolve(),
166
+ dispose() {
167
+ stop?.();
168
+ stop = null;
169
+ items.clear();
170
+ steps.clear();
171
+ tasks.clear();
172
+ frames.clear();
173
+ idles.clear();
174
+ tempos.clear();
175
+ removers.clear();
176
+ const resolve = waiters;
177
+ waiters = [];
178
+ for (const r of resolve) r();
179
+ }
180
+ };
181
+ }
182
+
183
+ // src/layout/held.ts
184
+ var CAUGHT = 0.5;
185
+ function holdItem(item, grab) {
186
+ let size = { width: item.drawn.width, height: item.drawn.height };
187
+ let at = { x: grab.x, y: grab.y };
188
+ let pointer = null;
189
+ let snapped = null;
190
+ let returning = false;
191
+ const heldRect = () => pointer ? { x: pointer.x - at.x, y: pointer.y - at.y, width: size.width, height: size.height } : null;
192
+ const same2 = (a, b) => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.01;
193
+ const snapTo = (slot) => {
194
+ if (slot) {
195
+ if (snapped && same2(snapped, slot)) return null;
196
+ snapped = { ...slot };
197
+ returning = false;
198
+ item.moveTo(slot);
199
+ return "snapped";
200
+ }
201
+ if (!snapped) return null;
202
+ snapped = null;
203
+ returning = true;
204
+ return "left";
205
+ };
206
+ const follow = () => {
207
+ const goal = heldRect();
208
+ if (!returning || !goal) return false;
209
+ item.moveTo(goal);
210
+ const d = item.drawn;
211
+ if (Math.max(Math.abs(d.x - goal.x), Math.abs(d.y - goal.y), Math.abs(d.width - goal.width), Math.abs(d.height - goal.height)) >= CAUGHT) return false;
212
+ returning = false;
213
+ item.hold(goal);
214
+ return true;
215
+ };
216
+ const letGo = (to) => {
217
+ const release = { ...item.drawn };
218
+ snapped = null;
219
+ returning = false;
220
+ item.moveTo(to);
221
+ return release;
222
+ };
223
+ return {
224
+ get pointer() {
225
+ return pointer;
226
+ },
227
+ get held() {
228
+ return heldRect();
229
+ },
230
+ get snapped() {
231
+ return snapped;
232
+ },
233
+ get returning() {
234
+ return returning;
235
+ },
236
+ move(p) {
237
+ pointer = { x: p.x, y: p.y };
238
+ if (snapped || returning) return;
239
+ item.hold(heldRect());
240
+ },
241
+ snapTo,
242
+ follow,
243
+ preview(plan, slot) {
244
+ const change = snapTo(plan.snapItem && slot ? slot : null);
245
+ follow();
246
+ return change;
247
+ },
248
+ resize(next) {
249
+ if (Math.abs(next.width - size.width) < 0.01 && Math.abs(next.height - size.height) < 0.01) return false;
250
+ at = { x: size.width ? at.x / size.width * next.width : 0, y: size.height ? at.y / size.height * next.height : 0 };
251
+ size = { width: next.width, height: next.height };
252
+ if (!snapped && pointer) {
253
+ returning = true;
254
+ follow();
255
+ }
256
+ return true;
257
+ },
258
+ land: letGo,
259
+ cancel: letGo
260
+ };
261
+ }
262
+
263
+ // src/layout/flip.ts
264
+ var rectOf = (r) => ({ x: r.left, y: r.top, width: r.width, height: r.height });
265
+ function flip(entries, change) {
266
+ const before = entries.map((e) => rectOf(e.node.getBoundingClientRect()));
267
+ change();
268
+ entries.forEach((e, i) => {
269
+ const { from, to } = e.place(before[i]);
270
+ e.item.glideFrom(from, to);
271
+ });
272
+ }
273
+
274
+ // src/layout/dom.ts
275
+ function layOutBox(node, box) {
276
+ const s = node.style;
277
+ s.left = `${box.x}px`;
278
+ s.top = `${box.y}px`;
279
+ s.width = `${box.width}px`;
280
+ s.height = `${box.height}px`;
281
+ }
282
+ function drawBox(nodes, frame) {
283
+ const { reveal: r, pop } = frame;
284
+ const cx = frame.drawn.width / 2;
285
+ const cy = frame.drawn.height / 2;
286
+ const s = nodes.node.style;
287
+ s.transform = pop.scale === 1 ? `translate(${r.dx}px, ${r.dy}px)` : `translate(${r.dx}px, ${r.dy}px) translate(${cx}px, ${cy}px) scale(${pop.scale}) translate(${-cx}px, ${-cy}px)`;
288
+ s.opacity = pop.opacity === 1 ? "" : String(pop.opacity);
289
+ if (nodes.frame) {
290
+ nodes.frame.style.width = `${r.width}px`;
291
+ nodes.frame.style.height = `${r.height}px`;
292
+ }
293
+ const clipped = nodes.content ?? (nodes.frame ? null : nodes.node);
294
+ if (clipped) clipped.style.clipPath = r.clipRight || r.clipBottom ? `inset(0 ${r.clipRight}px ${r.clipBottom}px 0)` : "";
295
+ s.visibility = frame.gone ? "hidden" : "";
296
+ }
297
+ function domDrawable(nodes) {
298
+ return {
299
+ layOut: (box) => layOutBox(nodes.node, box),
300
+ draw: (frame) => drawBox(nodes, frame)
301
+ };
302
+ }
303
+ export {
304
+ createLayoutMotion,
305
+ domDrawable,
306
+ drawBox,
307
+ flip,
308
+ holdItem,
309
+ layOutBox,
310
+ rectOf
311
+ };
312
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/layout/motion.ts","../src/layout/held.ts","../src/layout/flip.ts","../src/layout/dom.ts"],"sourcesContent":["import type { FrameInfo, FrameLoop, Phase } from \"../clock/frame-loop\";\nimport type { Rect } from \"../shapes\";\nimport { popIn, reveal, type PopIn, type RevealFrame } from \"../values/reveal\";\nimport { createSettle, SETTLE_TEMPO, type Settle } from \"../values/settle\";\n\n/**\n * What a {@link Drawable} draws on a frame: where the item is drawn, the box its content is laid out in, how to draw\n * the one at the other without stretching ({@link reveal}), and its appearance ({@link popIn}).\n */\nexport interface DrawFrame {\n /** Where the item is drawn this frame (its frame: background, border, shadow). */\n readonly drawn: Rect;\n /** The box its content is laid out in: where it is heading, or (held) where it was laid out last. */\n readonly box: Rect;\n /** How to draw `box`'s content at `drawn`: a move, the frame at the drawn size, the content clipped. */\n readonly reveal: RevealFrame;\n /** Its uniform appearance: scale about its centre and opacity. */\n readonly pop: PopIn;\n /** How shown it is, 0 (gone) to 1. */\n readonly shown: number;\n /** All the way gone: hidden and at rest (out of sight and out of the way of the pointer). */\n readonly gone: boolean;\n}\n\n/**\n * How an item reaches the screen. The layout motion never measures or touches anything itself: it lays an item's\n * content out once per new box and draws it once per frame through this. {@link domDrawable} writes an element's\n * style; a canvas or a test can draw anything else.\n */\nexport interface Drawable {\n /** Lay the content out in `box` (its position and size): called once per new box, never per frame. */\n layOut(box: Rect): void;\n /** Draw the item for this frame. */\n draw(frame: DrawFrame): void;\n}\n\n/**\n * One item the layout motion moves: give it a new place and it settles there from wherever it is drawn.\n *\n * - {@link LayoutItem.moveTo}: a settle to the new place, retargeted from the drawn rect (no jump, no overshoot);\n * the content is laid out at the new box at once and the item redrawn at once, so no frame shows the old offset\n * from the new box.\n * - A size change is revealed: the content is laid out at the target size and the frame clipped, never scaled.\n * - {@link LayoutItem.show}: appear or disappear with a uniform-scale fade.\n */\nexport interface LayoutItem {\n readonly id: string;\n /** Where it is drawn now. */\n readonly drawn: Rect;\n /** Where it is heading (its settle's target). */\n readonly target: Rect;\n /** The box its content is laid out in. */\n readonly box: Rect;\n /** At rest on its target. */\n readonly settled: boolean;\n /** How shown it is, 0 to 1, and whether it is heading for shown. */\n readonly shown: number;\n readonly showing: boolean;\n /** Its appearance is at rest (fully shown, or gone). */\n readonly shownSettled: boolean;\n /** Settle to `to` from where it is drawn; lays the content out at `to` and redraws at once. */\n moveTo(to: Rect): void;\n /** Be at `to` now, at rest: no glide. */\n jumpTo(to: Rect): void;\n /** Drawn at `from` now, then settle to `to` (a FLIP's invert and play: `from` in the item's own coordinates). */\n glideFrom(from: Rect, to: Rect): void;\n /** Exactly at `r`, at rest (what a pointer holds); the content stays laid out in its box, moved with it. */\n hold(r: Rect): void;\n /** Appear (true) or disappear (false) with a uniform-scale fade; `now`: without the fade. */\n show(on: boolean, options?: { readonly now?: boolean }): void;\n /** Draw it again now (after its drawable's element was laid out anew from outside). */\n redraw(): void;\n}\n\n/** A task the layout motion runs on every frame before it steps the items; true keeps the frames coming. */\nexport type LayoutTask = (frame: FrameInfo) => boolean | void;\n\nexport interface LayoutMotionOptions {\n /** The frame loop every item steps on (one loop for all of them). */\n readonly loop: FrameLoop;\n /** The settle tempo, per second ({@link SETTLE_TEMPO}); default `SETTLE_TEMPO.default`. */\n readonly omega?: number;\n /** The frame phase the items step and draw in; default `\"layout\"`. */\n readonly phase?: Phase;\n /** Where an appearing item grows from, as a share of its size ({@link popIn}'s `from`); default 0.87. */\n readonly popFrom?: number;\n}\n\n/**\n * Layout motion: items with an id and a target rect, each settled to its place on one shared frame loop.\n *\n * Give an item a new place ({@link LayoutItem.moveTo}) and it glides there from wherever it is drawn: the window\n * motion rules of `values/` (settle, reveal, popIn) applied to every item at once. The loop runs only while\n * something moves, or a task asks for frames, and stops by itself.\n *\n * It only animates the rects it is given: which items move where, and when, is the caller's layout.\n */\nexport interface LayoutMotion {\n /** Add an item drawn by `drawable`, at `at`, shown (or gone: `{ shown: false }`). Its content is laid out at once. */\n add(id: string, drawable: Drawable, at: Rect, options?: { readonly shown?: boolean }): LayoutItem;\n get(id: string): LayoutItem | undefined;\n /** Stop moving an item (its drawable is not touched again). */\n remove(id: string): void;\n readonly items: ReadonlyMap<string, LayoutItem>;\n /** Run `task` on every frame, before the items step; returns how to stop it. */\n task(task: LayoutTask): () => void;\n /** Call `listener` on every frame, after the items have stepped and been drawn; returns how to stop it. */\n onFrame(listener: (frame: FrameInfo) => void): () => void;\n /** Call `listener` each time the frames stop (nothing moves); returns how to stop it. */\n onIdle(listener: () => void): () => void;\n /** Make sure at least one more frame runs (a task has something to do). */\n wake(): void;\n /** Frames are running. */\n readonly running: boolean;\n /** Set the tempo for every item (and the ones added later). */\n configure(config: { readonly omega?: number }): void;\n /** Resolves once nothing moves (at once if nothing does). */\n idle(): Promise<void>;\n /** Stop the frames and forget every item. */\n dispose(): void;\n}\n\n/** Two rects the same within a hundredth of a pixel. */\nconst same = (a: Rect, b: Rect): boolean =>\n 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;\nconst copy = (r: Rect): Rect => ({ x: r.x, y: r.y, width: r.width, height: r.height });\n\n/** Create the {@link LayoutMotion} for one surface. */\nexport function createLayoutMotion(options: LayoutMotionOptions): LayoutMotion {\n const { loop } = options;\n const phase = options.phase ?? \"layout\";\n const popFrom = options.popFrom ?? 0.87;\n let omega = options.omega ?? SETTLE_TEMPO.default;\n const items = new Map<string, LayoutItem>();\n const steps = new Map<string, (dt: number) => boolean>();\n const tasks = new Set<LayoutTask>();\n const frames = new Set<(frame: FrameInfo) => void>();\n const idles = new Set<() => void>();\n const tempos = new Set<() => void>();\n /** What removing an item undoes besides its entry (its tempo hook). */\n const removers = new Map<string, () => void>();\n let waiters: (() => void)[] = [];\n let stop: (() => void) | null = null;\n let woken = false;\n\n const wake = (): void => {\n woken = true;\n if (stop) return;\n stop = loop.repeat(phase, tick);\n };\n\n function tick(frame: FrameInfo): boolean {\n let moving = woken;\n woken = false;\n for (const task of [...tasks]) if (task(frame)) moving = true;\n for (const step of [...steps.values()]) if (step(frame.delta)) moving = true;\n for (const listener of [...frames]) listener(frame);\n if (moving || woken) return true;\n stop = null;\n const resolve = waiters;\n waiters = [];\n for (const r of resolve) r();\n for (const listener of [...idles]) listener();\n return false;\n }\n\n function add(id: string, drawable: Drawable, at: Rect, opts: { readonly shown?: boolean } = {}): LayoutItem {\n if (items.has(id)) throw new Error(`layout motion: item \"${id}\" is already added (remove it first)`);\n const rect: Settle<Rect> = createSettle<Rect>(copy(at), { omega });\n // A number from 0 to 1: rest within a thousandth, not the default tenth (tuned for pixels).\n const pop: Settle<number> = createSettle(opts.shown === false ? 0 : 1, { omega, restDelta: 0.001 });\n let box = copy(at);\n const frameOf = (): DrawFrame => {\n const drawn = rect.value;\n return { drawn, box, reveal: reveal(drawn, box), pop: popIn(pop.value, popFrom), shown: pop.value, gone: pop.settled && pop.value === 0 };\n };\n const draw = (): void => drawable.draw(frameOf());\n const layOut = (to: Rect): void => {\n box = copy(to);\n drawable.layOut(box);\n };\n const tempo = (): void => {\n rect.configure({ omega });\n pop.configure({ omega });\n };\n const item: LayoutItem = {\n id,\n get drawn() {\n return rect.value;\n },\n get target() {\n return rect.target;\n },\n get box() {\n return box;\n },\n get settled() {\n return rect.settled;\n },\n get shown() {\n return pop.value;\n },\n get showing() {\n return pop.target === 1;\n },\n get shownSettled() {\n return pop.settled;\n },\n moveTo(to) {\n if (same(box, to) && same(rect.target, to)) return;\n layOut(to);\n // Laid out in the new box now: draw it at once at the drawn rect, else until the next frame it would show\n // the old offset from the new box (a dropped item would flash a frame away from where it was let go).\n draw();\n if (same(rect.target, to)) return;\n rect.setTarget(copy(to));\n wake();\n },\n jumpTo(to) {\n layOut(to);\n rect.jumpTo(copy(to));\n draw();\n },\n glideFrom(from, to) {\n rect.jumpTo(copy(from));\n layOut(to);\n draw();\n rect.setTarget(copy(to));\n wake();\n },\n hold(r) {\n rect.hold(copy(r));\n draw();\n },\n show(on, o = {}) {\n const want = on ? 1 : 0;\n if (o.now) pop.jumpTo(want);\n else if (pop.target !== want) {\n pop.setTarget(want);\n wake();\n }\n draw();\n },\n redraw: draw,\n };\n drawable.layOut(box);\n draw();\n items.set(id, item);\n tempos.add(tempo);\n steps.set(id, (dt) => {\n const a = rect.step(dt);\n const b = pop.step(dt);\n draw();\n return a || b;\n });\n removers.set(id, () => tempos.delete(tempo));\n return item;\n }\n\n return {\n add,\n get: (id) => items.get(id),\n remove(id) {\n items.delete(id);\n steps.delete(id);\n removers.get(id)?.();\n removers.delete(id);\n },\n items,\n task(task) {\n tasks.add(task);\n wake();\n return () => tasks.delete(task);\n },\n onFrame(listener) {\n frames.add(listener);\n return () => frames.delete(listener);\n },\n onIdle(listener) {\n idles.add(listener);\n return () => idles.delete(listener);\n },\n wake,\n get running() {\n return stop !== null;\n },\n configure(config) {\n if (config.omega !== undefined) omega = config.omega;\n for (const t of tempos) t();\n },\n idle: () => (stop ? new Promise<void>((r) => waiters.push(r)) : Promise.resolve()),\n dispose() {\n stop?.();\n stop = null;\n items.clear();\n steps.clear();\n tasks.clear();\n frames.clear();\n idles.clear();\n tempos.clear();\n removers.clear();\n const resolve = waiters;\n waiters = [];\n for (const r of resolve) r();\n },\n };\n}\n","import type { Point, Rect } from \"../shapes\";\nimport type { LayoutItem } from \"./motion\";\n\n/**\n * An item held by a pointer: the real item (no copy) follows the pointer 1:1 from where it was grabbed, at the size\n * it was lifted at; its place stays reserved (that is the caller's layout). Then:\n *\n * - {@link HeldDrag.snapTo}: glide into a slot (a snap preview); `null` leaves the slot and glides back to the\n * pointer, following it as it moves ({@link HeldDrag.follow} once a frame), until it is under it again.\n * - {@link HeldDrag.land}: let go into a slot: the landing settles from where it was let go (the release rect), never\n * from its old home. Snapped into that slot already, it simply finishes that glide.\n * - {@link HeldDrag.cancel}: let go with no drop: it glides home from where it was let go.\n * - {@link HeldDrag.preview}: the three drop previews, per frame: indicator and gap keep the item under the pointer\n * (gap with the caller's room open), snap glides it into the slot; leaving glides it back to the pointer.\n * - {@link HeldDrag.resize}: the item takes a new size mid-drag (its content laid out anew by the caller): it settles\n * to it from where it is drawn, the size revealed (never stretched), and is held 1:1 again once there.\n */\nexport interface HeldDrag {\n /** Where the pointer is (null before the first move). */\n readonly pointer: Point | null;\n /** Where the pointer holds the item: the pointer less the grab offset, at the held size (lifted, or resized). */\n readonly held: Rect | null;\n /** The slot it sits in (a snap), or null. */\n readonly snapped: Rect | null;\n /** It left a slot (or took a new size) and is gliding back to the pointer. */\n readonly returning: boolean;\n /** The pointer moved: held 1:1 (unless it sits in a slot or is on its way back). */\n move(pointer: Point): void;\n /**\n * Into `slot` (a glide from where it is drawn; the same slot again does nothing), or out of the slot it sits in\n * (`null`: back to the pointer). Returns what changed: `\"snapped\"`, `\"left\"`, or null.\n */\n snapTo(slot: Rect | null): \"snapped\" | \"left\" | null;\n /** Once a frame: on its way back, retarget to the pointer; true on the frame it is under the pointer again. */\n follow(): boolean;\n /**\n * Once a frame, a drop preview's part for the item (`plan`: `@n-uf/motion/drag`'s `previewPlan`, or any\n * `{ snapItem }`): with `snapItem` it glides into `slot` (snap); else it stays under the pointer, or glides back to\n * it from a slot it left (indicator, gap). The room, if the plan makes any, is the caller's layout. In place of\n * {@link HeldDrag.snapTo} and {@link HeldDrag.follow}; returns what changed.\n */\n preview(plan: { readonly snapItem: boolean }, slot: Rect | null): \"snapped\" | \"left\" | null;\n /**\n * Hold it at `size` from now on (the caller has laid its content out for that size). The grab point keeps its share\n * of the item, so the pointer stays on the same spot of it; the item settles from where it is drawn to its new held\n * rect (its size revealed, never stretched), then is held 1:1 again ({@link HeldDrag.follow} once a frame). In a\n * slot it stays there, taking the new size when it leaves. The same size again does nothing; returns true on a\n * change.\n */\n resize(size: { readonly width: number; readonly height: number }): boolean;\n /** Let go into `slot`: returns the release rect, where the landing starts. */\n land(slot: Rect): Rect;\n /** Let go with no drop: glides `home` from the release rect, which it returns. */\n cancel(home: Rect): Rect;\n}\n\n/** How close (px, every component) the way back has to come to count as under the pointer again. */\nconst CAUGHT = 0.5;\n\n/** Hold `item` from the pointer at `grab` (the pointer's offset from its top-left corner), at its drawn size now. */\nexport function holdItem(item: LayoutItem, grab: Point): HeldDrag {\n let size = { width: item.drawn.width, height: item.drawn.height };\n let at = { x: grab.x, y: grab.y };\n let pointer: Point | null = null;\n let snapped: Rect | null = null;\n let returning = false;\n const heldRect = (): Rect | null => (pointer ? { x: pointer.x - at.x, y: pointer.y - at.y, width: size.width, height: size.height } : null);\n const same = (a: Rect, b: Rect): boolean => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.01;\n const snapTo = (slot: Rect | null): \"snapped\" | \"left\" | null => {\n if (slot) {\n if (snapped && same(snapped, slot)) return null;\n snapped = { ...slot };\n returning = false;\n item.moveTo(slot);\n return \"snapped\";\n }\n if (!snapped) return null;\n snapped = null;\n returning = true;\n return \"left\";\n };\n const follow = (): boolean => {\n const goal = heldRect();\n if (!returning || !goal) return false;\n item.moveTo(goal);\n const d = item.drawn;\n if (Math.max(Math.abs(d.x - goal.x), Math.abs(d.y - goal.y), Math.abs(d.width - goal.width), Math.abs(d.height - goal.height)) >= CAUGHT) return false;\n returning = false;\n item.hold(goal);\n return true;\n };\n const letGo = (to: Rect): Rect => {\n const release = { ...item.drawn };\n snapped = null;\n returning = false;\n item.moveTo(to);\n return release;\n };\n return {\n get pointer() {\n return pointer;\n },\n get held() {\n return heldRect();\n },\n get snapped() {\n return snapped;\n },\n get returning() {\n return returning;\n },\n move(p) {\n pointer = { x: p.x, y: p.y };\n if (snapped || returning) return;\n item.hold(heldRect()!);\n },\n snapTo,\n follow,\n preview(plan, slot) {\n const change = snapTo(plan.snapItem && slot ? slot : null);\n follow();\n return change;\n },\n resize(next) {\n if (Math.abs(next.width - size.width) < 0.01 && Math.abs(next.height - size.height) < 0.01) return false;\n at = { x: size.width ? (at.x / size.width) * next.width : 0, y: size.height ? (at.y / size.height) * next.height : 0 };\n size = { width: next.width, height: next.height };\n if (!snapped && pointer) {\n returning = true;\n follow();\n }\n return true;\n },\n land: letGo,\n cancel: letGo,\n };\n}\n","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"./motion\";\n\n/** A rect as a DOM rect reports it (`getBoundingClientRect()`): left, top, width, height. */\nexport interface RectLike {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Anything that can say where it is drawn: a DOM node, or a test's stand-in. */\nexport interface Measurable {\n getBoundingClientRect(): RectLike;\n}\n\n/** A {@link RectLike} as a {@link Rect}. */\nexport const rectOf = (r: RectLike): Rect => ({ x: r.left, y: r.top, width: r.width, height: r.height });\n\n/** One member of a {@link flip}: an item, the node it draws, and where it goes once the DOM has changed. */\nexport interface FlipEntry {\n readonly item: LayoutItem;\n readonly node: Measurable;\n /**\n * Once the DOM has changed: the old rect (as measured before, in page coordinates) in the item's own coordinates\n * now, and its new place there.\n */\n readonly place: (before: Rect) => { readonly from: Rect; readonly to: Rect };\n}\n\n/**\n * FLIP for DOM groups, on settle: record where each node is drawn (first), change the DOM (`change`: move nodes to\n * other parents, reorder them), then each item is drawn at its old rect and settles to its new place (last, invert,\n * play). No transform tween: a settle from the rect it was drawn at, so it never jumps or overshoots, and its size\n * changes through reveal.\n */\nexport function flip(entries: readonly FlipEntry[], change: () => void): void {\n const before = entries.map((e) => rectOf(e.node.getBoundingClientRect()));\n change();\n entries.forEach((e, i) => {\n const { from, to } = e.place(before[i]!);\n e.item.glideFrom(from, to);\n });\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"./motion\";\n\n/**\n * The style properties the layout motion writes, as strings (a DOM node's `style` has them all). Structural: the\n * library needs no DOM types.\n */\nexport interface StyleLike {\n left: string;\n top: string;\n width: string;\n height: string;\n transform: string;\n opacity: string;\n clipPath: string;\n visibility: string;\n}\n\n/** Something with a writable {@link StyleLike} `style`: a DOM node. */\nexport interface Styled {\n readonly style: StyleLike;\n}\n\n/**\n * The nodes of a drawn box: `node` is laid out at the box and moved to the drawn rect; `frame` (background, border,\n * shadow) is drawn at the drawn size; `content` is clipped to it. With no `frame` and `content`, `node` itself is\n * clipped (its content laid out at the box, never stretched).\n */\nexport interface BoxNodes {\n readonly node: Styled;\n readonly frame?: Styled;\n readonly content?: Styled;\n}\n\n/** Lay `node` out at `box`: its position and size, in its offset parent's coordinates. */\nexport function layOutBox(node: Styled, box: Rect): void {\n const s = node.style;\n s.left = `${box.x}px`;\n s.top = `${box.y}px`;\n s.width = `${box.width}px`;\n s.height = `${box.height}px`;\n}\n\n/**\n * Draw one frame of a box laid out by {@link layOutBox}: one transform (the move to the drawn rect, and the uniform\n * appearance about its centre), the frame at the drawn size, the content clipped (reveal); hidden when gone.\n */\nexport function drawBox(nodes: BoxNodes, frame: DrawFrame): void {\n const { reveal: r, pop } = frame;\n const cx = frame.drawn.width / 2;\n const cy = frame.drawn.height / 2;\n const s = nodes.node.style;\n s.transform =\n pop.scale === 1 ? `translate(${r.dx}px, ${r.dy}px)` : `translate(${r.dx}px, ${r.dy}px) translate(${cx}px, ${cy}px) scale(${pop.scale}) translate(${-cx}px, ${-cy}px)`;\n s.opacity = pop.opacity === 1 ? \"\" : String(pop.opacity);\n if (nodes.frame) {\n nodes.frame.style.width = `${r.width}px`;\n nodes.frame.style.height = `${r.height}px`;\n }\n const clipped = nodes.content ?? (nodes.frame ? null : nodes.node);\n if (clipped) clipped.style.clipPath = r.clipRight || r.clipBottom ? `inset(0 ${r.clipRight}px ${r.clipBottom}px 0)` : \"\";\n // All the way gone: out of sight and out of the way of the pointer.\n s.visibility = frame.gone ? \"hidden\" : \"\";\n}\n\n/** A {@link Drawable} for DOM nodes: {@link layOutBox} on a new box, {@link drawBox} on every frame. */\nexport function domDrawable(nodes: BoxNodes): Drawable {\n return {\n layOut: (box) => layOutBox(nodes.node, box),\n draw: (frame) => drawBox(nodes, frame),\n };\n}\n"],"mappings":";;;;;;;;AA2HA,IAAM,OAAO,CAAC,GAAS,MACrB,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,QAAQ,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI;AACpI,IAAM,OAAO,CAAC,OAAmB,EAAE,GAAG,EAAE,GAAG,GAAG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,IAAI,MAAM;AAC1B;AAMO,SAAS,QAAQ,OAAiB,OAAwB;AAC/D,QAAM,EAAE,QAAQ,GAAG,IAAI,IAAI;AAC3B,QAAM,KAAK,MAAM,MAAM,QAAQ;AAC/B,QAAM,KAAK,MAAM,MAAM,SAAS;AAChC,QAAM,IAAI,MAAM,KAAK;AACrB,IAAE,YACA,IAAI,UAAU,IAAI,aAAa,EAAE,EAAE,OAAO,EAAE,EAAE,QAAQ,aAAa,EAAE,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,IAAI,KAAK,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE;AAClK,IAAE,UAAU,IAAI,YAAY,IAAI,KAAK,OAAO,IAAI,OAAO;AACvD,MAAI,MAAM,OAAO;AACf,UAAM,MAAM,MAAM,QAAQ,GAAG,EAAE,KAAK;AACpC,UAAM,MAAM,MAAM,SAAS,GAAG,EAAE,MAAM;AAAA,EACxC;AACA,QAAM,UAAU,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM;AAC7D,MAAI,QAAS,SAAQ,MAAM,WAAW,EAAE,aAAa,EAAE,aAAa,WAAW,EAAE,SAAS,MAAM,EAAE,UAAU,UAAU;AAEtH,IAAE,aAAa,MAAM,OAAO,WAAW;AACzC;AAGO,SAAS,YAAY,OAA2B;AACrD,SAAO;AAAA,IACL,QAAQ,CAAC,QAAQ,UAAU,MAAM,MAAM,GAAG;AAAA,IAC1C,MAAM,CAAC,UAAU,QAAQ,OAAO,KAAK;AAAA,EACvC;AACF;","names":["same"]}
@@ -0,0 +1,51 @@
1
+ import { R as Rect } from './shapes-EbQlwbCu.js';
2
+
3
+ /**
4
+ * How to draw a window whose rect is gliding without stretching its content.
5
+ *
6
+ * The content is laid out once at the target size and never scaled. The
7
+ * window's element sits at its target in the layout; to draw it at the
8
+ * gliding rect:
9
+ *
10
+ * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;
11
+ * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;
12
+ * - clip the content by `clipRight` and `clipBottom` so it fits a frame
13
+ * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).
14
+ *
15
+ * A window that shrinks shows a band of its own background closing in at the
16
+ * right and bottom; one that grows reveals content already laid out at its
17
+ * new size. Text is never stretched. One transform and one clip per frame, no
18
+ * layout per frame.
19
+ */
20
+ interface RevealFrame {
21
+ /** Move the element (laid out at the target) right by this much. */
22
+ readonly dx: number;
23
+ /** Move the element (laid out at the target) down by this much. */
24
+ readonly dy: number;
25
+ /** The frame's width: the drawn rect's. */
26
+ readonly width: number;
27
+ /** The frame's height: the drawn rect's. */
28
+ readonly height: number;
29
+ /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */
30
+ readonly clipRight: number;
31
+ /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */
32
+ readonly clipBottom: number;
33
+ }
34
+ /** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */
35
+ declare function reveal(drawn: Rect, target: Rect): RevealFrame;
36
+ /** A uniform pop-in (or pop-out, run backwards): scale about the centre and opacity. */
37
+ interface PopIn {
38
+ /** Scale about the window's centre: the same on both axes, so nothing is stretched. */
39
+ readonly scale: number;
40
+ readonly opacity: number;
41
+ }
42
+ /**
43
+ * Opening and closing: the window grows from `from` of its size to full, about
44
+ * its centre, while fading in. `progress` runs 0 to 1 (take it from a settle
45
+ * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for
46
+ * pixels and would snap the last 10 %; or from a tween); closing runs it from
47
+ * 1 to 0. Hyprland's default is `popin 87%`.
48
+ */
49
+ declare function popIn(progress: number, from?: number): PopIn;
50
+
51
+ export { type PopIn as P, type RevealFrame as R, popIn as p, reveal as r };
package/dist/values.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { A as Animatable, W as Widen, R as Rect } from './shapes-EbQlwbCu.js';
1
+ import { A as Animatable, W as Widen } from './shapes-EbQlwbCu.js';
2
+ export { P as PopIn, R as RevealFrame, p as popIn, r as reveal } from './reveal-my7U6UyE.js';
2
3
  import { e as Phase, a as FrameLoop } from './frame-loop-C88dc9xw.js';
3
4
  import { ReadonlySignal } from './signals.js';
4
5
  import './port-CmlUctqx.js';
@@ -202,54 +203,6 @@ declare const SETTLE_DEFAULTS: {
202
203
  */
203
204
  declare function createSettle<T extends Animatable>(initial: T, config?: SettleConfig): Settle<Widen<T>>;
204
205
 
205
- /**
206
- * How to draw a window whose rect is gliding without stretching its content.
207
- *
208
- * The content is laid out once at the target size and never scaled. The
209
- * window's element sits at its target in the layout; to draw it at the
210
- * gliding rect:
211
- *
212
- * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;
213
- * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;
214
- * - clip the content by `clipRight` and `clipBottom` so it fits a frame
215
- * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).
216
- *
217
- * A window that shrinks shows a band of its own background closing in at the
218
- * right and bottom; one that grows reveals content already laid out at its
219
- * new size. Text is never stretched. One transform and one clip per frame, no
220
- * layout per frame.
221
- */
222
- interface RevealFrame {
223
- /** Move the element (laid out at the target) right by this much. */
224
- readonly dx: number;
225
- /** Move the element (laid out at the target) down by this much. */
226
- readonly dy: number;
227
- /** The frame's width: the drawn rect's. */
228
- readonly width: number;
229
- /** The frame's height: the drawn rect's. */
230
- readonly height: number;
231
- /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */
232
- readonly clipRight: number;
233
- /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */
234
- readonly clipBottom: number;
235
- }
236
- /** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */
237
- declare function reveal(drawn: Rect, target: Rect): RevealFrame;
238
- /** A uniform pop-in (or pop-out, run backwards): scale about the centre and opacity. */
239
- interface PopIn {
240
- /** Scale about the window's centre: the same on both axes, so nothing is stretched. */
241
- readonly scale: number;
242
- readonly opacity: number;
243
- }
244
- /**
245
- * Opening and closing: the window grows from `from` of its size to full, about
246
- * its centre, while fading in. `progress` runs 0 to 1 (take it from a settle
247
- * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for
248
- * pixels and would snap the last 10 %; or from a tween); closing runs it from
249
- * 1 to 0. Hyprland's default is `popin 87%`.
250
- */
251
- declare function popIn(progress: number, from?: number): PopIn;
252
-
253
206
  /** Options of {@link motionValue}. */
254
207
  interface MotionOptions {
255
208
  /**
@@ -321,4 +274,4 @@ declare function settleValue<T extends Animatable>(loop: FrameLoop, initial: T,
321
274
  /** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */
322
275
  declare function tweenValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: TweenConfig & MotionOptions): MotionValue<Widen<T>, Tween<Widen<T>>>;
323
276
 
324
- export { type Animator, type AnimatorValue, type Easing, type MotionOptions, type MotionValue, type PopIn, type RevealFrame, SETTLE_DEFAULTS, SETTLE_TEMPO, SPRING_DEFAULTS, type SetOptions, type Settle, type SettleConfig, type Spring, type SpringConfig, type SpringParams, type SpringState, type Tween, type TweenConfig, createSettle, createSpring, createTween, cubicBezier, ease, easeIn, easeInOut, easeInOutCubic, easeOut, easeOutCubic, linear, motionValue, popIn, resolveSpring, reveal, settleValue, springStep, springValue, tweenValue };
277
+ export { type Animator, type AnimatorValue, type Easing, type MotionOptions, type MotionValue, SETTLE_DEFAULTS, SETTLE_TEMPO, SPRING_DEFAULTS, type SetOptions, type Settle, type SettleConfig, type Spring, type SpringConfig, type SpringParams, type SpringState, type Tween, type TweenConfig, createSettle, createSpring, createTween, cubicBezier, ease, easeIn, easeInOut, easeInOutCubic, easeOut, easeOutCubic, linear, motionValue, resolveSpring, settleValue, springStep, springValue, tweenValue };
package/dist/values.js CHANGED
@@ -1,8 +1,5 @@
1
1
  import {
2
- SETTLE_DEFAULTS,
3
- SETTLE_TEMPO,
4
2
  SPRING_DEFAULTS,
5
- createSettle,
6
3
  createSpring,
7
4
  createTween,
8
5
  cubicBezier,
@@ -14,15 +11,20 @@ import {
14
11
  easeOutCubic,
15
12
  linear,
16
13
  motionValue,
17
- popIn,
18
14
  resolveSpring,
19
- reveal,
20
15
  settleValue,
21
16
  springStep,
22
17
  springValue,
23
18
  tweenValue
24
- } from "./chunk-6W5KW7XQ.js";
19
+ } from "./chunk-CM6WVNDH.js";
25
20
  import "./chunk-OOKRBVMB.js";
21
+ import {
22
+ SETTLE_DEFAULTS,
23
+ SETTLE_TEMPO,
24
+ createSettle,
25
+ popIn,
26
+ reveal
27
+ } from "./chunk-WQQ2E25M.js";
26
28
  export {
27
29
  SETTLE_DEFAULTS,
28
30
  SETTLE_TEMPO,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n-uf/motion",
3
- "version": "26.11.3",
3
+ "version": "26.11.4",
4
4
  "description": "One frame loop with an injected clock, fine-grained signals, springs and tweens, and a DOM-free gesture recogniser. No DOM, no framework.",
5
5
  "keywords": [
6
6
  "animation",
@@ -61,6 +61,14 @@
61
61
  "types": "./dist/testing.d.ts",
62
62
  "default": "./dist/testing.js"
63
63
  },
64
+ "./drag": {
65
+ "types": "./dist/drag.d.ts",
66
+ "default": "./dist/drag.js"
67
+ },
68
+ "./layout": {
69
+ "types": "./dist/layout.d.ts",
70
+ "default": "./dist/layout.js"
71
+ },
64
72
  "./browser": {
65
73
  "types": "./dist/browser.d.ts",
66
74
  "default": "./dist/browser.js"