magic-pill 9.4.0-next.1 → 9.4.0-next.2
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 +17 -0
- package/dist/MagicPill/MagicPill.d.mts +9 -1
- package/dist/MagicPill/MagicPill.d.ts +9 -1
- package/dist/MagicPill/MagicPill.js +3 -1
- package/dist/MagicPill/MagicPill.mjs +3 -1
- package/dist/Pill/goo.js +238 -15
- package/dist/Pill/goo.mjs +235 -16
- package/dist/Pill/morph.js +8 -3
- package/dist/Pill/morph.mjs +7 -4
- package/dist/satellites/Actions.js +138 -16
- package/dist/satellites/Actions.mjs +139 -18
- package/dist/satellites/Orbitals.js +76 -45
- package/dist/satellites/Orbitals.mjs +77 -46
- package/dist/satellites/Satellites.js +284 -50
- package/dist/satellites/Satellites.mjs +285 -51
- package/dist/satellites/layout.js +83 -30
- package/dist/satellites/layout.mjs +83 -30
- package/dist/satellites/types.d.mts +4 -0
- package/dist/satellites/types.d.ts +4 -0
- package/dist/satellites.d.mts +2 -2
- package/dist/satellites.d.ts +2 -2
- package/dist/store/store.js +1 -1
- package/dist/store/store.mjs +1 -1
- package/dist/styles.css +170 -17
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
const require_Pill = require("../Pill/Pill.js");
|
|
5
5
|
const require_goo = require("../Pill/goo.js");
|
|
6
|
+
const require_morph = require("../Pill/morph.js");
|
|
6
7
|
const require_PillProgress = require("../Pill/PillProgress.js");
|
|
7
8
|
const require_matchPath = require("../PillNavbar/matchPath.js");
|
|
8
9
|
const require_room = require("../PillNavbar/room.js");
|
|
@@ -28,7 +29,8 @@ const ACTIONS = "\0actions";
|
|
|
28
29
|
const SIDE_PLACEMENTS = /* @__PURE__ */ new Set(["left", "right"]);
|
|
29
30
|
/**
|
|
30
31
|
* The page's actions' box along the pill, whichever way their pill runs now
|
|
31
|
-
* and even while its size animates: laid out on a hidden copy, turned along
|
|
32
|
+
* and even while its size animates: laid out on a hidden copy, turned along,
|
|
33
|
+
* with all of them (not cut short by a wheel).
|
|
32
34
|
*/
|
|
33
35
|
function alongBox(atom, vertical) {
|
|
34
36
|
const copy = atom.cloneNode(true);
|
|
@@ -39,13 +41,55 @@ function alongBox(atom, vertical) {
|
|
|
39
41
|
copy.style.pointerEvents = "none";
|
|
40
42
|
copy.style.translate = "none";
|
|
41
43
|
copy.style.scale = "none";
|
|
44
|
+
copy.querySelector("[data-mp=\"actions\"]")?.removeAttribute("data-wheel");
|
|
42
45
|
atom.after(copy);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const width = copy.offsetWidth;
|
|
47
|
+
const height = copy.offsetHeight;
|
|
48
|
+
const actions = [...copy.querySelectorAll("[data-mp=\"actions\"] > *")];
|
|
49
|
+
const along = (element) => vertical ? element.offsetTop : element.offsetLeft;
|
|
50
|
+
const action = actions[0] ? vertical ? actions[0].offsetHeight : actions[0].offsetWidth : 0;
|
|
51
|
+
const step = actions.length > 1 ? Math.abs(along(actions[1]) - along(actions[0])) : action;
|
|
52
|
+
const length = vertical ? height : width;
|
|
47
53
|
copy.remove();
|
|
48
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
width,
|
|
56
|
+
height,
|
|
57
|
+
wheel: {
|
|
58
|
+
count: actions.length,
|
|
59
|
+
first: length - Math.max(0, actions.length - 1) * step,
|
|
60
|
+
step,
|
|
61
|
+
action
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Out of the anchor (or back into it) with the goo, drawing itself the whole
|
|
67
|
+
* way, as the orbitals do: from inside it at its nearest edge by default.
|
|
68
|
+
*/
|
|
69
|
+
const bud = (anchor, element, kind, delay, duration, from, opaque = false) => require_goo.playOrbit(anchor, [{
|
|
70
|
+
element,
|
|
71
|
+
delay,
|
|
72
|
+
from: from ?? require_goo.atEdgeOf(anchor),
|
|
73
|
+
opaque
|
|
74
|
+
}], kind === "split" ? "open" : "close", { duration });
|
|
75
|
+
/** The screen's length along the host's edge, less its offsets. */
|
|
76
|
+
const mainRoom = (vertical, offset) => (vertical ? window.innerHeight : document.documentElement.clientWidth || window.innerWidth) - offset * 2;
|
|
77
|
+
/**
|
|
78
|
+
* The length of the page's actions inside the pill when they must be cut
|
|
79
|
+
* short to leave it `room` (undefined: all of them fit). `least`: how short
|
|
80
|
+
* the host gets with its navbar's labels folded.
|
|
81
|
+
*/
|
|
82
|
+
function insideWheelLength(track, root, vertical, room, least) {
|
|
83
|
+
const actions = [...track.children];
|
|
84
|
+
if (actions.length < 2) return void 0;
|
|
85
|
+
const along = (element) => vertical ? element.offsetTop : element.offsetLeft;
|
|
86
|
+
const action = vertical ? actions[0].offsetHeight : actions[0].offsetWidth;
|
|
87
|
+
const step = Math.abs(along(actions[1]) - along(actions[0]));
|
|
88
|
+
const all = action + (actions.length - 1) * step;
|
|
89
|
+
const now = vertical ? track.clientHeight : track.clientWidth;
|
|
90
|
+
const left = room - ((vertical ? root.offsetHeight : Math.min(root.offsetWidth, least ?? 1e400)) - now);
|
|
91
|
+
if (left >= all - .5 || step <= 0) return void 0;
|
|
92
|
+
return action + (Math.max(1, Math.min(actions.length, 1 + Math.floor((left - action) / step))) - 1) * step;
|
|
49
93
|
}
|
|
50
94
|
/** Two boxes side by side, a gap apart: the second can come out of the first. */
|
|
51
95
|
const nextTo = (a, b, gap) => {
|
|
@@ -109,15 +153,70 @@ function SatellitesLayer({ host }) {
|
|
|
109
153
|
...entry,
|
|
110
154
|
leaving: true
|
|
111
155
|
});
|
|
112
|
-
const
|
|
156
|
+
const [travelling, setTravelling] = (0, react.useState)(false);
|
|
157
|
+
const spot = `${host.placement} ${host.vertical}`;
|
|
158
|
+
const lastSpot = (0, react.useRef)(spot);
|
|
159
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
160
|
+
if (lastSpot.current === spot) return;
|
|
161
|
+
lastSpot.current = spot;
|
|
162
|
+
setTravelling(true);
|
|
163
|
+
}, [spot]);
|
|
164
|
+
(0, react.useEffect)(() => {
|
|
165
|
+
const root = host.rootRef.current;
|
|
166
|
+
if (!travelling || !root) return;
|
|
167
|
+
let closed = false;
|
|
168
|
+
const watch = new MutationObserver(() => {
|
|
169
|
+
const presence = root.dataset.presence;
|
|
170
|
+
if (presence === "rest" || presence === "hidden") closed = true;
|
|
171
|
+
else if (closed) setTravelling(false);
|
|
172
|
+
});
|
|
173
|
+
watch.observe(root, {
|
|
174
|
+
attributes: true,
|
|
175
|
+
attributeFilter: ["data-presence"]
|
|
176
|
+
});
|
|
177
|
+
const fallback = setTimeout(() => setTravelling(false), 1500);
|
|
178
|
+
return () => {
|
|
179
|
+
watch.disconnect();
|
|
180
|
+
clearTimeout(fallback);
|
|
181
|
+
};
|
|
182
|
+
}, [travelling, host.rootRef]);
|
|
183
|
+
const wanted = host.notifying && !host.keepElectronsOut || travelling;
|
|
184
|
+
const wasTucked = (0, react.useRef)(wanted);
|
|
185
|
+
const holding = (0, react.useRef)(false);
|
|
186
|
+
if (wasTucked.current && !wanted) holding.current = true;
|
|
187
|
+
wasTucked.current = wanted;
|
|
188
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
189
|
+
const root = host.rootRef.current;
|
|
190
|
+
if (wanted || !holding.current) return;
|
|
191
|
+
const release = () => {
|
|
192
|
+
holding.current = false;
|
|
193
|
+
refresh();
|
|
194
|
+
};
|
|
195
|
+
const morphs = (root?.getAnimations?.() ?? []).filter((animation) => animation.id === require_morph.MORPH);
|
|
196
|
+
if (morphs.length === 0) return release();
|
|
197
|
+
let cancelled = false;
|
|
198
|
+
Promise.allSettled(morphs.map((animation) => animation.finished)).then(() => {
|
|
199
|
+
if (!cancelled) release();
|
|
200
|
+
});
|
|
201
|
+
return () => {
|
|
202
|
+
cancelled = true;
|
|
203
|
+
};
|
|
204
|
+
}, [wanted]);
|
|
205
|
+
const tucked = wanted || holding.current;
|
|
113
206
|
const actions = require_Actions.useHostActions(host);
|
|
114
207
|
const lastActions = (0, react.useRef)(null);
|
|
115
208
|
if (actions) lastActions.current = actions;
|
|
116
209
|
const detached = host.actionsStyle === "detached";
|
|
117
210
|
const actionsPresence = detached && actions && !tucked ? "compact" : "hidden";
|
|
118
|
-
const
|
|
211
|
+
const goingIn = (0, react.useRef)(false);
|
|
212
|
+
const wasDetached = (0, react.useRef)(detached);
|
|
213
|
+
if (wasDetached.current && !detached && actions) goingIn.current = true;
|
|
214
|
+
if (detached) goingIn.current = false;
|
|
215
|
+
wasDetached.current = detached;
|
|
216
|
+
const shownActions = detached || goingIn.current ? actions ?? lastActions.current : null;
|
|
119
217
|
const atom = (0, react.useRef)(null);
|
|
120
218
|
const [actionsAcross, setActionsAcross] = (0, react.useState)(false);
|
|
219
|
+
const [wheelLength, setWheelLength] = (0, react.useState)(void 0);
|
|
121
220
|
const actionsBox = (0, react.useRef)(null);
|
|
122
221
|
const across = (0, react.useRef)(actionsAcross);
|
|
123
222
|
across.current = actionsAcross;
|
|
@@ -137,6 +236,11 @@ function SatellitesLayer({ host }) {
|
|
|
137
236
|
});
|
|
138
237
|
const hostMin = (0, react.useRef)(void 0);
|
|
139
238
|
const rows = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
239
|
+
const spots = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
240
|
+
const rejoining = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
241
|
+
const splitNext = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
242
|
+
const insideSpot = (0, react.useRef)(null);
|
|
243
|
+
const lastStyle = (0, react.useRef)(host.actionsStyle);
|
|
140
244
|
const arrange = (0, react.useRef)(() => {});
|
|
141
245
|
arrange.current = (animate) => {
|
|
142
246
|
const root = host.rootRef.current;
|
|
@@ -178,19 +282,42 @@ function SatellitesLayer({ host }) {
|
|
|
178
282
|
width: actionsBox.current.width,
|
|
179
283
|
height: actionsBox.current.height,
|
|
180
284
|
side: host.actionsSide,
|
|
181
|
-
turn
|
|
285
|
+
turn,
|
|
286
|
+
...host.actionsWheel ? { wheel: actionsBox.current.wheel } : {}
|
|
182
287
|
} : void 0,
|
|
288
|
+
nearest: host.nearestToPill,
|
|
183
289
|
side: host.electronSide,
|
|
184
290
|
line: host.electronLine,
|
|
185
291
|
arrange: host.arrange,
|
|
186
292
|
gap,
|
|
187
293
|
offset
|
|
188
294
|
});
|
|
295
|
+
if (animate && host.actionsStyle === "inside") {
|
|
296
|
+
const track = root.querySelector("[data-mp=\"actions\"][data-inside]");
|
|
297
|
+
if (track) {
|
|
298
|
+
const length = host.actionsWheel ? insideWheelLength(track, root, vertical, mainRoom(vertical, offset) - layout.reserve, hostMin.current) : void 0;
|
|
299
|
+
if (length === void 0) {
|
|
300
|
+
track.removeAttribute("data-wheel");
|
|
301
|
+
track.style.removeProperty("--_mp-wheel-length");
|
|
302
|
+
} else {
|
|
303
|
+
track.setAttribute("data-wheel", "");
|
|
304
|
+
track.style.setProperty("--_mp-wheel-length", `${length}px`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
189
308
|
const reduced = require_timing.prefersReducedMotion();
|
|
190
309
|
const moving = animate && !reduced && typeof root.animate === "function";
|
|
191
310
|
const timings = require_measure.durations(out[0] ? elements.current.get(out[0].electron.id) : root);
|
|
311
|
+
const boxes = layout.boxes;
|
|
312
|
+
const hostAlong = (vertical ? root.offsetTop : root.offsetLeft) + layout.shift + (vertical ? root.offsetHeight : root.offsetWidth) / 2;
|
|
313
|
+
const alongOf = (box) => vertical ? box.top + box.height / 2 : box.left + box.width / 2;
|
|
314
|
+
const spotOf = (box) => `${alongOf(box) < hostAlong ? "before" : "after"} ${Math.round(vertical ? box.left : box.top)}`;
|
|
315
|
+
const hostCentre = () => vertical ? require_goo.atPoint(root.offsetLeft + root.offsetWidth / 2, hostAlong) : require_goo.atPoint(hostAlong, root.offsetTop + root.offsetHeight / 2);
|
|
316
|
+
const changing = (id, box) => !!box && presences.current.get(id) === "compact" && spots.current.has(id) && spots.current.get(id) !== spotOf(box);
|
|
317
|
+
const turning = !!atomElement && !!atomOut && layout.actionsAcross !== across.current && presences.current.get(ACTIONS) === "compact";
|
|
318
|
+
const holding = animate && !reduced && (out.some(({ electron }) => !rejoining.current.has(electron.id) && changing(electron.id, boxes[electron.id])) || !!atomOut && !rejoining.current.has(ACTIONS) && (turning || changing(ACTIONS, boxes.actions))) || rejoining.current.size > 0;
|
|
192
319
|
const previous = applied.current;
|
|
193
|
-
if (Math.abs(layout.shift - previous.shift) > .5) {
|
|
320
|
+
if (!holding && Math.abs(layout.shift - previous.shift) > .5) {
|
|
194
321
|
const along = (value) => vertical ? `0px ${value}px` : `${value}px 0px`;
|
|
195
322
|
if (layout.shift) root.style.setProperty("translate", along(layout.shift));
|
|
196
323
|
else root.style.removeProperty("translate");
|
|
@@ -201,70 +328,161 @@ function SatellitesLayer({ host }) {
|
|
|
201
328
|
composite: "add"
|
|
202
329
|
});
|
|
203
330
|
}
|
|
204
|
-
if (!vertical && layout.reserve !== previous.reserve) {
|
|
331
|
+
if (!holding && !vertical && layout.reserve !== previous.reserve) {
|
|
205
332
|
if (layout.reserve) root.style.setProperty("--_mp-shift-x", `${layout.reserve}px`);
|
|
206
333
|
else root.style.removeProperty("--_mp-shift-x");
|
|
207
334
|
}
|
|
208
|
-
applied.current = {
|
|
335
|
+
if (!holding) applied.current = {
|
|
209
336
|
shift: layout.shift,
|
|
210
337
|
reserve: layout.reserve
|
|
211
338
|
};
|
|
212
|
-
|
|
213
|
-
|
|
339
|
+
const rejoin = (id, element, then) => {
|
|
340
|
+
rejoining.current.add(id);
|
|
341
|
+
const { exit } = require_measure.durations(element);
|
|
342
|
+
bud(root, element, "join", 0, exit);
|
|
343
|
+
setTimeout(() => {
|
|
344
|
+
rejoining.current.delete(id);
|
|
345
|
+
then();
|
|
346
|
+
}, exit + 20);
|
|
347
|
+
};
|
|
348
|
+
const styleChanged = lastStyle.current !== host.actionsStyle;
|
|
349
|
+
if (animate) {
|
|
350
|
+
const track = host.actionsStyle === "inside" ? root.querySelector("[data-mp=\"actions\"][data-inside]") : null;
|
|
351
|
+
if (track) {
|
|
352
|
+
const hostLeft = root.offsetLeft + (vertical ? 0 : layout.shift);
|
|
353
|
+
const hostTop = root.offsetTop + (vertical ? layout.shift : 0);
|
|
354
|
+
insideSpot.current = {
|
|
355
|
+
x: hostLeft + track.offsetLeft + track.offsetWidth / 2,
|
|
356
|
+
y: hostTop + track.offsetTop + track.offsetHeight / 2
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
lastStyle.current = host.actionsStyle;
|
|
360
|
+
}
|
|
361
|
+
const slides = [];
|
|
214
362
|
if (atomElement) {
|
|
215
363
|
const was = presences.current.get(ACTIONS);
|
|
216
364
|
const box = boxes.actions;
|
|
217
365
|
const settled = layout.actionsAcross === across.current;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
366
|
+
const moved = !!box && spots.current.has(ACTIONS) && spots.current.get(ACTIONS) !== spotOf(box);
|
|
367
|
+
if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS)) {
|
|
368
|
+
const turnTo = layout.actionsAcross;
|
|
369
|
+
rejoin(ACTIONS, atomElement, () => {
|
|
370
|
+
presences.current.set(ACTIONS, "hidden");
|
|
371
|
+
spots.current.delete(ACTIONS);
|
|
372
|
+
setActionsAcross(turnTo);
|
|
373
|
+
refresh();
|
|
224
374
|
});
|
|
375
|
+
} else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS)) setActionsAcross(layout.actionsAcross);
|
|
376
|
+
if (animate && atomOut && actionsBox.current) {
|
|
377
|
+
const { wheel } = actionsBox.current;
|
|
378
|
+
const length = layout.actionsShown !== void 0 ? wheel.action + (layout.actionsShown - 1) * wheel.step : void 0;
|
|
379
|
+
if (length !== wheelLength) setWheelLength(length);
|
|
380
|
+
}
|
|
381
|
+
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding) {
|
|
382
|
+
const before = alongOf(box) < hostAlong;
|
|
383
|
+
const width = atomElement.offsetWidth || box.width;
|
|
384
|
+
const height = atomElement.offsetHeight || box.height;
|
|
385
|
+
const from = {
|
|
386
|
+
left: Number.parseFloat(atomElement.style.left),
|
|
387
|
+
top: Number.parseFloat(atomElement.style.top)
|
|
388
|
+
};
|
|
389
|
+
const left = !vertical && before ? box.left + box.width - width : box.left;
|
|
390
|
+
const top = vertical && before ? box.top + box.height - height : box.top;
|
|
391
|
+
atomElement.style.left = `${left}px`;
|
|
392
|
+
atomElement.style.top = `${top}px`;
|
|
393
|
+
spots.current.set(ACTIONS, spotOf(box));
|
|
394
|
+
if (animate && was !== "compact") {
|
|
395
|
+
const fromInside = styleChanged && insideSpot.current ? require_goo.atPoint(insideSpot.current.x, insideSpot.current.y, 1) : void 0;
|
|
396
|
+
require_morph.cancel(atomElement, require_morph.MORPH, true);
|
|
397
|
+
require_morph.cancel(atomElement, require_morph.MOVE);
|
|
398
|
+
bud(root, atomElement, "split", 0, require_measure.durations(atomElement).enter, fromInside, !!fromInside);
|
|
399
|
+
} else if (moving && was === "compact" && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
400
|
+
if (Math.abs(from.left - left) > .5 || Math.abs(from.top - top) > .5) {
|
|
401
|
+
slides.push({
|
|
402
|
+
element: atomElement,
|
|
403
|
+
from: vertical ? from.top : from.left,
|
|
404
|
+
to: vertical ? top : left
|
|
405
|
+
});
|
|
406
|
+
atomElement.animate([{ translate: `${from.left - left}px ${from.top - top}px` }, { translate: "0px 0px" }], {
|
|
407
|
+
id: SHIFT,
|
|
408
|
+
duration: timings.change,
|
|
409
|
+
easing: "ease-in-out",
|
|
410
|
+
composite: "add"
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
225
414
|
} else if (animate && !atomOut && was === "compact") {
|
|
226
|
-
const { fade,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
415
|
+
const { fade, exit } = require_measure.durations(atomElement);
|
|
416
|
+
if (styleChanged && host.actionsStyle === "inside" && insideSpot.current) {
|
|
417
|
+
require_morph.cancel(atomElement, require_morph.EXIT, true);
|
|
418
|
+
for (const child of atomElement.children) child.style.opacity = "1";
|
|
419
|
+
bud(root, atomElement, "join", 0, exit, require_goo.atPoint(insideSpot.current.x, insideSpot.current.y, 1), true);
|
|
420
|
+
setTimeout(() => {
|
|
421
|
+
for (const child of atomElement.children) child.style.removeProperty("opacity");
|
|
422
|
+
goingIn.current = false;
|
|
423
|
+
refresh();
|
|
424
|
+
}, exit + 20);
|
|
425
|
+
} else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + require_measure.durations(atomElement).change), hostCentre());
|
|
426
|
+
else bud(root, atomElement, "join", fade, exit);
|
|
427
|
+
spots.current.delete(ACTIONS);
|
|
231
428
|
}
|
|
232
|
-
if (animate && (settled || !atomOut)) presences.current.set(ACTIONS, actionsPresence);
|
|
429
|
+
if (animate && !rejoining.current.has(ACTIONS) && !holding && (settled || !atomOut)) presences.current.set(ACTIONS, actionsPresence);
|
|
233
430
|
}
|
|
234
431
|
const crossOf = (box) => Math.round(vertical ? box.left : box.top);
|
|
235
432
|
out.forEach(({ electron }, index) => {
|
|
236
433
|
const element = elements.current.get(electron.id);
|
|
237
434
|
const box = boxes[electron.id];
|
|
238
435
|
const was = presences.current.get(electron.id);
|
|
239
|
-
|
|
436
|
+
if (rejoining.current.has(electron.id)) return;
|
|
437
|
+
if (splitNext.current.delete(electron.id)) {
|
|
438
|
+
element.style.left = `${box.left}px`;
|
|
439
|
+
element.style.top = `${box.top}px`;
|
|
440
|
+
rows.current.set(electron.id, String(crossOf(box)));
|
|
441
|
+
bud(root, element, "split", 0, require_measure.durations(element).enter);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
const moved = was === "compact" && spots.current.has(electron.id) && spots.current.get(electron.id) !== spotOf(box);
|
|
445
|
+
if (animate && moved && !reduced) {
|
|
446
|
+
spots.current.set(electron.id, spotOf(box));
|
|
447
|
+
rejoin(electron.id, element, () => {
|
|
448
|
+
splitNext.current.add(electron.id);
|
|
449
|
+
arrange.current(true);
|
|
450
|
+
});
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (holding) return;
|
|
454
|
+
spots.current.set(electron.id, spotOf(box));
|
|
455
|
+
const from = {
|
|
456
|
+
left: Number.parseFloat(element.style.left),
|
|
457
|
+
top: Number.parseFloat(element.style.top)
|
|
458
|
+
};
|
|
240
459
|
element.style.left = `${box.left}px`;
|
|
241
460
|
element.style.top = `${box.top}px`;
|
|
242
461
|
const row = String(crossOf(box));
|
|
243
462
|
const changedRow = rows.current.has(electron.id) && rows.current.get(electron.id) !== row;
|
|
244
463
|
rows.current.set(electron.id, row);
|
|
464
|
+
const placed = Number.isFinite(from.left) && Number.isFinite(from.top);
|
|
245
465
|
if (!animate) {
|
|
246
|
-
if (changedRow && !reduced && typeof element.animate === "function") {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
composite: "add"
|
|
253
|
-
});
|
|
254
|
-
}
|
|
466
|
+
if (changedRow && placed && !reduced && typeof element.animate === "function") element.animate([{ translate: `${from.left - box.left}px ${from.top - box.top}px` }, { translate: "0px 0px" }], {
|
|
467
|
+
id: SHIFT,
|
|
468
|
+
duration: timings.change,
|
|
469
|
+
easing: "ease-in-out",
|
|
470
|
+
composite: "add"
|
|
471
|
+
});
|
|
255
472
|
return;
|
|
256
473
|
}
|
|
257
474
|
if (was === void 0 || was === "hidden") {
|
|
258
475
|
const before = out[index - 1];
|
|
259
476
|
const neighbour = before ? elements.current.get(before.electron.id) : void 0;
|
|
260
477
|
const anchor = neighbour && before && nextTo(boxes[before.electron.id], box, gap) ? neighbour : root;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
478
|
+
bud(anchor, element, "split", 0, require_measure.durations(element).enter);
|
|
479
|
+
} else if (moving && placed && (Math.abs(from.left - box.left) > .5 || Math.abs(from.top - box.top) > .5)) {
|
|
480
|
+
slides.push({
|
|
481
|
+
element,
|
|
482
|
+
from: vertical ? from.top : from.left,
|
|
483
|
+
to: vertical ? box.top : box.left
|
|
264
484
|
});
|
|
265
|
-
|
|
266
|
-
const to = element.getBoundingClientRect();
|
|
267
|
-
element.animate([{ translate: `${from.left - to.left}px ${from.top - to.top}px` }, { translate: "0px 0px" }], {
|
|
485
|
+
element.animate([{ translate: `${from.left - box.left}px ${from.top - box.top}px` }, { translate: "0px 0px" }], {
|
|
268
486
|
id: SHIFT,
|
|
269
487
|
duration: timings.change,
|
|
270
488
|
easing: "ease-in-out",
|
|
@@ -272,16 +490,24 @@ function SatellitesLayer({ host }) {
|
|
|
272
490
|
});
|
|
273
491
|
}
|
|
274
492
|
});
|
|
275
|
-
|
|
493
|
+
const passing = /* @__PURE__ */ new Set();
|
|
494
|
+
slides.forEach((a, i) => slides.slice(i + 1).forEach((b) => {
|
|
495
|
+
if (Math.sign(a.from - b.from) !== Math.sign(a.to - b.to)) {
|
|
496
|
+
passing.add(a.element);
|
|
497
|
+
passing.add(b.element);
|
|
498
|
+
}
|
|
499
|
+
}));
|
|
500
|
+
if (passing.size > 1) require_goo.playNecks([...passing], timings.change);
|
|
501
|
+
if (animate && !holding) {
|
|
276
502
|
for (const entry of entries) {
|
|
277
503
|
const element = elements.current.get(entry.electron.id);
|
|
278
504
|
if (!element || entry.presence !== "hidden" || presences.current.get(entry.electron.id) !== "compact") continue;
|
|
279
|
-
|
|
505
|
+
const ending = entry.leaving ? entry.electron.input.ending ?? host.electronEnding : "join";
|
|
506
|
+
spots.current.delete(entry.electron.id);
|
|
507
|
+
if (ending === "pop") continue;
|
|
280
508
|
const { fade, change, exit } = require_measure.durations(element);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
duration: exit
|
|
284
|
-
});
|
|
509
|
+
if (tucked && !entry.leaving) bud(root, element, "join", 0, Math.max(exit, fade + change), hostCentre());
|
|
510
|
+
else bud(root, element, "join", fade, exit);
|
|
285
511
|
}
|
|
286
512
|
for (const entry of entries) presences.current.set(entry.electron.id, entry.presence);
|
|
287
513
|
}
|
|
@@ -290,12 +516,18 @@ function SatellitesLayer({ host }) {
|
|
|
290
516
|
(0, react.useEffect)(() => {
|
|
291
517
|
const root = host.rootRef.current;
|
|
292
518
|
if (!root) return;
|
|
293
|
-
|
|
519
|
+
let settle;
|
|
520
|
+
const follow = () => {
|
|
521
|
+
arrange.current(false);
|
|
522
|
+
clearTimeout(settle);
|
|
523
|
+
settle = setTimeout(() => arrange.current(true), 200);
|
|
524
|
+
};
|
|
294
525
|
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(follow);
|
|
295
526
|
observer?.observe(root);
|
|
296
527
|
if (atom.current) observer?.observe(atom.current);
|
|
297
528
|
window.addEventListener("resize", follow);
|
|
298
529
|
return () => {
|
|
530
|
+
clearTimeout(settle);
|
|
299
531
|
observer?.disconnect();
|
|
300
532
|
window.removeEventListener("resize", follow);
|
|
301
533
|
root.style.removeProperty("translate");
|
|
@@ -324,6 +556,7 @@ function SatellitesLayer({ host }) {
|
|
|
324
556
|
shown.current.delete(id);
|
|
325
557
|
presences.current.delete(id);
|
|
326
558
|
rows.current.delete(id);
|
|
559
|
+
spots.current.delete(id);
|
|
327
560
|
refresh();
|
|
328
561
|
}, fade + change + exit + 100);
|
|
329
562
|
});
|
|
@@ -377,7 +610,8 @@ function SatellitesLayer({ host }) {
|
|
|
377
610
|
style: ELECTRON_STYLE,
|
|
378
611
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Actions.ActionList, {
|
|
379
612
|
items: shownActions,
|
|
380
|
-
host
|
|
613
|
+
host,
|
|
614
|
+
wheel: wheelLength
|
|
381
615
|
})
|
|
382
616
|
}),
|
|
383
617
|
entries.map(({ electron, presence }) => electron.input.orbitals?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Orbitals.Orbitals, {
|