magic-pill 9.4.0-rc.1 → 9.4.0-rc.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 +4 -0
- package/dist/MagicPill/MagicPill.js +20 -2
- package/dist/MagicPill/MagicPill.mjs +21 -3
- package/dist/Pill/morph.js +0 -40
- package/dist/Pill/morph.mjs +1 -39
- package/dist/satellites/Actions.js +9 -0
- package/dist/satellites/Actions.mjs +9 -0
- package/dist/satellites/Satellites.js +44 -42
- package/dist/satellites/Satellites.mjs +45 -43
- package/dist/satellites/circle.js +165 -0
- package/dist/satellites/circle.mjs +161 -0
- package/dist/satellites/types.d.mts +5 -0
- package/dist/satellites/types.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
- **Beta:** a panel opening with no room for the electrons beside it waits for them to go into the pill, then opens to its full length in one motion: it opened part way as they went in, then widened again once they were in
|
|
86
86
|
- A panel closing gives the focus back to its trigger before the pill measures the size it closes to, so it closes in one motion with the label the focus opens: it closed without it, then grew again as the label opened (an electron beside it went in, then out again)
|
|
87
87
|
- A form in the pill itself, short of room, gives its submit button's live label ("Adding you…") the room while it's sent, and the field takes it back once it's done or refused, in one resize each way: the label was folded and cut, then squeezed as it opened
|
|
88
|
+
- **Beta:** a panel opening while the electrons go into the pill for it (no room for them beside it) waits for them with the pill as it was, then opens as it always does: it showed its panel in the small pill while they went in
|
|
89
|
+
- **Beta:** the page's actions in a row of their own above or below the pill (`actionsSide="beside"`) resize for another list from the end lined up with the pill: their new size jumped in at once
|
|
90
|
+
- **Beta:** the page's actions in the pill, cut short by their wheel, no longer grow for a moment the first time another list comes: their row resized from the length it had before the wheel cut it, then shrank back
|
|
91
|
+
- **Beta:** the page's actions switched into the pill, left behind by a page change, or going in for a panel that has no room for them beside it, close to a circle where they stand, then go in as one (the pill waits for them before it takes the next page's shape, and the panel before it opens); switched out, or back on their page, they come out as a circle and open to their pill, then their content shows. The circle is at the pill's level: a column of actions beside a bottom pill closes down to it and goes in from there. They went in as a small pill, at their own proportions
|
|
88
92
|
|
|
89
93
|
### Changed
|
|
90
94
|
- **Beta:** `actionsWheel` is on by default for the page's actions in the pill (`actionsStyle="inside"`): short of room, they show what fits next to the navbar and turn the rest in their wheel; `false` shows them all. Still off by default for a pill of their own
|
|
@@ -252,6 +252,23 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
252
252
|
presence: next
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
+
const wantsPanel = displayed.presence === "panel";
|
|
256
|
+
const [panelGate, setPanelGate] = (0, react.useState)(wantsPanel ? "open" : "closed");
|
|
257
|
+
if (satellites && wantsPanel && panelGate === "closed") setPanelGate("pending");
|
|
258
|
+
if (!wantsPanel && panelGate !== "closed") setPanelGate("closed");
|
|
259
|
+
const satellitesHoldPanel = (0, react.useRef)(false);
|
|
260
|
+
const holdPanel = (0, react.useCallback)((hold) => {
|
|
261
|
+
satellitesHoldPanel.current = hold;
|
|
262
|
+
if (!hold) setPanelGate((gate) => gate === "closed" ? gate : "open");
|
|
263
|
+
}, []);
|
|
264
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
265
|
+
if (panelGate === "pending") setPanelGate(satellitesHoldPanel.current ? "waiting" : "open");
|
|
266
|
+
}, [panelGate]);
|
|
267
|
+
const shownBeforePanel = (0, react.useRef)(displayed.presence === "panel" ? "compact" : displayed.presence);
|
|
268
|
+
const pillPresence = satellites && wantsPanel && panelGate !== "open" ? shownBeforePanel.current : displayed.presence;
|
|
269
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
270
|
+
if (pillPresence !== "panel") shownBeforePanel.current = pillPresence;
|
|
271
|
+
}, [pillPresence]);
|
|
255
272
|
const satelliteHost = satellites ? {
|
|
256
273
|
name,
|
|
257
274
|
store,
|
|
@@ -260,7 +277,8 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
260
277
|
vertical: isVertical,
|
|
261
278
|
pathname,
|
|
262
279
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !require_choreography.isOpen(displayed.presence),
|
|
263
|
-
panel:
|
|
280
|
+
panel: wantsPanel,
|
|
281
|
+
holdPanel,
|
|
264
282
|
linkComponent,
|
|
265
283
|
variant,
|
|
266
284
|
theme: rest.theme,
|
|
@@ -330,7 +348,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
330
348
|
"--_mp-sidebar-width": `${sidebarWidth.current}px`
|
|
331
349
|
} : rest.style,
|
|
332
350
|
variant: sceneVariant,
|
|
333
|
-
presence:
|
|
351
|
+
presence: pillPresence,
|
|
334
352
|
onPresenceChange: presenceHandler(displayedRef, setDisplayed),
|
|
335
353
|
onPointerEnter: (event) => {
|
|
336
354
|
onPointerEnter?.(event);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Fragment, forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Pill from "../Pill/Pill.mjs";
|
|
5
5
|
import { PillIcon } from "../Pill/parts.mjs";
|
|
6
6
|
import { NotificationContent } from "../PillNotification/PillNotification.mjs";
|
|
@@ -252,6 +252,23 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
252
252
|
presence: next
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
+
const wantsPanel = displayed.presence === "panel";
|
|
256
|
+
const [panelGate, setPanelGate] = useState(wantsPanel ? "open" : "closed");
|
|
257
|
+
if (satellites && wantsPanel && panelGate === "closed") setPanelGate("pending");
|
|
258
|
+
if (!wantsPanel && panelGate !== "closed") setPanelGate("closed");
|
|
259
|
+
const satellitesHoldPanel = useRef(false);
|
|
260
|
+
const holdPanel = useCallback((hold) => {
|
|
261
|
+
satellitesHoldPanel.current = hold;
|
|
262
|
+
if (!hold) setPanelGate((gate) => gate === "closed" ? gate : "open");
|
|
263
|
+
}, []);
|
|
264
|
+
useIsomorphicLayoutEffect(() => {
|
|
265
|
+
if (panelGate === "pending") setPanelGate(satellitesHoldPanel.current ? "waiting" : "open");
|
|
266
|
+
}, [panelGate]);
|
|
267
|
+
const shownBeforePanel = useRef(displayed.presence === "panel" ? "compact" : displayed.presence);
|
|
268
|
+
const pillPresence = satellites && wantsPanel && panelGate !== "open" ? shownBeforePanel.current : displayed.presence;
|
|
269
|
+
useIsomorphicLayoutEffect(() => {
|
|
270
|
+
if (pillPresence !== "panel") shownBeforePanel.current = pillPresence;
|
|
271
|
+
}, [pillPresence]);
|
|
255
272
|
const satelliteHost = satellites ? {
|
|
256
273
|
name,
|
|
257
274
|
store,
|
|
@@ -260,7 +277,8 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
260
277
|
vertical: isVertical,
|
|
261
278
|
pathname,
|
|
262
279
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !isOpen(displayed.presence),
|
|
263
|
-
panel:
|
|
280
|
+
panel: wantsPanel,
|
|
281
|
+
holdPanel,
|
|
264
282
|
linkComponent,
|
|
265
283
|
variant,
|
|
266
284
|
theme: rest.theme,
|
|
@@ -330,7 +348,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
330
348
|
"--_mp-sidebar-width": `${sidebarWidth.current}px`
|
|
331
349
|
} : rest.style,
|
|
332
350
|
variant: sceneVariant,
|
|
333
|
-
presence:
|
|
351
|
+
presence: pillPresence,
|
|
334
352
|
onPresenceChange: presenceHandler(displayedRef, setDisplayed),
|
|
335
353
|
onPointerEnter: (event) => {
|
|
336
354
|
onPointerEnter?.(event);
|
package/dist/Pill/morph.js
CHANGED
|
@@ -440,44 +440,6 @@ function readPanel(pill) {
|
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
443
|
-
* A panel opening, held at its start (`holdOpening`) while what makes room for it moves out of the
|
|
444
|
-
* way (an electron going into the pill, magic-pill/satellites), then played again (`replayOpening`)
|
|
445
|
-
* to the size it has once that room is free: one motion. It opened part way as the electron went
|
|
446
|
-
* in, then widened again once it was in (A36).
|
|
447
|
-
*/
|
|
448
|
-
function holdOpening(element) {
|
|
449
|
-
let held = false;
|
|
450
|
-
for (const animation of element.getAnimations?.({ subtree: true }) ?? []) {
|
|
451
|
-
if (animation.id !== "mp-morph") continue;
|
|
452
|
-
animation.pause();
|
|
453
|
-
animation.currentTime = 0;
|
|
454
|
-
held = true;
|
|
455
|
-
}
|
|
456
|
-
return held;
|
|
457
|
-
}
|
|
458
|
-
/** The opening `holdOpening` held, from where it's held to the pill's size now. Whether one was held. */
|
|
459
|
-
function replayOpening(element) {
|
|
460
|
-
if ((element.getAnimations?.({ subtree: true }) ?? []).filter((animation) => animation.id === "mp-morph" && animation.playState === "paused").length === 0) return false;
|
|
461
|
-
const from = readSize(element);
|
|
462
|
-
cancel(element, MORPH, true);
|
|
463
|
-
if (require_timing.prefersReducedMotion()) return true;
|
|
464
|
-
const to = readSettledSize(element);
|
|
465
|
-
const panel = readPanel(element);
|
|
466
|
-
const plan = planMorph(from, to, "compact", "panel", readMorphTimings(element), panel?.box);
|
|
467
|
-
if (!plan) return true;
|
|
468
|
-
const options = {
|
|
469
|
-
...plan.options,
|
|
470
|
-
id: MORPH
|
|
471
|
-
};
|
|
472
|
-
element.animate(plan.pill, options);
|
|
473
|
-
if (plan.panel && panel) {
|
|
474
|
-
panel.element.animate(plan.panel, options);
|
|
475
|
-
const footer = panel.element.querySelector("[data-mp=\"panel-footer\"]");
|
|
476
|
-
if (footer) footer.animate([{ position: "relative" }, { position: "relative" }], options);
|
|
477
|
-
}
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
443
|
* Animates the pill's size on each presence change. Off for `unstyled` pills,
|
|
482
444
|
* with reduced motion, and where the Web Animations API is missing.
|
|
483
445
|
*/
|
|
@@ -665,12 +627,10 @@ exports.PlacementWatch = PlacementWatch;
|
|
|
665
627
|
exports.animateMove = animateMove;
|
|
666
628
|
exports.cancel = cancel;
|
|
667
629
|
exports.captureSwap = captureSwap;
|
|
668
|
-
exports.holdOpening = holdOpening;
|
|
669
630
|
exports.onCopy = onCopy;
|
|
670
631
|
exports.planExit = planExit;
|
|
671
632
|
exports.planMorph = planMorph;
|
|
672
633
|
exports.planSwap = planSwap;
|
|
673
634
|
exports.playSwap = playSwap;
|
|
674
635
|
exports.readMorphTimings = readMorphTimings;
|
|
675
|
-
exports.replayOpening = replayOpening;
|
|
676
636
|
exports.useSizeMorph = useSizeMorph;
|
package/dist/Pill/morph.mjs
CHANGED
|
@@ -440,44 +440,6 @@ function readPanel(pill) {
|
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
443
|
-
* A panel opening, held at its start (`holdOpening`) while what makes room for it moves out of the
|
|
444
|
-
* way (an electron going into the pill, magic-pill/satellites), then played again (`replayOpening`)
|
|
445
|
-
* to the size it has once that room is free: one motion. It opened part way as the electron went
|
|
446
|
-
* in, then widened again once it was in (A36).
|
|
447
|
-
*/
|
|
448
|
-
function holdOpening(element) {
|
|
449
|
-
let held = false;
|
|
450
|
-
for (const animation of element.getAnimations?.({ subtree: true }) ?? []) {
|
|
451
|
-
if (animation.id !== "mp-morph") continue;
|
|
452
|
-
animation.pause();
|
|
453
|
-
animation.currentTime = 0;
|
|
454
|
-
held = true;
|
|
455
|
-
}
|
|
456
|
-
return held;
|
|
457
|
-
}
|
|
458
|
-
/** The opening `holdOpening` held, from where it's held to the pill's size now. Whether one was held. */
|
|
459
|
-
function replayOpening(element) {
|
|
460
|
-
if ((element.getAnimations?.({ subtree: true }) ?? []).filter((animation) => animation.id === "mp-morph" && animation.playState === "paused").length === 0) return false;
|
|
461
|
-
const from = readSize(element);
|
|
462
|
-
cancel(element, MORPH, true);
|
|
463
|
-
if (prefersReducedMotion()) return true;
|
|
464
|
-
const to = readSettledSize(element);
|
|
465
|
-
const panel = readPanel(element);
|
|
466
|
-
const plan = planMorph(from, to, "compact", "panel", readMorphTimings(element), panel?.box);
|
|
467
|
-
if (!plan) return true;
|
|
468
|
-
const options = {
|
|
469
|
-
...plan.options,
|
|
470
|
-
id: MORPH
|
|
471
|
-
};
|
|
472
|
-
element.animate(plan.pill, options);
|
|
473
|
-
if (plan.panel && panel) {
|
|
474
|
-
panel.element.animate(plan.panel, options);
|
|
475
|
-
const footer = panel.element.querySelector("[data-mp=\"panel-footer\"]");
|
|
476
|
-
if (footer) footer.animate([{ position: "relative" }, { position: "relative" }], options);
|
|
477
|
-
}
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
443
|
* Animates the pill's size on each presence change. Off for `unstyled` pills,
|
|
482
444
|
* with reduced motion, and where the Web Animations API is missing.
|
|
483
445
|
*/
|
|
@@ -656,4 +618,4 @@ var PlacementWatch = class extends Component {
|
|
|
656
618
|
}
|
|
657
619
|
};
|
|
658
620
|
|
|
659
|
-
export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap,
|
|
621
|
+
export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, useSizeMorph };
|
|
@@ -200,6 +200,15 @@ const keyOf = (item) => item.id ?? item.label;
|
|
|
200
200
|
*/
|
|
201
201
|
function useInsideResize(items, track, resizes) {
|
|
202
202
|
const length = (0, react.useRef)(void 0);
|
|
203
|
+
(0, react.useEffect)(() => {
|
|
204
|
+
const row = track.current;
|
|
205
|
+
if (!row || typeof ResizeObserver === "undefined") return;
|
|
206
|
+
const observer = new ResizeObserver(() => {
|
|
207
|
+
length.current = getComputedStyle(row).flexDirection.startsWith("column") ? row.offsetHeight : row.offsetWidth;
|
|
208
|
+
});
|
|
209
|
+
observer.observe(row);
|
|
210
|
+
return () => observer.disconnect();
|
|
211
|
+
}, [track]);
|
|
203
212
|
require_react.useIsomorphicLayoutEffect(() => {
|
|
204
213
|
const row = track.current;
|
|
205
214
|
if (!row) return;
|
|
@@ -200,6 +200,15 @@ const keyOf = (item) => item.id ?? item.label;
|
|
|
200
200
|
*/
|
|
201
201
|
function useInsideResize(items, track, resizes) {
|
|
202
202
|
const length = useRef(void 0);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
const row = track.current;
|
|
205
|
+
if (!row || typeof ResizeObserver === "undefined") return;
|
|
206
|
+
const observer = new ResizeObserver(() => {
|
|
207
|
+
length.current = getComputedStyle(row).flexDirection.startsWith("column") ? row.offsetHeight : row.offsetWidth;
|
|
208
|
+
});
|
|
209
|
+
observer.observe(row);
|
|
210
|
+
return () => observer.disconnect();
|
|
211
|
+
}, [track]);
|
|
203
212
|
useIsomorphicLayoutEffect(() => {
|
|
204
213
|
const row = track.current;
|
|
205
214
|
if (!row) return;
|
|
@@ -16,6 +16,7 @@ const require_handoff = require("./handoff.js");
|
|
|
16
16
|
const require_measure = require("./measure.js");
|
|
17
17
|
const require_Orbitals = require("./Orbitals.js");
|
|
18
18
|
const require_Actions = require("./Actions.js");
|
|
19
|
+
const require_circle = require("./circle.js");
|
|
19
20
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
20
21
|
|
|
21
22
|
// src/satellites/Satellites.tsx
|
|
@@ -93,9 +94,11 @@ const AGAINST = 24;
|
|
|
93
94
|
* into it the same way played backwards. `at`: where the anchor is going, if it's moving; `slide`:
|
|
94
95
|
* how it gets there, which a droplet coming out follows while it's still attached (from its edge
|
|
95
96
|
* where it is to its edge where it goes), or it would come out where the anchor no longer is.
|
|
97
|
+
* `spot`: the part of its box it comes out to and goes in from (the page's actions' circle, circle.ts).
|
|
96
98
|
*/
|
|
97
|
-
function drop(anchor, element, kind, delay, duration, at, slide, settles = 0) {
|
|
98
|
-
const
|
|
99
|
+
function drop(anchor, element, kind, delay, duration, at, slide, settles = 0, spot) {
|
|
100
|
+
const edge = require_goo.atEdgeOf(anchor, at, require_goo.DROPLET);
|
|
101
|
+
const from = spot ? (rect, measured) => edge(spot(rect), measured) : edge;
|
|
99
102
|
const animates = !require_timing.prefersReducedMotion() && typeof element.animate === "function";
|
|
100
103
|
const moves = !!slide && kind === "split" && animates;
|
|
101
104
|
let wait = kind === "split" && animates ? settles : 0;
|
|
@@ -540,6 +543,20 @@ function SatellitesLayer({ host }) {
|
|
|
540
543
|
});
|
|
541
544
|
if (!(panelPlan.reserve > 0 && panelPlan.movedBeside.length === 0) || whole + panelPlan.reserve > input.viewport.width - offset * 2 + .5) {
|
|
542
545
|
setInPanel(true);
|
|
546
|
+
if (animate && !require_timing.prefersReducedMotion() && host.holdPanel && !panelHeld.current) {
|
|
547
|
+
panelHeld.current = true;
|
|
548
|
+
host.holdPanel(true);
|
|
549
|
+
const { fade, change, exit } = require_measure.durations(root);
|
|
550
|
+
const release = host.holdPanel;
|
|
551
|
+
setTimeout(() => {
|
|
552
|
+
if (!panelHeld.current) return;
|
|
553
|
+
panelHeld.current = false;
|
|
554
|
+
release(false);
|
|
555
|
+
}, require_circle.closingTime({
|
|
556
|
+
fade,
|
|
557
|
+
change
|
|
558
|
+
}) + exit + 200);
|
|
559
|
+
}
|
|
543
560
|
return;
|
|
544
561
|
}
|
|
545
562
|
}
|
|
@@ -604,6 +621,7 @@ function SatellitesLayer({ host }) {
|
|
|
604
621
|
left: along.left + applied.current.shift,
|
|
605
622
|
width: along.width
|
|
606
623
|
} : hostAt();
|
|
624
|
+
const level = vertical ? placement === "right" ? "right" : "left" : placement.startsWith("bottom") ? "bottom" : "top";
|
|
607
625
|
const hostCentre = () => vertical ? require_goo.atPoint(root.offsetLeft + root.offsetWidth / 2, hostAlong) : require_goo.atPoint(hostAlong, root.offsetTop + root.offsetHeight / 2);
|
|
608
626
|
if (animate && !reduced && !tucked && rejoining.current.size === 0) {
|
|
609
627
|
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));
|
|
@@ -611,8 +629,11 @@ function SatellitesLayer({ host }) {
|
|
|
611
629
|
if (!atomOut && (actionsWere === "compact" || actionsWere === "rest")) joining.push(atomElement ?? void 0);
|
|
612
630
|
const going = joining.filter((element) => !!element);
|
|
613
631
|
const lasts = going.map((element) => {
|
|
614
|
-
const { fade, exit } = require_measure.durations(element);
|
|
615
|
-
return
|
|
632
|
+
const { fade, change, exit } = require_measure.durations(element);
|
|
633
|
+
return element === atomElement ? require_circle.closingTime({
|
|
634
|
+
fade,
|
|
635
|
+
change
|
|
636
|
+
}) + exit : fade + exit;
|
|
616
637
|
});
|
|
617
638
|
const now = performance.now();
|
|
618
639
|
const until = now + Math.max(0, ...lasts);
|
|
@@ -705,7 +726,7 @@ function SatellitesLayer({ host }) {
|
|
|
705
726
|
const after = root.offsetWidth;
|
|
706
727
|
if (panelHeld.current) {
|
|
707
728
|
panelHeld.current = false;
|
|
708
|
-
|
|
729
|
+
host.holdPanel?.(false);
|
|
709
730
|
} else if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
|
|
710
731
|
id: require_measure.SHIFT,
|
|
711
732
|
duration: timings.change,
|
|
@@ -800,9 +821,14 @@ function SatellitesLayer({ host }) {
|
|
|
800
821
|
if (length !== wheelLength) setWheelLength(length);
|
|
801
822
|
}
|
|
802
823
|
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding && !joinHold && (animate || !moved) && turnPhase.current !== "closing") {
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
const
|
|
824
|
+
const hostLength = vertical ? root.offsetHeight : root.offsetWidth;
|
|
825
|
+
const hostStart = hostAlong - hostLength / 2;
|
|
826
|
+
const boxStart = vertical ? box.top : box.left;
|
|
827
|
+
const boxEnd = boxStart + (vertical ? box.height : box.width);
|
|
828
|
+
const before = boxEnd > hostStart + .5 && boxStart < hostStart + hostLength - .5 ? Math.abs(boxEnd - (hostStart + hostLength)) < Math.abs(boxStart - hostStart) : alongOf(box) < hostAlong;
|
|
829
|
+
const asCircle = require_circle.drawnAsCircle(atomElement);
|
|
830
|
+
const width = !asCircle && atomElement.offsetWidth || box.width;
|
|
831
|
+
const height = !asCircle && atomElement.offsetHeight || box.height;
|
|
806
832
|
const from = {
|
|
807
833
|
left: Number.parseFloat(atomElement.style.left),
|
|
808
834
|
top: placedTop(atomElement, atomPlaced.current?.height ?? height)
|
|
@@ -846,7 +872,8 @@ function SatellitesLayer({ host }) {
|
|
|
846
872
|
} else if (animate && (was === void 0 || was === "hidden")) {
|
|
847
873
|
require_morph.cancel(atomElement, require_morph.MORPH, true);
|
|
848
874
|
require_morph.cancel(atomElement, require_morph.MOVE);
|
|
849
|
-
drop(root, atomElement, "split", 0, require_measure.durations(atomElement).enter, splitAt, slide, settlesIn(root));
|
|
875
|
+
drop(root, atomElement, "split", 0, require_measure.durations(atomElement).enter, splitAt, slide, settlesIn(root), require_circle.circleSpot(level));
|
|
876
|
+
require_circle.openFromCircle(atomElement, require_measure.durations(atomElement), require_measure.durations(atomElement).enter, level);
|
|
850
877
|
} else if (moving && (was === "compact" || was === "rest") && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
851
878
|
if (withHost && placedLast) {
|
|
852
879
|
atomElement.animate([{
|
|
@@ -894,38 +921,24 @@ function SatellitesLayer({ host }) {
|
|
|
894
921
|
}
|
|
895
922
|
}
|
|
896
923
|
} else if (animate && !atomOut && (was === "compact" || was === "rest")) {
|
|
897
|
-
const
|
|
924
|
+
const timings = require_measure.durations(atomElement);
|
|
925
|
+
const { fade, exit } = timings;
|
|
898
926
|
const heldWidth = atomElement.offsetWidth;
|
|
899
927
|
const heldHeight = atomElement.offsetHeight;
|
|
900
|
-
const holdSize = (duration) => {
|
|
901
|
-
if (reduced || typeof atomElement.animate !== "function" || heldWidth <= 0) return;
|
|
902
|
-
const size = {
|
|
903
|
-
width: `${heldWidth}px`,
|
|
904
|
-
height: `${heldHeight}px`,
|
|
905
|
-
minWidth: "0px",
|
|
906
|
-
maxWidth: "none",
|
|
907
|
-
minHeight: "0px",
|
|
908
|
-
maxHeight: "none"
|
|
909
|
-
};
|
|
910
|
-
atomElement.animate([size, size], {
|
|
911
|
-
id: require_goo.SPLIT,
|
|
912
|
-
duration,
|
|
913
|
-
fill: "forwards"
|
|
914
|
-
});
|
|
915
|
-
};
|
|
916
928
|
if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
|
|
917
929
|
require_handoff.setHandoff(host.store, "in");
|
|
918
|
-
|
|
919
|
-
|
|
930
|
+
const closing = require_circle.closingTime(timings);
|
|
931
|
+
drop(root, atomElement, "join", closing, exit, void 0, void 0, 0, require_circle.circleSpot(level));
|
|
932
|
+
require_circle.closeToCircle(atomElement, heldWidth, heldHeight, exit, level, timings);
|
|
920
933
|
setTimeout(() => {
|
|
921
934
|
goingIn.current = false;
|
|
922
935
|
require_handoff.setHandoff(host.store, void 0);
|
|
923
936
|
refresh();
|
|
924
|
-
},
|
|
937
|
+
}, closing + exit + 20);
|
|
925
938
|
} else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + require_measure.durations(atomElement).change), hostCentre());
|
|
926
939
|
else {
|
|
927
|
-
drop(root, atomElement, "join", 0,
|
|
928
|
-
|
|
940
|
+
drop(root, atomElement, "join", require_circle.closingTime(timings), exit, void 0, void 0, 0, require_circle.circleSpot(level));
|
|
941
|
+
require_circle.closeToCircle(atomElement, heldWidth, heldHeight, exit, level, timings);
|
|
929
942
|
presences.current.set(ACTIONS, "hidden");
|
|
930
943
|
}
|
|
931
944
|
spots.current.delete(ACTIONS);
|
|
@@ -1001,17 +1014,6 @@ function SatellitesLayer({ host }) {
|
|
|
1001
1014
|
}
|
|
1002
1015
|
}));
|
|
1003
1016
|
if (passing.size > 1) require_goo.playNecks([...passing], timings.change);
|
|
1004
|
-
if (animate && moving && panelTucked && !panelHeld.current && entries.some((entry) => presences.current.get(entry.electron.id) === "compact")) {
|
|
1005
|
-
if (require_morph.holdOpening(root)) {
|
|
1006
|
-
panelHeld.current = true;
|
|
1007
|
-
const { fade, exit } = require_measure.durations(root);
|
|
1008
|
-
setTimeout(() => {
|
|
1009
|
-
if (!panelHeld.current) return;
|
|
1010
|
-
panelHeld.current = false;
|
|
1011
|
-
require_morph.replayOpening(root);
|
|
1012
|
-
}, fade + exit + 200);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
1017
|
if (!host.panel) panelHeld.current = false;
|
|
1016
1018
|
if (animate && !holding) {
|
|
1017
1019
|
for (const entry of entries) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEffect, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import Pill from "../Pill/Pill.mjs";
|
|
5
5
|
import { DROPLET, SPLIT, atEdgeOf, atPoint, playNecks, playOrbit } from "../Pill/goo.mjs";
|
|
6
|
-
import { MORPH, MOVE, cancel
|
|
6
|
+
import { MORPH, MOVE, cancel } from "../Pill/morph.mjs";
|
|
7
7
|
import { PillProgress } from "../Pill/PillProgress.mjs";
|
|
8
8
|
import { findActiveIndex } from "../PillNavbar/matchPath.mjs";
|
|
9
9
|
import { foldedWidth, openSize, unfoldedWidth } from "../PillNavbar/room.mjs";
|
|
@@ -16,6 +16,7 @@ import { setHandoff, useHandoff } from "./handoff.mjs";
|
|
|
16
16
|
import { SHIFT, durations, otherPills, toPixels } from "./measure.mjs";
|
|
17
17
|
import { Orbitals } from "./Orbitals.mjs";
|
|
18
18
|
import { ActionList, useHostActions } from "./Actions.mjs";
|
|
19
|
+
import { circleSpot, closeToCircle, closingTime, drawnAsCircle, openFromCircle } from "./circle.mjs";
|
|
19
20
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
20
21
|
|
|
21
22
|
// src/satellites/Satellites.tsx
|
|
@@ -93,9 +94,11 @@ const AGAINST = 24;
|
|
|
93
94
|
* into it the same way played backwards. `at`: where the anchor is going, if it's moving; `slide`:
|
|
94
95
|
* how it gets there, which a droplet coming out follows while it's still attached (from its edge
|
|
95
96
|
* where it is to its edge where it goes), or it would come out where the anchor no longer is.
|
|
97
|
+
* `spot`: the part of its box it comes out to and goes in from (the page's actions' circle, circle.ts).
|
|
96
98
|
*/
|
|
97
|
-
function drop(anchor, element, kind, delay, duration, at, slide, settles = 0) {
|
|
98
|
-
const
|
|
99
|
+
function drop(anchor, element, kind, delay, duration, at, slide, settles = 0, spot) {
|
|
100
|
+
const edge = atEdgeOf(anchor, at, DROPLET);
|
|
101
|
+
const from = spot ? (rect, measured) => edge(spot(rect), measured) : edge;
|
|
99
102
|
const animates = !prefersReducedMotion() && typeof element.animate === "function";
|
|
100
103
|
const moves = !!slide && kind === "split" && animates;
|
|
101
104
|
let wait = kind === "split" && animates ? settles : 0;
|
|
@@ -540,6 +543,20 @@ function SatellitesLayer({ host }) {
|
|
|
540
543
|
});
|
|
541
544
|
if (!(panelPlan.reserve > 0 && panelPlan.movedBeside.length === 0) || whole + panelPlan.reserve > input.viewport.width - offset * 2 + .5) {
|
|
542
545
|
setInPanel(true);
|
|
546
|
+
if (animate && !prefersReducedMotion() && host.holdPanel && !panelHeld.current) {
|
|
547
|
+
panelHeld.current = true;
|
|
548
|
+
host.holdPanel(true);
|
|
549
|
+
const { fade, change, exit } = durations(root);
|
|
550
|
+
const release = host.holdPanel;
|
|
551
|
+
setTimeout(() => {
|
|
552
|
+
if (!panelHeld.current) return;
|
|
553
|
+
panelHeld.current = false;
|
|
554
|
+
release(false);
|
|
555
|
+
}, closingTime({
|
|
556
|
+
fade,
|
|
557
|
+
change
|
|
558
|
+
}) + exit + 200);
|
|
559
|
+
}
|
|
543
560
|
return;
|
|
544
561
|
}
|
|
545
562
|
}
|
|
@@ -604,6 +621,7 @@ function SatellitesLayer({ host }) {
|
|
|
604
621
|
left: along.left + applied.current.shift,
|
|
605
622
|
width: along.width
|
|
606
623
|
} : hostAt();
|
|
624
|
+
const level = vertical ? placement === "right" ? "right" : "left" : placement.startsWith("bottom") ? "bottom" : "top";
|
|
607
625
|
const hostCentre = () => vertical ? atPoint(root.offsetLeft + root.offsetWidth / 2, hostAlong) : atPoint(hostAlong, root.offsetTop + root.offsetHeight / 2);
|
|
608
626
|
if (animate && !reduced && !tucked && rejoining.current.size === 0) {
|
|
609
627
|
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));
|
|
@@ -611,8 +629,11 @@ function SatellitesLayer({ host }) {
|
|
|
611
629
|
if (!atomOut && (actionsWere === "compact" || actionsWere === "rest")) joining.push(atomElement ?? void 0);
|
|
612
630
|
const going = joining.filter((element) => !!element);
|
|
613
631
|
const lasts = going.map((element) => {
|
|
614
|
-
const { fade, exit } = durations(element);
|
|
615
|
-
return
|
|
632
|
+
const { fade, change, exit } = durations(element);
|
|
633
|
+
return element === atomElement ? closingTime({
|
|
634
|
+
fade,
|
|
635
|
+
change
|
|
636
|
+
}) + exit : fade + exit;
|
|
616
637
|
});
|
|
617
638
|
const now = performance.now();
|
|
618
639
|
const until = now + Math.max(0, ...lasts);
|
|
@@ -705,7 +726,7 @@ function SatellitesLayer({ host }) {
|
|
|
705
726
|
const after = root.offsetWidth;
|
|
706
727
|
if (panelHeld.current) {
|
|
707
728
|
panelHeld.current = false;
|
|
708
|
-
|
|
729
|
+
host.holdPanel?.(false);
|
|
709
730
|
} else if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
|
|
710
731
|
id: SHIFT,
|
|
711
732
|
duration: timings.change,
|
|
@@ -800,9 +821,14 @@ function SatellitesLayer({ host }) {
|
|
|
800
821
|
if (length !== wheelLength) setWheelLength(length);
|
|
801
822
|
}
|
|
802
823
|
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding && !joinHold && (animate || !moved) && turnPhase.current !== "closing") {
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
const
|
|
824
|
+
const hostLength = vertical ? root.offsetHeight : root.offsetWidth;
|
|
825
|
+
const hostStart = hostAlong - hostLength / 2;
|
|
826
|
+
const boxStart = vertical ? box.top : box.left;
|
|
827
|
+
const boxEnd = boxStart + (vertical ? box.height : box.width);
|
|
828
|
+
const before = boxEnd > hostStart + .5 && boxStart < hostStart + hostLength - .5 ? Math.abs(boxEnd - (hostStart + hostLength)) < Math.abs(boxStart - hostStart) : alongOf(box) < hostAlong;
|
|
829
|
+
const asCircle = drawnAsCircle(atomElement);
|
|
830
|
+
const width = !asCircle && atomElement.offsetWidth || box.width;
|
|
831
|
+
const height = !asCircle && atomElement.offsetHeight || box.height;
|
|
806
832
|
const from = {
|
|
807
833
|
left: Number.parseFloat(atomElement.style.left),
|
|
808
834
|
top: placedTop(atomElement, atomPlaced.current?.height ?? height)
|
|
@@ -846,7 +872,8 @@ function SatellitesLayer({ host }) {
|
|
|
846
872
|
} else if (animate && (was === void 0 || was === "hidden")) {
|
|
847
873
|
cancel(atomElement, MORPH, true);
|
|
848
874
|
cancel(atomElement, MOVE);
|
|
849
|
-
drop(root, atomElement, "split", 0, durations(atomElement).enter, splitAt, slide, settlesIn(root));
|
|
875
|
+
drop(root, atomElement, "split", 0, durations(atomElement).enter, splitAt, slide, settlesIn(root), circleSpot(level));
|
|
876
|
+
openFromCircle(atomElement, durations(atomElement), durations(atomElement).enter, level);
|
|
850
877
|
} else if (moving && (was === "compact" || was === "rest") && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
851
878
|
if (withHost && placedLast) {
|
|
852
879
|
atomElement.animate([{
|
|
@@ -894,38 +921,24 @@ function SatellitesLayer({ host }) {
|
|
|
894
921
|
}
|
|
895
922
|
}
|
|
896
923
|
} else if (animate && !atomOut && (was === "compact" || was === "rest")) {
|
|
897
|
-
const
|
|
924
|
+
const timings = durations(atomElement);
|
|
925
|
+
const { fade, exit } = timings;
|
|
898
926
|
const heldWidth = atomElement.offsetWidth;
|
|
899
927
|
const heldHeight = atomElement.offsetHeight;
|
|
900
|
-
const holdSize = (duration) => {
|
|
901
|
-
if (reduced || typeof atomElement.animate !== "function" || heldWidth <= 0) return;
|
|
902
|
-
const size = {
|
|
903
|
-
width: `${heldWidth}px`,
|
|
904
|
-
height: `${heldHeight}px`,
|
|
905
|
-
minWidth: "0px",
|
|
906
|
-
maxWidth: "none",
|
|
907
|
-
minHeight: "0px",
|
|
908
|
-
maxHeight: "none"
|
|
909
|
-
};
|
|
910
|
-
atomElement.animate([size, size], {
|
|
911
|
-
id: SPLIT,
|
|
912
|
-
duration,
|
|
913
|
-
fill: "forwards"
|
|
914
|
-
});
|
|
915
|
-
};
|
|
916
928
|
if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
|
|
917
929
|
setHandoff(host.store, "in");
|
|
918
|
-
|
|
919
|
-
|
|
930
|
+
const closing = closingTime(timings);
|
|
931
|
+
drop(root, atomElement, "join", closing, exit, void 0, void 0, 0, circleSpot(level));
|
|
932
|
+
closeToCircle(atomElement, heldWidth, heldHeight, exit, level, timings);
|
|
920
933
|
setTimeout(() => {
|
|
921
934
|
goingIn.current = false;
|
|
922
935
|
setHandoff(host.store, void 0);
|
|
923
936
|
refresh();
|
|
924
|
-
},
|
|
937
|
+
}, closing + exit + 20);
|
|
925
938
|
} else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + durations(atomElement).change), hostCentre());
|
|
926
939
|
else {
|
|
927
|
-
drop(root, atomElement, "join", 0,
|
|
928
|
-
|
|
940
|
+
drop(root, atomElement, "join", closingTime(timings), exit, void 0, void 0, 0, circleSpot(level));
|
|
941
|
+
closeToCircle(atomElement, heldWidth, heldHeight, exit, level, timings);
|
|
929
942
|
presences.current.set(ACTIONS, "hidden");
|
|
930
943
|
}
|
|
931
944
|
spots.current.delete(ACTIONS);
|
|
@@ -1001,17 +1014,6 @@ function SatellitesLayer({ host }) {
|
|
|
1001
1014
|
}
|
|
1002
1015
|
}));
|
|
1003
1016
|
if (passing.size > 1) playNecks([...passing], timings.change);
|
|
1004
|
-
if (animate && moving && panelTucked && !panelHeld.current && entries.some((entry) => presences.current.get(entry.electron.id) === "compact")) {
|
|
1005
|
-
if (holdOpening(root)) {
|
|
1006
|
-
panelHeld.current = true;
|
|
1007
|
-
const { fade, exit } = durations(root);
|
|
1008
|
-
setTimeout(() => {
|
|
1009
|
-
if (!panelHeld.current) return;
|
|
1010
|
-
panelHeld.current = false;
|
|
1011
|
-
replayOpening(root);
|
|
1012
|
-
}, fade + exit + 200);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
1017
|
if (!host.panel) panelHeld.current = false;
|
|
1016
1018
|
if (animate && !holding) {
|
|
1017
1019
|
for (const entry of entries) {
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const require_goo = require("../Pill/goo.js");
|
|
2
|
+
const require_timing = require("../utils/timing.js");
|
|
3
|
+
|
|
4
|
+
// src/satellites/circle.ts
|
|
5
|
+
/**
|
|
6
|
+
* Their circle at the host's level, in their box (`rect`): what their droplet goes in from, and comes
|
|
7
|
+
* out to (drop's `spot`). From their whole box, a column's circle ended below a bottom pill, the
|
|
8
|
+
* droplet heading for the host from the column's middle.
|
|
9
|
+
*/
|
|
10
|
+
function circleSpot(level) {
|
|
11
|
+
return (rect) => {
|
|
12
|
+
const side = Math.min(rect.width, rect.height);
|
|
13
|
+
return {
|
|
14
|
+
left: level === "left" ? rect.left : level === "right" ? rect.left + rect.width - side : rect.left + (rect.width - side) / 2,
|
|
15
|
+
top: level === "top" ? rect.top : level === "bottom" ? rect.top + rect.height - side : rect.top + (rect.height - side) / 2,
|
|
16
|
+
width: side,
|
|
17
|
+
height: side
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** How long the droplet going in waits: their content fading, then their pill closing to a circle */
|
|
22
|
+
function closingTime({ fade, change }) {
|
|
23
|
+
return fade + change;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Going in: their content fades, they close to a circle at the host's level, and stay one (filled
|
|
27
|
+
* forwards) while the droplet takes them in. `width` and `height`: their size as laid out, which
|
|
28
|
+
* they're held at until they close (still coming out, they're drawn small: A33).
|
|
29
|
+
*/
|
|
30
|
+
function closeToCircle(element, width, height, droplet, level, timings) {
|
|
31
|
+
if (require_timing.prefersReducedMotion() || typeof element.animate !== "function" || width <= 0 || height <= 0) return;
|
|
32
|
+
const side = Math.min(width, height);
|
|
33
|
+
const pill = shape(element, width, height, width, height);
|
|
34
|
+
const circle = shape(element, width, height, side, side, level);
|
|
35
|
+
const closing = closingTime(timings);
|
|
36
|
+
const total = closing + droplet;
|
|
37
|
+
play(element, [
|
|
38
|
+
pill,
|
|
39
|
+
{
|
|
40
|
+
...pill,
|
|
41
|
+
offset: timings.fade / total
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
...circle,
|
|
45
|
+
offset: closing / total
|
|
46
|
+
},
|
|
47
|
+
circle
|
|
48
|
+
], {
|
|
49
|
+
id: require_goo.SPLIT,
|
|
50
|
+
duration: total,
|
|
51
|
+
easing: "ease-in-out",
|
|
52
|
+
fill: "forwards"
|
|
53
|
+
});
|
|
54
|
+
for (const child of element.children) child.animate?.([
|
|
55
|
+
{ opacity: 1 },
|
|
56
|
+
{
|
|
57
|
+
opacity: 0,
|
|
58
|
+
offset: timings.fade / total
|
|
59
|
+
},
|
|
60
|
+
{ opacity: 0 }
|
|
61
|
+
], {
|
|
62
|
+
id: require_goo.SPLIT,
|
|
63
|
+
duration: total,
|
|
64
|
+
fill: "forwards"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Coming out: a circle while the droplet comes out (and while it waits to), then their pill opening
|
|
69
|
+
* from it, then their content showing. At their size as laid out now; the circle at the host's level.
|
|
70
|
+
*/
|
|
71
|
+
function openFromCircle(element, timings, droplet, level) {
|
|
72
|
+
if (require_timing.prefersReducedMotion() || typeof element.animate !== "function") return;
|
|
73
|
+
const width = element.offsetWidth;
|
|
74
|
+
const height = element.offsetHeight;
|
|
75
|
+
if (width <= 0 || height <= 0) return;
|
|
76
|
+
const delay = Math.max(0, ...(element.getAnimations?.() ?? []).filter((animation) => animation.id === require_goo.SPLIT).map((animation) => Number(animation.effect?.getTiming().delay ?? 0)));
|
|
77
|
+
const total = droplet + timings.change + timings.fade;
|
|
78
|
+
const side = Math.min(width, height);
|
|
79
|
+
const pill = shape(element, width, height, width, height);
|
|
80
|
+
const circle = shape(element, width, height, side, side, level);
|
|
81
|
+
play(element, [
|
|
82
|
+
circle,
|
|
83
|
+
{
|
|
84
|
+
...circle,
|
|
85
|
+
offset: droplet / total
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
...pill,
|
|
89
|
+
offset: (droplet + timings.change) / total
|
|
90
|
+
},
|
|
91
|
+
pill
|
|
92
|
+
], {
|
|
93
|
+
id: require_goo.SPLIT,
|
|
94
|
+
delay,
|
|
95
|
+
duration: total,
|
|
96
|
+
easing: "ease-in-out",
|
|
97
|
+
fill: "backwards"
|
|
98
|
+
});
|
|
99
|
+
for (const child of element.children) child.animate?.([
|
|
100
|
+
{ opacity: 0 },
|
|
101
|
+
{
|
|
102
|
+
opacity: 0,
|
|
103
|
+
offset: (droplet + timings.change) / total
|
|
104
|
+
},
|
|
105
|
+
{ opacity: 1 }
|
|
106
|
+
], {
|
|
107
|
+
id: require_goo.SPLIT,
|
|
108
|
+
delay,
|
|
109
|
+
duration: total,
|
|
110
|
+
fill: "backwards"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const sizes = /* @__PURE__ */ new WeakSet();
|
|
114
|
+
/**
|
|
115
|
+
* Whether they're drawn at a size of the circle's (closing, a circle, or opening from one) instead of
|
|
116
|
+
* their own: their offsetWidth and offsetHeight are the circle's then, not their size as laid out.
|
|
117
|
+
*/
|
|
118
|
+
function drawnAsCircle(element) {
|
|
119
|
+
return (element.getAnimations?.() ?? []).some((animation) => sizes.has(animation));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Their box at a size, in their box as laid out (`fullWidth` by `fullHeight`): in its middle, or with
|
|
123
|
+
* `level`, against its edge on that side (and in its middle the other way). Every size bound is set
|
|
124
|
+
* too: held by their width and height only, the bounds a morph had set won (a column turned into a
|
|
125
|
+
* circle in one frame, A38).
|
|
126
|
+
*/
|
|
127
|
+
function shape(element, fullWidth, fullHeight, width, height, level) {
|
|
128
|
+
const placedTop = element.style.top === "auto" ? fullHeight - height : 0;
|
|
129
|
+
const x = level === "left" ? 0 : level === "right" ? fullWidth - width : (fullWidth - width) / 2;
|
|
130
|
+
const y = (level === "top" ? 0 : level === "bottom" ? fullHeight - height : (fullHeight - height) / 2) - placedTop;
|
|
131
|
+
return {
|
|
132
|
+
width: `${width}px`,
|
|
133
|
+
height: `${height}px`,
|
|
134
|
+
minWidth: "0px",
|
|
135
|
+
maxWidth: "none",
|
|
136
|
+
minHeight: "0px",
|
|
137
|
+
maxHeight: "none",
|
|
138
|
+
translate: `${x}px ${y}px`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The size as it is, and the offset to their circle's spot added to whatever else moves them (the
|
|
143
|
+
* droplet's way in or out, a slide with the host): one animation for both, and the droplet's own
|
|
144
|
+
* translate was lost.
|
|
145
|
+
*/
|
|
146
|
+
function play(element, frames, options) {
|
|
147
|
+
const size = element.animate(frames.map(({ translate: _translate, ...size }) => size), {
|
|
148
|
+
...options,
|
|
149
|
+
composite: "replace"
|
|
150
|
+
});
|
|
151
|
+
sizes.add(size);
|
|
152
|
+
element.animate(frames.map(({ translate, offset }) => offset === void 0 ? { translate } : {
|
|
153
|
+
translate,
|
|
154
|
+
offset
|
|
155
|
+
}), {
|
|
156
|
+
...options,
|
|
157
|
+
composite: "add"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
exports.circleSpot = circleSpot;
|
|
162
|
+
exports.closeToCircle = closeToCircle;
|
|
163
|
+
exports.closingTime = closingTime;
|
|
164
|
+
exports.drawnAsCircle = drawnAsCircle;
|
|
165
|
+
exports.openFromCircle = openFromCircle;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { SPLIT } from "../Pill/goo.mjs";
|
|
2
|
+
import { prefersReducedMotion } from "../utils/timing.mjs";
|
|
3
|
+
|
|
4
|
+
// src/satellites/circle.ts
|
|
5
|
+
/**
|
|
6
|
+
* Their circle at the host's level, in their box (`rect`): what their droplet goes in from, and comes
|
|
7
|
+
* out to (drop's `spot`). From their whole box, a column's circle ended below a bottom pill, the
|
|
8
|
+
* droplet heading for the host from the column's middle.
|
|
9
|
+
*/
|
|
10
|
+
function circleSpot(level) {
|
|
11
|
+
return (rect) => {
|
|
12
|
+
const side = Math.min(rect.width, rect.height);
|
|
13
|
+
return {
|
|
14
|
+
left: level === "left" ? rect.left : level === "right" ? rect.left + rect.width - side : rect.left + (rect.width - side) / 2,
|
|
15
|
+
top: level === "top" ? rect.top : level === "bottom" ? rect.top + rect.height - side : rect.top + (rect.height - side) / 2,
|
|
16
|
+
width: side,
|
|
17
|
+
height: side
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** How long the droplet going in waits: their content fading, then their pill closing to a circle */
|
|
22
|
+
function closingTime({ fade, change }) {
|
|
23
|
+
return fade + change;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Going in: their content fades, they close to a circle at the host's level, and stay one (filled
|
|
27
|
+
* forwards) while the droplet takes them in. `width` and `height`: their size as laid out, which
|
|
28
|
+
* they're held at until they close (still coming out, they're drawn small: A33).
|
|
29
|
+
*/
|
|
30
|
+
function closeToCircle(element, width, height, droplet, level, timings) {
|
|
31
|
+
if (prefersReducedMotion() || typeof element.animate !== "function" || width <= 0 || height <= 0) return;
|
|
32
|
+
const side = Math.min(width, height);
|
|
33
|
+
const pill = shape(element, width, height, width, height);
|
|
34
|
+
const circle = shape(element, width, height, side, side, level);
|
|
35
|
+
const closing = closingTime(timings);
|
|
36
|
+
const total = closing + droplet;
|
|
37
|
+
play(element, [
|
|
38
|
+
pill,
|
|
39
|
+
{
|
|
40
|
+
...pill,
|
|
41
|
+
offset: timings.fade / total
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
...circle,
|
|
45
|
+
offset: closing / total
|
|
46
|
+
},
|
|
47
|
+
circle
|
|
48
|
+
], {
|
|
49
|
+
id: SPLIT,
|
|
50
|
+
duration: total,
|
|
51
|
+
easing: "ease-in-out",
|
|
52
|
+
fill: "forwards"
|
|
53
|
+
});
|
|
54
|
+
for (const child of element.children) child.animate?.([
|
|
55
|
+
{ opacity: 1 },
|
|
56
|
+
{
|
|
57
|
+
opacity: 0,
|
|
58
|
+
offset: timings.fade / total
|
|
59
|
+
},
|
|
60
|
+
{ opacity: 0 }
|
|
61
|
+
], {
|
|
62
|
+
id: SPLIT,
|
|
63
|
+
duration: total,
|
|
64
|
+
fill: "forwards"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Coming out: a circle while the droplet comes out (and while it waits to), then their pill opening
|
|
69
|
+
* from it, then their content showing. At their size as laid out now; the circle at the host's level.
|
|
70
|
+
*/
|
|
71
|
+
function openFromCircle(element, timings, droplet, level) {
|
|
72
|
+
if (prefersReducedMotion() || typeof element.animate !== "function") return;
|
|
73
|
+
const width = element.offsetWidth;
|
|
74
|
+
const height = element.offsetHeight;
|
|
75
|
+
if (width <= 0 || height <= 0) return;
|
|
76
|
+
const delay = Math.max(0, ...(element.getAnimations?.() ?? []).filter((animation) => animation.id === SPLIT).map((animation) => Number(animation.effect?.getTiming().delay ?? 0)));
|
|
77
|
+
const total = droplet + timings.change + timings.fade;
|
|
78
|
+
const side = Math.min(width, height);
|
|
79
|
+
const pill = shape(element, width, height, width, height);
|
|
80
|
+
const circle = shape(element, width, height, side, side, level);
|
|
81
|
+
play(element, [
|
|
82
|
+
circle,
|
|
83
|
+
{
|
|
84
|
+
...circle,
|
|
85
|
+
offset: droplet / total
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
...pill,
|
|
89
|
+
offset: (droplet + timings.change) / total
|
|
90
|
+
},
|
|
91
|
+
pill
|
|
92
|
+
], {
|
|
93
|
+
id: SPLIT,
|
|
94
|
+
delay,
|
|
95
|
+
duration: total,
|
|
96
|
+
easing: "ease-in-out",
|
|
97
|
+
fill: "backwards"
|
|
98
|
+
});
|
|
99
|
+
for (const child of element.children) child.animate?.([
|
|
100
|
+
{ opacity: 0 },
|
|
101
|
+
{
|
|
102
|
+
opacity: 0,
|
|
103
|
+
offset: (droplet + timings.change) / total
|
|
104
|
+
},
|
|
105
|
+
{ opacity: 1 }
|
|
106
|
+
], {
|
|
107
|
+
id: SPLIT,
|
|
108
|
+
delay,
|
|
109
|
+
duration: total,
|
|
110
|
+
fill: "backwards"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const sizes = /* @__PURE__ */ new WeakSet();
|
|
114
|
+
/**
|
|
115
|
+
* Whether they're drawn at a size of the circle's (closing, a circle, or opening from one) instead of
|
|
116
|
+
* their own: their offsetWidth and offsetHeight are the circle's then, not their size as laid out.
|
|
117
|
+
*/
|
|
118
|
+
function drawnAsCircle(element) {
|
|
119
|
+
return (element.getAnimations?.() ?? []).some((animation) => sizes.has(animation));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Their box at a size, in their box as laid out (`fullWidth` by `fullHeight`): in its middle, or with
|
|
123
|
+
* `level`, against its edge on that side (and in its middle the other way). Every size bound is set
|
|
124
|
+
* too: held by their width and height only, the bounds a morph had set won (a column turned into a
|
|
125
|
+
* circle in one frame, A38).
|
|
126
|
+
*/
|
|
127
|
+
function shape(element, fullWidth, fullHeight, width, height, level) {
|
|
128
|
+
const placedTop = element.style.top === "auto" ? fullHeight - height : 0;
|
|
129
|
+
const x = level === "left" ? 0 : level === "right" ? fullWidth - width : (fullWidth - width) / 2;
|
|
130
|
+
const y = (level === "top" ? 0 : level === "bottom" ? fullHeight - height : (fullHeight - height) / 2) - placedTop;
|
|
131
|
+
return {
|
|
132
|
+
width: `${width}px`,
|
|
133
|
+
height: `${height}px`,
|
|
134
|
+
minWidth: "0px",
|
|
135
|
+
maxWidth: "none",
|
|
136
|
+
minHeight: "0px",
|
|
137
|
+
maxHeight: "none",
|
|
138
|
+
translate: `${x}px ${y}px`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The size as it is, and the offset to their circle's spot added to whatever else moves them (the
|
|
143
|
+
* droplet's way in or out, a slide with the host): one animation for both, and the droplet's own
|
|
144
|
+
* translate was lost.
|
|
145
|
+
*/
|
|
146
|
+
function play(element, frames, options) {
|
|
147
|
+
const size = element.animate(frames.map(({ translate: _translate, ...size }) => size), {
|
|
148
|
+
...options,
|
|
149
|
+
composite: "replace"
|
|
150
|
+
});
|
|
151
|
+
sizes.add(size);
|
|
152
|
+
element.animate(frames.map(({ translate, offset }) => offset === void 0 ? { translate } : {
|
|
153
|
+
translate,
|
|
154
|
+
offset
|
|
155
|
+
}), {
|
|
156
|
+
...options,
|
|
157
|
+
composite: "add"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { circleSpot, closeToCircle, closingTime, drawnAsCircle, openFromCircle };
|
|
@@ -35,6 +35,11 @@ export interface SatelliteHost {
|
|
|
35
35
|
notifying: boolean;
|
|
36
36
|
/** Its panel is open (or opening): the satellites go beside the panel, or into the pill when they'd cut it short */
|
|
37
37
|
panel?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Going into the pill for its panel (`true`), the pill keeps what it shows until they're in
|
|
40
|
+
* (`false`): then it opens its panel. Called in their layout pass, or the panel opens at once.
|
|
41
|
+
*/
|
|
42
|
+
holdPanel?: (hold: boolean) => void;
|
|
38
43
|
linkComponent?: LinkComponent;
|
|
39
44
|
variant?: PillVariant;
|
|
40
45
|
theme?: PillTheme;
|
|
@@ -35,6 +35,11 @@ export interface SatelliteHost {
|
|
|
35
35
|
notifying: boolean;
|
|
36
36
|
/** Its panel is open (or opening): the satellites go beside the panel, or into the pill when they'd cut it short */
|
|
37
37
|
panel?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Going into the pill for its panel (`true`), the pill keeps what it shows until they're in
|
|
40
|
+
* (`false`): then it opens its panel. Called in their layout pass, or the panel opens at once.
|
|
41
|
+
*/
|
|
42
|
+
holdPanel?: (hold: boolean) => void;
|
|
38
43
|
linkComponent?: LinkComponent;
|
|
39
44
|
variant?: PillVariant;
|
|
40
45
|
theme?: PillTheme;
|