magic-pill 9.4.0-next.4 → 9.4.0-next.5
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 +14 -0
- package/dist/MagicPill/MagicPill.js +1 -0
- package/dist/MagicPill/MagicPill.mjs +1 -0
- package/dist/Pill/goo.js +30 -9
- package/dist/Pill/goo.mjs +30 -9
- package/dist/PillNavbar/room.js +2 -1
- package/dist/PillNavbar/room.mjs +2 -1
- package/dist/PillNotification/RowsBody.js +1 -1
- package/dist/PillNotification/RowsBody.mjs +1 -1
- package/dist/satellites/Actions.js +89 -11
- package/dist/satellites/Actions.mjs +89 -11
- package/dist/satellites/Orbitals.js +1 -1
- package/dist/satellites/Orbitals.mjs +1 -1
- package/dist/satellites/Satellites.js +252 -151
- package/dist/satellites/Satellites.mjs +251 -151
- package/dist/satellites/types.d.mts +2 -0
- package/dist/satellites/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ function alongBox(atom, vertical) {
|
|
|
49
49
|
atom.after(copy);
|
|
50
50
|
const width = copy.offsetWidth;
|
|
51
51
|
const height = copy.offsetHeight;
|
|
52
|
-
const actions = [...copy.querySelectorAll("[data-mp=\"actions\"] >
|
|
52
|
+
const actions = [...copy.querySelectorAll("[data-mp=\"actions\"] > :not([data-action-leaving])")];
|
|
53
53
|
const along = (element) => vertical ? element.offsetTop : element.offsetLeft;
|
|
54
54
|
const action = actions[0] ? vertical ? actions[0].offsetHeight : actions[0].offsetWidth : 0;
|
|
55
55
|
const step = actions.length > 1 ? Math.abs(along(actions[1]) - along(actions[0])) : action;
|
|
@@ -83,6 +83,8 @@ const bud = (anchor, element, kind, delay, duration, from, opaque = false) => re
|
|
|
83
83
|
* of the window's edge sends one event per frame. Was 200 ms: a pause you could feel once you let go
|
|
84
84
|
*/
|
|
85
85
|
const SETTLED = 120;
|
|
86
|
+
/** How long a panel opens (styles.css, [data-presence="panel"]'s max size), without the satellites' room */
|
|
87
|
+
const panelLength = (offset) => `min(var(--mp-panel-width, 32rem), 100vw - ${offset * 2}px)`;
|
|
86
88
|
/** A host's slide longer than this (px) can run against a droplet's way out (see drop) */
|
|
87
89
|
const AGAINST = 24;
|
|
88
90
|
/**
|
|
@@ -91,26 +93,28 @@ const AGAINST = 24;
|
|
|
91
93
|
* how it gets there, which a droplet coming out follows while it's still attached (from its edge
|
|
92
94
|
* where it is to its edge where it goes), or it would come out where the anchor no longer is.
|
|
93
95
|
*/
|
|
94
|
-
function drop(anchor, element, kind, delay, duration, at, slide) {
|
|
96
|
+
function drop(anchor, element, kind, delay, duration, at, slide, settles = 0) {
|
|
95
97
|
const from = require_goo.atEdgeOf(anchor, at, require_goo.DROPLET);
|
|
96
|
-
const
|
|
98
|
+
const animates = !require_timing.prefersReducedMotion() && typeof element.animate === "function";
|
|
99
|
+
const moves = !!slide && kind === "split" && animates;
|
|
100
|
+
let wait = kind === "split" && animates ? settles : 0;
|
|
97
101
|
if (moves && slide && Math.hypot(slide.x, slide.y) > AGAINST) {
|
|
98
102
|
for (const animation of element.getAnimations?.() ?? []) if (animation.id === "mp-split") animation.cancel();
|
|
99
103
|
const out = from(element.getBoundingClientRect(), element);
|
|
100
|
-
if (out.x * slide.x + out.y * slide.y < 0)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
if (out.x * slide.x + out.y * slide.y < 0) wait = Math.max(wait, slide.duration);
|
|
105
|
+
}
|
|
106
|
+
if (wait > 0) {
|
|
107
|
+
const stop = require_goo.playOrbit(anchor, [{
|
|
108
|
+
element,
|
|
109
|
+
delay: delay + wait,
|
|
110
|
+
from,
|
|
111
|
+
droplet: true
|
|
112
|
+
}], "open", { duration });
|
|
113
|
+
element.animate([{ opacity: 0 }, { opacity: 0 }], {
|
|
114
|
+
id: require_goo.SPLIT,
|
|
115
|
+
duration: delay + wait
|
|
116
|
+
});
|
|
117
|
+
return stop;
|
|
114
118
|
}
|
|
115
119
|
const stop = require_goo.playOrbit(anchor, [{
|
|
116
120
|
element,
|
|
@@ -126,6 +130,50 @@ function drop(anchor, element, kind, delay, duration, at, slide) {
|
|
|
126
130
|
});
|
|
127
131
|
return stop;
|
|
128
132
|
}
|
|
133
|
+
/** The page's actions folding away in the pill or opening in it (Actions.tsx) */
|
|
134
|
+
const INSIDE_ACTIONS = "mp-inside-actions";
|
|
135
|
+
/** Longer than this, an animation holds a size rather than moving to one (Actions.tsx holds for a minute) */
|
|
136
|
+
const HOLD = 1e4;
|
|
137
|
+
/** What changes a pill's size as it animates: its morph, its navbar's labels, its actions folding or opening. */
|
|
138
|
+
const SIZING = /^(grid-template-columns|width|height|inline-size|block-size|max-width|max-inline-size|padding|margin)/;
|
|
139
|
+
/**
|
|
140
|
+
* How long (ms) until the host stops changing size: its morph, its labels folding or opening. What
|
|
141
|
+
* comes out of it waits for that (the host settles first, then they come out of it).
|
|
142
|
+
*/
|
|
143
|
+
function settlesIn(root) {
|
|
144
|
+
let left = 0;
|
|
145
|
+
for (const animation of root.getAnimations?.({ subtree: true }) ?? []) {
|
|
146
|
+
const property = animation.transitionProperty;
|
|
147
|
+
if (animation.id !== "mp-morph" && animation.id !== INSIDE_ACTIONS && !(property && SIZING.test(property))) continue;
|
|
148
|
+
if (animation.playState !== "running") continue;
|
|
149
|
+
const end = animation.effect?.getComputedTiming().endTime;
|
|
150
|
+
if (typeof end === "number" && end > HOLD) continue;
|
|
151
|
+
const now = Number(animation.currentTime ?? 0);
|
|
152
|
+
if (typeof end === "number" && Number.isFinite(end)) left = Math.max(left, end - now);
|
|
153
|
+
}
|
|
154
|
+
return left;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Places a satellite, fixed: beside a host at the bottom of the screen, held by its bottom edge as the
|
|
158
|
+
* host is. Safari's toolbar moves the host as the page scrolls (or as a new page comes): they move
|
|
159
|
+
* with it at once, with no pass. Held by their top, they stayed where they were, under the address
|
|
160
|
+
* bar, until the next pass, then slid (or shrank to a circle) to catch up.
|
|
161
|
+
*/
|
|
162
|
+
function place(element, left, top, height, byBottom) {
|
|
163
|
+
element.style.left = `${left}px`;
|
|
164
|
+
if (byBottom) {
|
|
165
|
+
element.style.top = "auto";
|
|
166
|
+
element.style.bottom = `${window.innerHeight - top - height}px`;
|
|
167
|
+
} else {
|
|
168
|
+
element.style.top = `${top}px`;
|
|
169
|
+
element.style.removeProperty("bottom");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Where a satellite was placed (its top on the screen now), whichever edge holds it. */
|
|
173
|
+
function placedTop(element, height) {
|
|
174
|
+
if (element.style.top === "auto" && element.style.bottom) return window.innerHeight - Number.parseFloat(element.style.bottom) - height;
|
|
175
|
+
return Number.parseFloat(element.style.top);
|
|
176
|
+
}
|
|
129
177
|
/** The screen's length along the host's edge, less its offsets. */
|
|
130
178
|
const mainRoom = (vertical, offset) => (vertical ? window.innerHeight : document.documentElement.clientWidth || window.innerWidth) - offset * 2;
|
|
131
179
|
/**
|
|
@@ -336,7 +384,11 @@ function SatellitesLayer({ host }) {
|
|
|
336
384
|
(0, react.useEffect)(() => {
|
|
337
385
|
if (leavingPill) setLeavingPill(false);
|
|
338
386
|
}, [leavingPill]);
|
|
339
|
-
const
|
|
387
|
+
const [inPanel, setInPanel] = (0, react.useState)(false);
|
|
388
|
+
if (inPanel && !host.panel) setInPanel(false);
|
|
389
|
+
const panelTucked = inPanel && host.panel;
|
|
390
|
+
const comingOut = detached && !!actions && !tucked && !panelTucked && (waits || handoff === "out");
|
|
391
|
+
const actionsPresence = detached && actions && !tucked && !panelTucked && !waits && handoff !== "out" ? turnPhase.current ? "rest" : "compact" : "hidden";
|
|
340
392
|
const goingIn = (0, react.useRef)(false);
|
|
341
393
|
const wasDetached = (0, react.useRef)(detached);
|
|
342
394
|
if (wasDetached.current && !detached && actions) goingIn.current = presences.current.get(ACTIONS) === "compact";
|
|
@@ -355,7 +407,7 @@ function SatellitesLayer({ host }) {
|
|
|
355
407
|
};
|
|
356
408
|
const entries = [...shown.current.values()].map((entry) => ({
|
|
357
409
|
...entry,
|
|
358
|
-
presence: presenceOf(entry)
|
|
410
|
+
presence: panelTucked ? "hidden" : presenceOf(entry)
|
|
359
411
|
}));
|
|
360
412
|
const elements = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
361
413
|
const applied = (0, react.useRef)({
|
|
@@ -372,6 +424,9 @@ function SatellitesLayer({ host }) {
|
|
|
372
424
|
const atomPlaced = (0, react.useRef)(null);
|
|
373
425
|
const lastStyle = (0, react.useRef)(host.actionsStyle);
|
|
374
426
|
const foldingSince = (0, react.useRef)(void 0);
|
|
427
|
+
const labelOpened = (0, react.useRef)(void 0);
|
|
428
|
+
const joinUntil = (0, react.useRef)(0);
|
|
429
|
+
const spotsUntil = (0, react.useRef)(0);
|
|
375
430
|
const tripHost = (0, react.useRef)(null);
|
|
376
431
|
const arrange = (0, react.useRef)(() => {});
|
|
377
432
|
arrange.current = (animate) => {
|
|
@@ -427,7 +482,7 @@ function SatellitesLayer({ host }) {
|
|
|
427
482
|
vertical,
|
|
428
483
|
rtl: style.direction === "rtl",
|
|
429
484
|
electrons: sized(out),
|
|
430
|
-
actions: actionsInput(!!atomOut),
|
|
485
|
+
actions: actionsInput(!!atomOut || comingOut),
|
|
431
486
|
nearest: host.nearestToPill,
|
|
432
487
|
side: host.electronSide,
|
|
433
488
|
line: host.electronLine,
|
|
@@ -440,23 +495,58 @@ function SatellitesLayer({ host }) {
|
|
|
440
495
|
const open = hostOpen.current;
|
|
441
496
|
const least = hostMin.current;
|
|
442
497
|
const canFold = !vertical && open !== void 0 && least !== void 0 && least < open - .5;
|
|
498
|
+
const openBox = canFold ? alignedBox(root, placement, vertical, rtl, {
|
|
499
|
+
width: open,
|
|
500
|
+
height: root.offsetHeight
|
|
501
|
+
}) : void 0;
|
|
502
|
+
const foldedBox = canFold ? alignedBox(root, placement, vertical, rtl, {
|
|
503
|
+
width: least,
|
|
504
|
+
height: root.offsetHeight
|
|
505
|
+
}) : void 0;
|
|
443
506
|
const asOpen = canFold ? require_layout.planSatellites({
|
|
444
507
|
...input,
|
|
445
|
-
host:
|
|
446
|
-
width: open,
|
|
447
|
-
height: root.offsetHeight
|
|
448
|
-
}),
|
|
508
|
+
host: openBox,
|
|
449
509
|
hostMin: void 0
|
|
450
510
|
}) : void 0;
|
|
451
511
|
const asFolded = canFold ? require_layout.planSatellites({
|
|
452
512
|
...input,
|
|
453
|
-
host:
|
|
454
|
-
width: least,
|
|
455
|
-
height: root.offsetHeight
|
|
456
|
-
})
|
|
513
|
+
host: foldedBox
|
|
457
514
|
}) : void 0;
|
|
458
515
|
const fitsOpen = !!asOpen && open + asOpen.reserve <= input.viewport.width - offset * 2 + .5 && asOpen.movedBeside.length <= asFolded.movedBeside.length && (!asOpen.actionsAcross || asFolded.actionsAcross) && (asOpen.actionsShown ?? 1e400) >= (asFolded.actionsShown ?? 1e400);
|
|
459
|
-
const
|
|
516
|
+
const chosen = !canFold ? require_layout.planSatellites(input) : fitsOpen ? asOpen : asFolded;
|
|
517
|
+
if (root.querySelector("[data-mp=\"navbar\"] [data-mp=\"action\"]:is(:hover, :focus-visible, [data-pointed])")) labelOpened.current = "open";
|
|
518
|
+
else if (labelOpened.current === "open") labelOpened.current = performance.now();
|
|
519
|
+
const closing = labelOpened.current;
|
|
520
|
+
const pointing = closing === "open" || closing !== void 0 && performance.now() - closing < require_measure.durations(root).change * 2;
|
|
521
|
+
let panelPlan;
|
|
522
|
+
let panelBox;
|
|
523
|
+
if (host.panel && !vertical && !panelTucked && (out.length > 0 || !!atomOut)) {
|
|
524
|
+
const probe = document.createElement("div");
|
|
525
|
+
probe.style.cssText = `position:absolute;visibility:hidden;block-size:0;inline-size:${panelLength(offset)}`;
|
|
526
|
+
root.append(probe);
|
|
527
|
+
const whole = Number.parseFloat(getComputedStyle(probe).inlineSize) || 0;
|
|
528
|
+
probe.remove();
|
|
529
|
+
if (whole > 0) {
|
|
530
|
+
panelBox = alignedBox(root, placement, vertical, rtl, {
|
|
531
|
+
width: whole,
|
|
532
|
+
height: root.offsetHeight
|
|
533
|
+
});
|
|
534
|
+
panelPlan = require_layout.planSatellites({
|
|
535
|
+
...input,
|
|
536
|
+
host: panelBox,
|
|
537
|
+
hostMin: void 0
|
|
538
|
+
});
|
|
539
|
+
if (!(panelPlan.reserve > 0 && panelPlan.movedBeside.length === 0) || whole + panelPlan.reserve > input.viewport.width - offset * 2 + .5) {
|
|
540
|
+
setInPanel(true);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const layout = panelPlan ?? (canFold && pointing && !squeezed && root.offsetWidth > (fitsOpen ? open : least) + .5 ? require_layout.planSatellites(fitsOpen ? {
|
|
546
|
+
...input,
|
|
547
|
+
hostMin: void 0
|
|
548
|
+
} : input) : chosen);
|
|
549
|
+
const plannedHost = layout === panelPlan ? panelBox : layout === asOpen ? openBox : layout === asFolded ? foldedBox : input.host;
|
|
460
550
|
if (!tucked && afterTrip.current === "ending") afterTrip.current = false;
|
|
461
551
|
const tripInputs = `${placement} ${input.viewport.width}x${input.viewport.height}`;
|
|
462
552
|
if (afterTrip.current && (animate || tripHost.current?.inputs !== tripInputs)) tripHost.current = {
|
|
@@ -486,7 +576,9 @@ function SatellitesLayer({ host }) {
|
|
|
486
576
|
const reduced = require_timing.prefersReducedMotion();
|
|
487
577
|
const moving = animate && !reduced && typeof root.animate === "function";
|
|
488
578
|
const timings = require_measure.durations(out[0] ? elements.current.get(out[0].electron.id) : root);
|
|
579
|
+
const glide = moving ? Math.max(timings.change, settlesIn(root)) : timings.change;
|
|
489
580
|
const boxes = layout.boxes;
|
|
581
|
+
const byBottom = !vertical && placement.startsWith("bottom");
|
|
490
582
|
const hostAlong = (vertical ? root.offsetTop : root.offsetLeft) + layout.shift + (vertical ? root.offsetHeight : root.offsetWidth) / 2;
|
|
491
583
|
const alongOf = (box) => vertical ? box.top + box.height / 2 : box.left + box.width / 2;
|
|
492
584
|
const outer = placement.startsWith("bottom") || placement === "right";
|
|
@@ -504,12 +596,44 @@ function SatellitesLayer({ host }) {
|
|
|
504
596
|
width: root.offsetWidth,
|
|
505
597
|
height: root.offsetHeight
|
|
506
598
|
});
|
|
599
|
+
const along = !vertical && trip === layout ? plannedHost : void 0;
|
|
600
|
+
const splitAt = () => along ? {
|
|
601
|
+
...hostAt(),
|
|
602
|
+
left: along.left + applied.current.shift,
|
|
603
|
+
width: along.width
|
|
604
|
+
} : hostAt();
|
|
507
605
|
const hostCentre = () => vertical ? require_goo.atPoint(root.offsetLeft + root.offsetWidth / 2, hostAlong) : require_goo.atPoint(hostAlong, root.offsetTop + root.offsetHeight / 2);
|
|
606
|
+
if (animate && !reduced && !tucked && rejoining.current.size === 0) {
|
|
607
|
+
const joining = entries.filter((entry) => entry.presence === "hidden" && presences.current.get(entry.electron.id) === "compact" && (entry.leaving ? entry.electron.input.ending ?? host.electronEnding : "join") !== "pop").map((entry) => elements.current.get(entry.electron.id));
|
|
608
|
+
const actionsWere = presences.current.get(ACTIONS);
|
|
609
|
+
if (!atomOut && (actionsWere === "compact" || actionsWere === "rest")) joining.push(atomElement ?? void 0);
|
|
610
|
+
const going = joining.filter((element) => !!element);
|
|
611
|
+
const lasts = going.map((element) => {
|
|
612
|
+
const { fade, exit } = require_measure.durations(element);
|
|
613
|
+
return fade + exit;
|
|
614
|
+
});
|
|
615
|
+
const now = performance.now();
|
|
616
|
+
const until = now + Math.max(0, ...lasts);
|
|
617
|
+
if (lasts.length && until > joinUntil.current) {
|
|
618
|
+
joinUntil.current = until;
|
|
619
|
+
setTimeout(() => arrange.current(true), until - now + 20);
|
|
620
|
+
}
|
|
621
|
+
if (atomElement && going.includes(atomElement) && host.actionsStyle === "inside" && goingIn.current) {
|
|
622
|
+
const inPill = require_measure.durations(root);
|
|
623
|
+
const settled = until + inPill.fade + inPill.change + 50;
|
|
624
|
+
if (settled > spotsUntil.current) {
|
|
625
|
+
spotsUntil.current = settled;
|
|
626
|
+
setTimeout(() => arrange.current(true), settled - now + 20);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
const joinHold = performance.now() < joinUntil.current;
|
|
631
|
+
const spotHold = joinHold || performance.now() < spotsUntil.current;
|
|
508
632
|
const changing = (id, box) => !!box && presences.current.get(id) === "compact" && spots.current.has(id) && spots.current.get(id) !== spotOf(box);
|
|
509
633
|
const turning = !!atomElement && !!atomOut && layout.actionsAcross !== across.current && presences.current.get(ACTIONS) === "compact";
|
|
510
|
-
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;
|
|
634
|
+
const holding = animate && !reduced && !spotHold && (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;
|
|
511
635
|
const previous = applied.current;
|
|
512
|
-
const settling = holding || !animate && previous.placement !== void 0 && previous.placement !== placement;
|
|
636
|
+
const settling = holding || joinHold || !animate && previous.placement !== void 0 && previous.placement !== placement;
|
|
513
637
|
const vector = (shift, onSide) => onSide ? {
|
|
514
638
|
x: 0,
|
|
515
639
|
y: shift
|
|
@@ -524,15 +648,36 @@ function SatellitesLayer({ host }) {
|
|
|
524
648
|
if (!settling && (Math.abs(was.x - now.x) > .5 || Math.abs(was.y - now.y) > .5)) {
|
|
525
649
|
if (trip.shift) root.style.setProperty("translate", `${now.x}px ${now.y}px`);
|
|
526
650
|
else root.style.removeProperty("translate");
|
|
527
|
-
if (moving) {
|
|
651
|
+
if (moving && comingOut) {
|
|
652
|
+
const { fade, change } = require_measure.durations(root);
|
|
653
|
+
const from = `${was.x - now.x}px ${was.y - now.y}px`;
|
|
654
|
+
slide = {
|
|
655
|
+
x: was.x - now.x,
|
|
656
|
+
y: was.y - now.y,
|
|
657
|
+
duration: fade + change
|
|
658
|
+
};
|
|
659
|
+
root.animate([
|
|
660
|
+
{ translate: from },
|
|
661
|
+
{
|
|
662
|
+
translate: from,
|
|
663
|
+
offset: fade / (fade + change || 1)
|
|
664
|
+
},
|
|
665
|
+
{ translate: "0px 0px" }
|
|
666
|
+
], {
|
|
667
|
+
id: SHIFT,
|
|
668
|
+
duration: fade + change,
|
|
669
|
+
easing: "ease-in-out",
|
|
670
|
+
composite: "add"
|
|
671
|
+
});
|
|
672
|
+
} else if (moving) {
|
|
528
673
|
slide = {
|
|
529
674
|
x: was.x - now.x,
|
|
530
675
|
y: was.y - now.y,
|
|
531
|
-
duration:
|
|
676
|
+
duration: glide
|
|
532
677
|
};
|
|
533
678
|
root.animate([{ translate: `${was.x - now.x}px ${was.y - now.y}px` }, { translate: "0px 0px" }], {
|
|
534
679
|
id: SHIFT,
|
|
535
|
-
duration:
|
|
680
|
+
duration: glide,
|
|
536
681
|
easing: "ease-in-out",
|
|
537
682
|
composite: "add"
|
|
538
683
|
});
|
|
@@ -552,7 +697,16 @@ function SatellitesLayer({ host }) {
|
|
|
552
697
|
}
|
|
553
698
|
const waits = folding && performance.now() - foldingSince.current < timings.change * 2;
|
|
554
699
|
if (reserve && !waits && room !== `${reserve}px`) root.style.setProperty("--_mp-shift-x", `${reserve}px`);
|
|
555
|
-
else if (!reserve && previous.reserve && room === `${previous.reserve}px`)
|
|
700
|
+
else if (!reserve && previous.reserve && room === `${previous.reserve}px`) {
|
|
701
|
+
const before = root.offsetWidth;
|
|
702
|
+
root.style.removeProperty("--_mp-shift-x");
|
|
703
|
+
const after = root.offsetWidth;
|
|
704
|
+
if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
|
|
705
|
+
id: SHIFT,
|
|
706
|
+
duration: timings.change,
|
|
707
|
+
easing: "ease-in-out"
|
|
708
|
+
});
|
|
709
|
+
}
|
|
556
710
|
applied.current = {
|
|
557
711
|
shift: trip.shift,
|
|
558
712
|
reserve,
|
|
@@ -578,12 +732,12 @@ function SatellitesLayer({ host }) {
|
|
|
578
732
|
const settled = layout.actionsAcross === across.current;
|
|
579
733
|
const moved = !!box && spots.current.has(ACTIONS) && spots.current.get(ACTIONS) !== spotOf(box);
|
|
580
734
|
const sideChanged = moved && spots.current.get(ACTIONS).split(" ")[0] !== spotOf(box).split(" ")[0];
|
|
581
|
-
if (animate && atomOut && was === "compact" && !settled && !sideChanged && !reduced && !rejoining.current.has(ACTIONS)) {
|
|
735
|
+
if (animate && atomOut && was === "compact" && !settled && !sideChanged && !reduced && !rejoining.current.has(ACTIONS) && !spotHold) {
|
|
582
736
|
const turnTo = layout.actionsAcross;
|
|
583
737
|
const { fade, change } = require_measure.durations(atomElement);
|
|
584
738
|
turnFrom.current = atomPlaced.current ?? {
|
|
585
739
|
left: Number.parseFloat(atomElement.style.left),
|
|
586
|
-
top:
|
|
740
|
+
top: placedTop(atomElement, atomElement.offsetHeight),
|
|
587
741
|
width: atomElement.offsetWidth,
|
|
588
742
|
height: atomElement.offsetHeight
|
|
589
743
|
};
|
|
@@ -598,7 +752,7 @@ function SatellitesLayer({ host }) {
|
|
|
598
752
|
setActionsAcross(turnTo);
|
|
599
753
|
refresh();
|
|
600
754
|
}, fade + change + 20);
|
|
601
|
-
} else if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS)) {
|
|
755
|
+
} else if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS) && !spotHold) {
|
|
602
756
|
const turnTo = layout.actionsAcross;
|
|
603
757
|
rejoin(ACTIONS, atomElement, () => {
|
|
604
758
|
presences.current.set(ACTIONS, "hidden");
|
|
@@ -606,33 +760,32 @@ function SatellitesLayer({ host }) {
|
|
|
606
760
|
setActionsAcross(turnTo);
|
|
607
761
|
refresh();
|
|
608
762
|
});
|
|
609
|
-
} else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS)) setActionsAcross(layout.actionsAcross);
|
|
763
|
+
} else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS) && !spotHold) setActionsAcross(layout.actionsAcross);
|
|
610
764
|
const from = turnFrom.current;
|
|
611
765
|
if (turnPhase.current === "closing" && from) {
|
|
612
766
|
const width = atomElement.offsetWidth;
|
|
613
767
|
const height = atomElement.offsetHeight;
|
|
614
|
-
|
|
615
|
-
const top = vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top;
|
|
616
|
-
atomElement.style.left = `${left}px`;
|
|
617
|
-
atomElement.style.top = `${top}px`;
|
|
768
|
+
place(atomElement, vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2, vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top, height, byBottom);
|
|
618
769
|
}
|
|
619
770
|
if (animate && atomOut && actionsBox.current) {
|
|
620
771
|
const { wheel } = actionsBox.current;
|
|
621
772
|
const length = layout.actionsShown !== void 0 ? wheel.action + (layout.actionsShown - 1) * wheel.step : void 0;
|
|
622
773
|
if (length !== wheelLength) setWheelLength(length);
|
|
623
774
|
}
|
|
624
|
-
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding && (animate || !moved) && turnPhase.current !== "closing") {
|
|
775
|
+
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding && !joinHold && (animate || !moved) && turnPhase.current !== "closing") {
|
|
625
776
|
const before = alongOf(box) < hostAlong;
|
|
626
777
|
const width = atomElement.offsetWidth || box.width;
|
|
627
778
|
const height = atomElement.offsetHeight || box.height;
|
|
628
779
|
const from = {
|
|
629
780
|
left: Number.parseFloat(atomElement.style.left),
|
|
630
|
-
top:
|
|
781
|
+
top: placedTop(atomElement, atomPlaced.current?.height ?? height)
|
|
631
782
|
};
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
783
|
+
const placedAt = (width, height) => ({
|
|
784
|
+
left: vertical ? placement === "right" ? box.left + box.width - width : box.left : before ? box.left + box.width - width : box.left,
|
|
785
|
+
top: vertical ? before ? box.top + box.height - height : box.top : placement.startsWith("bottom") ? box.top + box.height - height : box.top
|
|
786
|
+
});
|
|
787
|
+
const { left, top } = placedAt(width, height);
|
|
788
|
+
place(atomElement, left, top, height, byBottom);
|
|
636
789
|
spots.current.set(ACTIONS, spotOf(box));
|
|
637
790
|
const placedLast = atomPlaced.current;
|
|
638
791
|
const facing = (at) => vertical ? before ? at.top + at.height : at.top : before ? at.left + at.width : at.left;
|
|
@@ -666,36 +819,23 @@ function SatellitesLayer({ host }) {
|
|
|
666
819
|
} else if (animate && (was === void 0 || was === "hidden")) {
|
|
667
820
|
require_morph.cancel(atomElement, require_morph.MORPH, true);
|
|
668
821
|
require_morph.cancel(atomElement, require_morph.MOVE);
|
|
669
|
-
drop(root, atomElement, "split", 0, require_measure.durations(atomElement).enter,
|
|
670
|
-
} else if (moving && was === "compact" && !withHost && Number.isFinite(from.left) && Number.isFinite(from.top) && Math.hypot(from.left - left, from.top - top) > gap) {
|
|
671
|
-
atomElement.style.left = `${from.left}px`;
|
|
672
|
-
atomElement.style.top = `${from.top}px`;
|
|
673
|
-
turnFrom.current = {
|
|
674
|
-
left: from.left,
|
|
675
|
-
top: from.top,
|
|
676
|
-
width,
|
|
677
|
-
height
|
|
678
|
-
};
|
|
679
|
-
turnPhase.current = "closing";
|
|
680
|
-
const { fade, change } = require_measure.durations(atomElement);
|
|
681
|
-
setTimeout(() => {
|
|
682
|
-
turnFrom.current = null;
|
|
683
|
-
turnPhase.current = "turned";
|
|
684
|
-
refresh();
|
|
685
|
-
}, fade + change + 20);
|
|
686
|
-
refresh();
|
|
822
|
+
drop(root, atomElement, "split", 0, require_measure.durations(atomElement).enter, splitAt, slide, settlesIn(root));
|
|
687
823
|
} else if (moving && (was === "compact" || was === "rest") && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
688
|
-
if (withHost && placedLast)
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
824
|
+
if (withHost && placedLast) {
|
|
825
|
+
atomElement.animate([{
|
|
826
|
+
width: `${placedLast.width}px`,
|
|
827
|
+
height: `${placedLast.height}px`
|
|
828
|
+
}, {
|
|
829
|
+
width: `${width}px`,
|
|
830
|
+
height: `${height}px`
|
|
831
|
+
}], {
|
|
832
|
+
id: SHIFT,
|
|
833
|
+
duration: glide,
|
|
834
|
+
easing: "ease-in-out"
|
|
835
|
+
});
|
|
836
|
+
const start = placedAt(placedLast.width, placedLast.height);
|
|
837
|
+
place(atomElement, start.left, start.top, placedLast.height, byBottom);
|
|
838
|
+
}
|
|
699
839
|
const along = withHost ? facing(placedLast) - facing({
|
|
700
840
|
left,
|
|
701
841
|
top,
|
|
@@ -720,7 +860,7 @@ function SatellitesLayer({ host }) {
|
|
|
720
860
|
});
|
|
721
861
|
atomElement.animate([{ translate: `${shift.x}px ${shift.y}px` }, { translate: "0px 0px" }], {
|
|
722
862
|
id: SHIFT,
|
|
723
|
-
duration:
|
|
863
|
+
duration: glide,
|
|
724
864
|
easing: "ease-in-out",
|
|
725
865
|
composite: "add"
|
|
726
866
|
});
|
|
@@ -728,36 +868,53 @@ function SatellitesLayer({ host }) {
|
|
|
728
868
|
}
|
|
729
869
|
} else if (animate && !atomOut && (was === "compact" || was === "rest")) {
|
|
730
870
|
const { fade, exit } = require_measure.durations(atomElement);
|
|
871
|
+
const { width: heldWidth, height: heldHeight } = atomElement.getBoundingClientRect();
|
|
872
|
+
const holdSize = () => {
|
|
873
|
+
if (reduced || typeof atomElement.animate !== "function" || heldWidth <= 0) return;
|
|
874
|
+
const size = {
|
|
875
|
+
width: `${heldWidth}px`,
|
|
876
|
+
height: `${heldHeight}px`,
|
|
877
|
+
minWidth: "0px",
|
|
878
|
+
maxWidth: "none"
|
|
879
|
+
};
|
|
880
|
+
atomElement.animate([size, size], {
|
|
881
|
+
id: require_goo.SPLIT,
|
|
882
|
+
duration: fade + exit,
|
|
883
|
+
fill: "forwards"
|
|
884
|
+
});
|
|
885
|
+
};
|
|
731
886
|
if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
|
|
732
887
|
require_handoff.setHandoff(host.store, "in");
|
|
733
|
-
drop(root, atomElement, "join", fade, exit
|
|
888
|
+
drop(root, atomElement, "join", fade, exit);
|
|
889
|
+
holdSize();
|
|
734
890
|
setTimeout(() => {
|
|
735
891
|
goingIn.current = false;
|
|
736
892
|
require_handoff.setHandoff(host.store, void 0);
|
|
737
893
|
refresh();
|
|
738
894
|
}, fade + exit + 20);
|
|
739
895
|
} else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + require_measure.durations(atomElement).change), hostCentre());
|
|
740
|
-
else
|
|
896
|
+
else {
|
|
897
|
+
drop(root, atomElement, "join", fade, exit);
|
|
898
|
+
holdSize();
|
|
899
|
+
}
|
|
741
900
|
spots.current.delete(ACTIONS);
|
|
742
901
|
}
|
|
743
902
|
if (animate && !rejoining.current.has(ACTIONS) && !holding && (settled || !atomOut)) presences.current.set(ACTIONS, actionsPresence);
|
|
744
903
|
}
|
|
745
904
|
const crossOf = rowOf;
|
|
746
|
-
const hopping = /* @__PURE__ */ new Set();
|
|
747
905
|
out.forEach(({ electron }, index) => {
|
|
748
906
|
const element = elements.current.get(electron.id);
|
|
749
907
|
const box = boxes[electron.id];
|
|
750
908
|
const was = presences.current.get(electron.id);
|
|
751
909
|
if (rejoining.current.has(electron.id)) return;
|
|
752
910
|
if (splitNext.current.delete(electron.id)) {
|
|
753
|
-
element.
|
|
754
|
-
element.style.top = `${box.top}px`;
|
|
911
|
+
place(element, box.left, box.top, box.height, byBottom);
|
|
755
912
|
rows.current.set(electron.id, String(crossOf(box)));
|
|
756
|
-
drop(root, element, "split", 0, require_measure.durations(element).enter,
|
|
913
|
+
drop(root, element, "split", 0, require_measure.durations(element).enter, splitAt, slide, settlesIn(root));
|
|
757
914
|
return;
|
|
758
915
|
}
|
|
759
916
|
const moved = was === "compact" && spots.current.has(electron.id) && spots.current.get(electron.id) !== spotOf(box);
|
|
760
|
-
if (animate && moved && !reduced) {
|
|
917
|
+
if (animate && moved && !reduced && !spotHold) {
|
|
761
918
|
spots.current.set(electron.id, spotOf(box));
|
|
762
919
|
rejoin(electron.id, element, () => {
|
|
763
920
|
splitNext.current.add(electron.id);
|
|
@@ -765,14 +922,13 @@ function SatellitesLayer({ host }) {
|
|
|
765
922
|
});
|
|
766
923
|
return;
|
|
767
924
|
}
|
|
768
|
-
if (holding || moved && !animate) return;
|
|
925
|
+
if (holding || joinHold || moved && (!animate || spotHold)) return;
|
|
769
926
|
spots.current.set(electron.id, spotOf(box));
|
|
770
927
|
const from = {
|
|
771
928
|
left: Number.parseFloat(element.style.left),
|
|
772
|
-
top:
|
|
929
|
+
top: placedTop(element, box.height)
|
|
773
930
|
};
|
|
774
|
-
element.
|
|
775
|
-
element.style.top = `${box.top}px`;
|
|
931
|
+
place(element, box.left, box.top, box.height, byBottom);
|
|
776
932
|
const row = String(crossOf(box));
|
|
777
933
|
const changedRow = rows.current.has(electron.id) && rows.current.get(electron.id) !== row;
|
|
778
934
|
rows.current.set(electron.id, row);
|
|
@@ -789,65 +945,9 @@ function SatellitesLayer({ host }) {
|
|
|
789
945
|
if (was === void 0 || was === "hidden") {
|
|
790
946
|
const before = out[index - 1];
|
|
791
947
|
const neighbour = before ? elements.current.get(before.electron.id) : void 0;
|
|
792
|
-
const anchor = neighbour && before &&
|
|
793
|
-
if (anchor === root) drop(root, element, "split", 0, require_measure.durations(element).enter,
|
|
948
|
+
const anchor = neighbour && before && nextTo(boxes[before.electron.id], box, gap) ? neighbour : root;
|
|
949
|
+
if (anchor === root) drop(root, element, "split", 0, require_measure.durations(element).enter, splitAt, slide, settlesIn(root));
|
|
794
950
|
else drop(anchor, element, "split", 0, require_measure.durations(element).enter);
|
|
795
|
-
} else if (moving && placed && Math.hypot(from.left - box.left, from.top - box.top) > gap && !reduced) {
|
|
796
|
-
hopping.add(electron.id);
|
|
797
|
-
const { fade, change } = require_measure.durations(element);
|
|
798
|
-
const options = {
|
|
799
|
-
id: SHIFT,
|
|
800
|
-
duration: fade * 2 + change
|
|
801
|
-
};
|
|
802
|
-
const at = `${from.left - box.left}px ${from.top - box.top}px`;
|
|
803
|
-
element.animate([
|
|
804
|
-
{
|
|
805
|
-
translate: at,
|
|
806
|
-
easing: "ease-in-out"
|
|
807
|
-
},
|
|
808
|
-
{
|
|
809
|
-
translate: at,
|
|
810
|
-
offset: .3,
|
|
811
|
-
easing: "ease-in-out"
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
translate: "0px 0px",
|
|
815
|
-
offset: .7
|
|
816
|
-
},
|
|
817
|
-
{ translate: "0px 0px" }
|
|
818
|
-
], {
|
|
819
|
-
...options,
|
|
820
|
-
composite: "add"
|
|
821
|
-
});
|
|
822
|
-
element.animate([
|
|
823
|
-
{
|
|
824
|
-
scale: 1,
|
|
825
|
-
easing: "ease-in"
|
|
826
|
-
},
|
|
827
|
-
{
|
|
828
|
-
scale: require_goo.DROPLET * 2,
|
|
829
|
-
offset: .3
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
scale: require_goo.DROPLET * 2,
|
|
833
|
-
offset: .7,
|
|
834
|
-
easing: "ease-out"
|
|
835
|
-
},
|
|
836
|
-
{ scale: 1 }
|
|
837
|
-
], options);
|
|
838
|
-
const content = [
|
|
839
|
-
{ opacity: 1 },
|
|
840
|
-
{
|
|
841
|
-
opacity: 0,
|
|
842
|
-
offset: .2
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
opacity: 0,
|
|
846
|
-
offset: .8
|
|
847
|
-
},
|
|
848
|
-
{ opacity: 1 }
|
|
849
|
-
];
|
|
850
|
-
for (const child of element.children) child.animate(content, options);
|
|
851
951
|
} else if (moving && placed && (Math.abs(from.left - box.left) > .5 || Math.abs(from.top - box.top) > .5)) {
|
|
852
952
|
slides.push({
|
|
853
953
|
element,
|
|
@@ -856,7 +956,7 @@ function SatellitesLayer({ host }) {
|
|
|
856
956
|
});
|
|
857
957
|
element.animate([{ translate: `${from.left - box.left}px ${from.top - box.top}px` }, { translate: "0px 0px" }], {
|
|
858
958
|
id: SHIFT,
|
|
859
|
-
duration:
|
|
959
|
+
duration: glide,
|
|
860
960
|
easing: "ease-in-out",
|
|
861
961
|
composite: "add"
|
|
862
962
|
});
|
|
@@ -879,7 +979,7 @@ function SatellitesLayer({ host }) {
|
|
|
879
979
|
if (ending === "pop") continue;
|
|
880
980
|
const { fade, change, exit } = require_measure.durations(element);
|
|
881
981
|
if (tucked) bud(root, element, "join", 0, Math.max(exit, fade + change), hostCentre());
|
|
882
|
-
else drop(root, element, "join", fade, exit
|
|
982
|
+
else drop(root, element, "join", fade, exit);
|
|
883
983
|
}
|
|
884
984
|
for (const entry of entries) presences.current.set(entry.electron.id, entry.presence);
|
|
885
985
|
}
|
|
@@ -1019,4 +1119,5 @@ function SatellitesLayer({ host }) {
|
|
|
1019
1119
|
}
|
|
1020
1120
|
|
|
1021
1121
|
exports.SatellitesLayer = SatellitesLayer;
|
|
1022
|
-
exports.drop = drop;
|
|
1122
|
+
exports.drop = drop;
|
|
1123
|
+
exports.settlesIn = settlesIn;
|