@cloudlet/toast 1.4.0-rc.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +181 -0
- package/README.md +30 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +19 -15
- package/dist/agent.js.map +1 -1
- package/dist/center-react.d.ts +286 -0
- package/dist/center-react.d.ts.map +1 -0
- package/dist/center-react.js +2 -0
- package/dist/center.d.ts +3 -0
- package/dist/center.d.ts.map +1 -0
- package/dist/center.js +1 -0
- package/dist/core/agent-port.d.ts +2 -0
- package/dist/core/agent-port.d.ts.map +1 -1
- package/dist/core/agent-port.js +3 -0
- package/dist/core/agent-port.js.map +1 -1
- package/dist/react/card.d.ts +4 -0
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +3 -8
- package/dist/react/card.js.map +1 -1
- package/dist/react/center-backdrop.d.ts +69 -0
- package/dist/react/center-backdrop.d.ts.map +1 -0
- package/dist/react/center-backdrop.js +81 -0
- package/dist/react/center-backdrop.js.map +1 -0
- package/dist/react/center-clear.d.ts +16 -0
- package/dist/react/center-clear.d.ts.map +1 -0
- package/dist/react/center-clear.js +24 -0
- package/dist/react/center-clear.js.map +1 -0
- package/dist/react/center-gestures.d.ts +47 -0
- package/dist/react/center-gestures.d.ts.map +1 -0
- package/dist/react/center-gestures.js +74 -0
- package/dist/react/center-gestures.js.map +1 -0
- package/dist/react/center-motion.d.ts +174 -0
- package/dist/react/center-motion.d.ts.map +1 -0
- package/dist/react/center-motion.js +344 -0
- package/dist/react/center-motion.js.map +1 -0
- package/dist/react/center.d.ts +15 -0
- package/dist/react/center.d.ts.map +1 -0
- package/dist/react/center.js +1287 -0
- package/dist/react/center.js.map +1 -0
- package/dist/react/focus.d.ts +7 -0
- package/dist/react/focus.d.ts.map +1 -0
- package/dist/react/focus.js +14 -0
- package/dist/react/focus.js.map +1 -0
- package/dist/react/gestures.d.ts +33 -2
- package/dist/react/gestures.d.ts.map +1 -1
- package/dist/react/gestures.js +181 -149
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +287 -283
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +18 -11
- package/dist/react/motion.d.ts.map +1 -1
- package/dist/react/motion.js +6 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/reduced.d.ts +24 -0
- package/dist/react/reduced.d.ts.map +1 -0
- package/dist/react/reduced.js +35 -0
- package/dist/react/reduced.js.map +1 -0
- package/dist/react/zoom.d.ts +12 -0
- package/dist/react/zoom.d.ts.map +1 -0
- package/dist/react/zoom.js +21 -0
- package/dist/react/zoom.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
- package/src/agent.ts +11 -6
- package/src/center-react.ts +300 -0
- package/src/center.ts +27 -0
- package/src/core/agent-port.ts +3 -0
- package/src/react/card.tsx +5 -6
- package/src/react/center-backdrop.tsx +151 -0
- package/src/react/center-clear.ts +56 -0
- package/src/react/center-gestures.ts +143 -0
- package/src/react/center-motion.ts +504 -0
- package/src/react/center.tsx +1557 -0
- package/src/react/focus.ts +18 -0
- package/src/react/gestures.ts +127 -37
- package/src/react/host.tsx +17 -5
- package/src/react/motion.ts +16 -9
- package/src/react/reduced.ts +52 -0
- package/src/react/zoom.ts +26 -0
- package/src/react.ts +4 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CenterMotion } from './center-motion.js';
|
|
2
|
+
/** What the center's swipes read from the panel at the moment they need it. */
|
|
3
|
+
interface CenterGestureOptions {
|
|
4
|
+
readonly motion: CenterMotion;
|
|
5
|
+
/** The column's width (CSS px): the drawer's threshold and, with `travel`, its full way. */
|
|
6
|
+
readonly width: () => number;
|
|
7
|
+
/** How far past its own width a closed card lies (`CENTER_MOTION.travel`). */
|
|
8
|
+
readonly travel: () => number;
|
|
9
|
+
/** The physical edge the drawer sits at: +1 right, -1 left (also in RTL). */
|
|
10
|
+
readonly edge: () => 1 | -1;
|
|
11
|
+
readonly open: () => boolean;
|
|
12
|
+
/** Asks the app to close the center (its `setOpen(false)`). */
|
|
13
|
+
readonly close: () => void;
|
|
14
|
+
/** The listed notification a card's motion key stands for, if it is still listed and can be dismissed. */
|
|
15
|
+
readonly idOf: (key: string) => string | null;
|
|
16
|
+
/** Asks the app to dismiss a notification (`onDismiss`). */
|
|
17
|
+
readonly dismiss: (id: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Hands the release speed (px per second) and the side the card was swiped to (+1 right, -1 left)
|
|
20
|
+
* to the copy that leaves for a swiped card, should it leave.
|
|
21
|
+
*/
|
|
22
|
+
readonly fling: (key: string, velocity: number, direction: 1 | -1) => void;
|
|
23
|
+
readonly now: () => number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The notification center's swipes, on the Toaster's `createSwipe` and its thresholds
|
|
27
|
+
* (`MOTION.swipe`): sideways only, vertical stays the list's native scrolling.
|
|
28
|
+
*
|
|
29
|
+
* Towards the drawer's edge, anywhere on the column, the drawer follows the fingers (resisting
|
|
30
|
+
* outwards past open); let go past the threshold it asks the app to close and keeps the release
|
|
31
|
+
* speed for the closing spring, short of it it springs back open. Away from the edge on a card that
|
|
32
|
+
* can be dismissed, the card follows and fades; past the threshold the app is asked to dismiss it and
|
|
33
|
+
* springs back while the app decides; its copy flies on with the release speed when the app takes it
|
|
34
|
+
* out soon after, even from its place (a card the app keeps stays); a card of an expanded group
|
|
35
|
+
* swipes on its own. Away from the edge elsewhere, a
|
|
36
|
+
* collapsed stack included, nothing happens. A sideways trackpad stream over the
|
|
37
|
+
* panel never reaches the browser's back and forward swipe, and the rest of a committed stream is
|
|
38
|
+
* swallowed until it goes idle, even once the closing panel is inert. Reduced motion turns the
|
|
39
|
+
* swipes off; the buttons stay.
|
|
40
|
+
*/
|
|
41
|
+
export declare function attachCenterGestures(root: HTMLElement, options: CenterGestureOptions): {
|
|
42
|
+
/** Ends a running swipe; the swallowed rest of a committed trackpad stream goes on to its end. */
|
|
43
|
+
cancel(): void;
|
|
44
|
+
dispose: () => void;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=center-gestures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-gestures.d.ts","sourceRoot":"","sources":["../../src/react/center-gestures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,+EAA+E;AAC/E,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAC3B,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9C,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC5B;AAWD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB;IAoFjF,kGAAkG;IAClG,MAAM;IACN,OAAO;EAEV"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MOTION as e } from "./motion.js";
|
|
2
|
+
import { createSwipe as t, decideRelease as n, rubberBand as r } from "./gestures.js";
|
|
3
|
+
//#region src/react/center-gestures.ts
|
|
4
|
+
var i = {
|
|
5
|
+
negative: !1,
|
|
6
|
+
positive: !0
|
|
7
|
+
}, a = 2, o = (e) => Number.isFinite(e) ? Math.max(-2, Math.min(a, e)) : 0;
|
|
8
|
+
function s(a, s) {
|
|
9
|
+
let { motion: c } = s, l = () => a.querySelector(".cloudlet-center-column");
|
|
10
|
+
function u() {
|
|
11
|
+
let t = s.edge(), a = () => Math.max(1, s.width() + s.travel());
|
|
12
|
+
c.grab();
|
|
13
|
+
let l = Math.min(1, c.value("p")), u = (e, r) => n(e * t, r * t, s.width(), i) !== 0;
|
|
14
|
+
return {
|
|
15
|
+
move(n) {
|
|
16
|
+
if (!s.open()) return;
|
|
17
|
+
let i = l - n * t / a();
|
|
18
|
+
c.drag(i <= 1 ? i : 1 + r((i - 1) * a(), e.swipe.resist) / a());
|
|
19
|
+
},
|
|
20
|
+
decide: u,
|
|
21
|
+
end(e, n) {
|
|
22
|
+
if (!s.open()) return;
|
|
23
|
+
let r = (e) => -e * t * 1e3 / a();
|
|
24
|
+
u(e, n) ? (c.release(r(n)), s.close()) : c.release(r(o(n)));
|
|
25
|
+
},
|
|
26
|
+
cancel() {
|
|
27
|
+
s.open() && c.release(0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function d(t) {
|
|
32
|
+
let a = t.dataset.cloudletMotionKey, l = a ? s.idOf(a) : null;
|
|
33
|
+
if (!a || l === null) return null;
|
|
34
|
+
let u = s.edge() > 0 ? -1 : 1, d = t.offsetWidth || s.width(), f = () => s.open() && t.isConnected, p = (e, t) => n(e * u, t * u, d, i) !== 0;
|
|
35
|
+
return {
|
|
36
|
+
move(t) {
|
|
37
|
+
f() && c.dragCard(a, t * u >= 0 ? t : r(t, e.swipe.resist));
|
|
38
|
+
},
|
|
39
|
+
decide: p,
|
|
40
|
+
end(e, t) {
|
|
41
|
+
f() && (p(e, t) && (s.fling(a, t * 1e3, u), s.dismiss(l)), c.releaseCard(a, o(t) * 1e3));
|
|
42
|
+
},
|
|
43
|
+
cancel() {
|
|
44
|
+
f() && c.releaseCard(a, 0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function f(e) {
|
|
49
|
+
if (c.reduced || !s.open() || !l()?.contains(e)) return null;
|
|
50
|
+
let t = e.closest(".cloudlet-center-list .cloudlet-card[data-cloudlet-motion-key]:not([data-cloudlet-place])");
|
|
51
|
+
return {
|
|
52
|
+
x: !0,
|
|
53
|
+
y: !1,
|
|
54
|
+
start: (e, n) => n === s.edge() ? u() : t ? d(t) : null,
|
|
55
|
+
release() {}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let p = t(a, {
|
|
59
|
+
begin: f,
|
|
60
|
+
claimsWheel: (e) => s.open() && a.contains(e),
|
|
61
|
+
holdsStream: !0,
|
|
62
|
+
now: s.now
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
cancel() {
|
|
66
|
+
p.active && p.cancel();
|
|
67
|
+
},
|
|
68
|
+
dispose: p.dispose
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { s as attachCenterGestures };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=center-gestures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-gestures.js","names":["towards","RETURN_SPEED","returnSpeed","velocity","attachCenterGestures","options","column","root","drawerSession","sign","range","from","motion","commits","decideRelease","offset","p","rubberBand","MOTION","speed","value","cardSession","key","card","id","width","live","begin","target","direction","swipe","createSwipe"],"sources":["../../src/react/center-gestures.ts"],"sourcesContent":["import type { CenterMotion } from './center-motion.js';\nimport { createSwipe, decideRelease, rubberBand } from './gestures.js';\nimport type { SwipeCandidate, SwipeSession } from './gestures.js';\nimport { MOTION } from './motion.js';\n\n/** What the center's swipes read from the panel at the moment they need it. */\ninterface CenterGestureOptions {\n readonly motion: CenterMotion;\n /** The column's width (CSS px): the drawer's threshold and, with `travel`, its full way. */\n readonly width: () => number;\n /** How far past its own width a closed card lies (`CENTER_MOTION.travel`). */\n readonly travel: () => number;\n /** The physical edge the drawer sits at: +1 right, -1 left (also in RTL). */\n readonly edge: () => 1 | -1;\n readonly open: () => boolean;\n /** Asks the app to close the center (its `setOpen(false)`). */\n readonly close: () => void;\n /** The listed notification a card's motion key stands for, if it is still listed and can be dismissed. */\n readonly idOf: (key: string) => string | null;\n /** Asks the app to dismiss a notification (`onDismiss`). */\n readonly dismiss: (id: string) => void;\n /**\n * Hands the release speed (px per second) and the side the card was swiped to (+1 right, -1 left)\n * to the copy that leaves for a swiped card, should it leave.\n */\n readonly fling: (key: string, velocity: number, direction: 1 | -1) => void;\n readonly now: () => number;\n}\n\nconst towards = { negative: false, positive: true } as const;\n\n/**\n * The most speed (px/ms) a release short of its threshold springs back with: the drawer springs\n * back open without passing closed on the way, whatever the swipe's own speed.\n */\nconst RETURN_SPEED = 2;\nconst returnSpeed = (velocity: number) => Number.isFinite(velocity) ? Math.max(-RETURN_SPEED, Math.min(RETURN_SPEED, velocity)) : 0;\n\n/**\n * The notification center's swipes, on the Toaster's `createSwipe` and its thresholds\n * (`MOTION.swipe`): sideways only, vertical stays the list's native scrolling.\n *\n * Towards the drawer's edge, anywhere on the column, the drawer follows the fingers (resisting\n * outwards past open); let go past the threshold it asks the app to close and keeps the release\n * speed for the closing spring, short of it it springs back open. Away from the edge on a card that\n * can be dismissed, the card follows and fades; past the threshold the app is asked to dismiss it and\n * springs back while the app decides; its copy flies on with the release speed when the app takes it\n * out soon after, even from its place (a card the app keeps stays); a card of an expanded group\n * swipes on its own. Away from the edge elsewhere, a\n * collapsed stack included, nothing happens. A sideways trackpad stream over the\n * panel never reaches the browser's back and forward swipe, and the rest of a committed stream is\n * swallowed until it goes idle, even once the closing panel is inert. Reduced motion turns the\n * swipes off; the buttons stay.\n */\nexport function attachCenterGestures(root: HTMLElement, options: CenterGestureOptions) {\n const { motion } = options;\n const column = () => root.querySelector('.cloudlet-center-column');\n\n function drawerSession(): SwipeSession {\n const sign = options.edge();\n const range = () => Math.max(1, options.width() + options.travel());\n // The finger takes the drawer where it is, also in the middle of its spring.\n motion.grab();\n const from = Math.min(1, motion.value('p'));\n const commits = (offset: number, velocity: number) => decideRelease(offset * sign, velocity * sign, options.width(), towards) !== 0;\n return {\n move(offset) {\n if (!options.open()) return;\n const p = from - offset * sign / range();\n // Outwards past open the drawer resists.\n motion.drag(p <= 1 ? p : 1 + rubberBand((p - 1) * range(), MOTION.swipe.resist) / range());\n },\n decide: commits,\n end(offset, velocity) {\n if (!options.open()) return;\n // px/ms towards the edge → the position's speed in p per second.\n const speed = (value: number) => -value * sign * 1000 / range();\n // Released towards open with the swipe's own speed: when the app closes the center the spring\n // turns from there, keeping it; when the app keeps it open the drawer settles back.\n if (commits(offset, velocity)) {\n motion.release(speed(velocity));\n options.close();\n return;\n }\n motion.release(speed(returnSpeed(velocity)));\n },\n cancel() { if (options.open()) motion.release(0); },\n };\n }\n\n function cardSession(card: HTMLElement): SwipeSession | null {\n const key = card.dataset.cloudletMotionKey;\n const id = key ? options.idOf(key) : null;\n if (!key || id === null) return null;\n const sign = (options.edge() > 0 ? -1 : 1) as 1 | -1;\n const width = card.offsetWidth || options.width();\n const live = () => options.open() && card.isConnected;\n const commits = (offset: number, velocity: number) => decideRelease(offset * sign, velocity * sign, width, towards) !== 0;\n return {\n move(offset) {\n if (!live()) return;\n // Towards the edge a card barely gives.\n motion.dragCard(key, offset * sign >= 0 ? offset : rubberBand(offset, MOTION.swipe.resist));\n },\n decide: commits,\n end(offset, velocity) {\n if (!live()) return;\n if (commits(offset, velocity)) {\n options.fling(key, velocity * 1000, sign);\n options.dismiss(id);\n }\n // The card springs back while the app decides; taken out soon after (the panel's fling\n // window), it flies on from wherever the spring has taken it, with the swipe's speed.\n motion.releaseCard(key, returnSpeed(velocity) * 1000);\n },\n cancel() { if (live()) motion.releaseCard(key, 0); },\n };\n }\n\n function begin(target: Element): SwipeCandidate | null {\n if (motion.reduced || !options.open() || !column()?.contains(target)) return null;\n // A card of the list or of an expanded group; a collapsed stack is no card (it hides others).\n const card = target.closest<HTMLElement>('.cloudlet-center-list .cloudlet-card[data-cloudlet-motion-key]:not([data-cloudlet-place])');\n return {\n x: true, y: false,\n start: (_axis, direction) => direction === options.edge() ? drawerSession() : card ? cardSession(card) : null,\n release() {},\n };\n }\n\n const swipe = createSwipe(root, {\n begin,\n // Sideways streams over the open panel never turn into the browser's history swipe.\n claimsWheel: target => options.open() && root.contains(target),\n holdsStream: true,\n now: options.now,\n });\n return {\n /** Ends a running swipe; the swallowed rest of a committed trackpad stream goes on to its end. */\n cancel() { if (swipe.active) swipe.cancel(); },\n dispose: swipe.dispose,\n };\n}\n"],"mappings":";;;AA6BA,IAAMA,IAAU;CAAE,UAAU;CAAO,UAAU;AAAK,GAM5CC,IAAe,GACfC,KAAe,MAAqB,OAAO,SAASC,CAAQ,IAAI,KAAK,IAAI,IAAe,KAAK,IAAIF,GAAcE,CAAQ,CAAC,IAAI;AAkBlI,SAAgBC,EAAqB,GAAmB,GAA+B;CACrF,IAAM,EAAE,cAAWC,GACbC,UAAeC,EAAK,cAAc,yBAAyB;CAEjE,SAASC,IAA8B;EACrC,IAAMC,IAAOJ,EAAQ,KAAK,GACpBK,UAAc,KAAK,IAAI,GAAGL,EAAQ,MAAM,IAAIA,EAAQ,OAAO,CAAC;EAElE,EAAO,KAAK;EACZ,IAAMM,IAAO,KAAK,IAAI,GAAGC,EAAO,MAAM,GAAG,CAAC,GACpCC,KAAW,GAAgB,MAAqBC,EAAcC,IAASN,GAAMN,IAAWM,GAAMJ,EA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MACNb,EAAQE,GAAQZ,CAAQ,MAC1BE,EAAQ,MAAMiB,GAAKnB,IAAW,KAAMM,CAAI,GACxCJ,EAAQ,QAAQmB,CAAE,IAIpBZ,EAAO,YAAYU,GAAKpB,EAAYC,CAAQ,IAAI,GAAI;GACtD;GACA,SAAS;IAAE,AAAIuB,EAAK,KAAGd,EAAO,YAAYU,GAAK,CAAC;GAAG;EACrD;CACF;CAEA,SAASK,EAAM,GAAwC;EACrD,IAAIf,EAAO,WAAW,CAACP,EAAQ,KAAK,KAAK,CAACC,EAAO,CAAC,EAAE,SAASsB,CAAM,GAAG,OAAO;EAE7E,IAAML,IAAOK,EAAO,QAAqB,2FAA2F;EACpI,OAAO;GACL,GAAG;GAAM,GAAG;GACZ,QAAQ,GAAO,MAAcC,MAAcxB,EAAQ,KAAK,IAAIG,EAAc,IAAIe,IAAOF,EAAYE,CAAI,IAAI;GACzG,UAAU,CAAC;EACb;CACF;CAEA,IAAMO,IAAQC,EAAYxB,GAAM;EAC9B;EAEA,cAAa,MAAUF,EAAQ,KAAK,KAAKE,EAAK,SAASqB,CAAM;EAC7D,aAAa;EACb,KAAKvB,EAAQ;CACf,CAAC;CACD,OAAO;EAEL,SAAS;GAAE,AAAIyB,EAAM,UAAQA,EAAM,OAAO;EAAG;EAC7C,SAASA,EAAM;CACjB;AACF"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { NotificationCenterMotionConstants, NotificationCenterMotionOverrides } from '../center-react.js';
|
|
2
|
+
/**
|
|
3
|
+
* The notification center's motion, the one place to tune it (as MOTION is the Toaster's).
|
|
4
|
+
* Durations are milliseconds at `timeScale: 1`; offsets and blur are CSS px. Starting values, to
|
|
5
|
+
* be tuned on the laboratory.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CENTER_MOTION: NotificationCenterMotionConstants;
|
|
8
|
+
/** Cards after the eighth trail like the eighth. */
|
|
9
|
+
export declare const LAG_CARDS = 8;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves `NotificationCenterMotion.overrides` (a debugging channel) onto the starting values with
|
|
12
|
+
* the Toaster's contract: a field that is not a finite number in range (stiffness and mass > 0, the
|
|
13
|
+
* rest ≥ 0) keeps its default; unknown keys are ignored.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveCenterMotion(overrides: NotificationCenterMotionOverrides | undefined): NotificationCenterMotionConstants;
|
|
16
|
+
type Spring = NotificationCenterMotionConstants['reflow'];
|
|
17
|
+
/**
|
|
18
|
+
* How long (ms at `timeScale: 1`) a card waits so that it starts once the first card of its group
|
|
19
|
+
* has covered `share` of its way on `spring` from rest: the stack's cascade. Cached per spring.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cascadeDelay(spec: Spring, share: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* A card of a group in the group's own terms (px from the top of its `li`, layout values untouched
|
|
24
|
+
* by transforms). `plain` is a card in the flow, its look scaled from its top centre: the top card
|
|
25
|
+
* of a stack and every card of an expanded group. `edge` (levels 1 and 2) and `hidden` (behind the
|
|
26
|
+
* second edge, at level 2) are bottom-aligned with the top card (`list` + `first`), lowered by
|
|
27
|
+
* `step × level` and narrowed from their bottom centre by the CSS, and clipped at rest to the top
|
|
28
|
+
* card's height (`restClip`).
|
|
29
|
+
*/
|
|
30
|
+
export interface StackBox {
|
|
31
|
+
readonly kind: 'plain' | 'edge' | 'hidden';
|
|
32
|
+
/** Plain: the card's layout top. */
|
|
33
|
+
readonly top: number;
|
|
34
|
+
/** The card's own height. */
|
|
35
|
+
readonly height: number;
|
|
36
|
+
/** The top of the group's list, and the height of the stack's top card. */
|
|
37
|
+
readonly list: number;
|
|
38
|
+
readonly first: number;
|
|
39
|
+
/** 0 for a plain card, 1 or 2 for an edge, 2 for a hidden card. */
|
|
40
|
+
readonly level: number;
|
|
41
|
+
}
|
|
42
|
+
/** A card's channels in its box's terms: offset, scale and clip from the top, with the speeds (per second). */
|
|
43
|
+
export interface StackLook {
|
|
44
|
+
readonly y: number;
|
|
45
|
+
readonly s: number;
|
|
46
|
+
readonly c: number;
|
|
47
|
+
readonly vy: number;
|
|
48
|
+
readonly vs: number;
|
|
49
|
+
}
|
|
50
|
+
/** What a card looks like in the group: the visible top and bottom, its scale, and their speeds. */
|
|
51
|
+
export interface StackVisual {
|
|
52
|
+
readonly top: number;
|
|
53
|
+
readonly bottom: number;
|
|
54
|
+
readonly scale: number;
|
|
55
|
+
readonly vbottom: number;
|
|
56
|
+
readonly vscale: number;
|
|
57
|
+
}
|
|
58
|
+
type StackGeometry = Pick<NotificationCenterMotionConstants['stack'], 'step' | 'shrink'>;
|
|
59
|
+
/** The clip from the top a card's place gives it at rest: an edge shows the top card's height. */
|
|
60
|
+
export declare const restClip: (box: StackBox) => number;
|
|
61
|
+
/** How a card looks with `look` in `box`; the clip in force is the channel's while it runs (`clipping`), else the place's own. */
|
|
62
|
+
export declare function stackVisual(box: StackBox, look: StackLook & {
|
|
63
|
+
readonly clipping: boolean;
|
|
64
|
+
}, geometry: StackGeometry): StackVisual;
|
|
65
|
+
/** The channels that give a card in `box` the look `visual`: the inverse of `stackVisual`, the clip within the card. */
|
|
66
|
+
export declare function stackLook(box: StackBox, visual: StackVisual, geometry: StackGeometry): StackLook;
|
|
67
|
+
type Spec = {
|
|
68
|
+
readonly stiffness: number;
|
|
69
|
+
readonly damping: number;
|
|
70
|
+
readonly mass: number;
|
|
71
|
+
} | {
|
|
72
|
+
readonly duration: number;
|
|
73
|
+
readonly bounce: number;
|
|
74
|
+
} | {
|
|
75
|
+
readonly tween: number;
|
|
76
|
+
};
|
|
77
|
+
interface CenterMotionOptions {
|
|
78
|
+
readonly now: () => number;
|
|
79
|
+
readonly requestFrame: (callback: (time: number) => void) => number;
|
|
80
|
+
readonly cancelFrame: (frame: number) => void;
|
|
81
|
+
/** The sole DOM writer (CSSOM rules), with the channels that changed since the last write. */
|
|
82
|
+
readonly write: (changed: ReadonlySet<string>) => void;
|
|
83
|
+
readonly reducedMotion?: boolean | undefined;
|
|
84
|
+
readonly timeScale?: number | undefined;
|
|
85
|
+
readonly constants?: NotificationCenterMotionConstants | undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* One RAF sampler per center over the generators of generators.ts. Every retarget starts from the
|
|
89
|
+
* current value and velocity, so opening in the middle of closing turns the drawer without a jerk;
|
|
90
|
+
* nothing is scheduled at rest; completion callbacks run from a frame, only for the latest request
|
|
91
|
+
* of their group. A finger (the gestures) can take the position over: `grab`, `drag`, then
|
|
92
|
+
* `release` back to the open position or `fling` before the center closes.
|
|
93
|
+
*/
|
|
94
|
+
export declare function createCenterMotion(options: CenterMotionOptions): {
|
|
95
|
+
/** The current value of a channel; `p` in 0–1 (a spring released with speed may pass 1). */
|
|
96
|
+
value(key: string): number;
|
|
97
|
+
/** Opens or closes on the position spring from where the drawer is and how fast it moves. */
|
|
98
|
+
setOpen(open: boolean, done?: () => void): void;
|
|
99
|
+
/**
|
|
100
|
+
* Shows (1) or hides (0) the backdrop's blur layers apart from the drawer, over `duration` ms
|
|
101
|
+
* from where they are; at once under reduced motion.
|
|
102
|
+
*/
|
|
103
|
+
setBlur(shown: boolean, duration: number): void;
|
|
104
|
+
/** Places the drawer without motion (an open center on the first client render). */
|
|
105
|
+
place(open: boolean): void;
|
|
106
|
+
/** A finger takes the position: the spring stops where it is. */
|
|
107
|
+
grab(): void;
|
|
108
|
+
/** The finger moves the drawer to `p` (0 closed, 1 open). */
|
|
109
|
+
drag(p: number): void;
|
|
110
|
+
/** The finger lets go short of closing: back to open with its speed (p per second). */
|
|
111
|
+
release(velocity: number, done?: () => void): void;
|
|
112
|
+
/** Sets the speed (p per second) the following `setOpen(false)` starts with. */
|
|
113
|
+
fling(velocity: number): void;
|
|
114
|
+
/** A card that arrives in the open center grows in from the top. */
|
|
115
|
+
enter(key: string): void;
|
|
116
|
+
/** A card's layout place moved by `delta` px: it starts where it was and springs to the new place. */
|
|
117
|
+
shift(key: string, delta: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* A card of a group moved between places (the stack's top, its edges, behind them, the list of
|
|
120
|
+
* an expanded group): `rebase` turns its current channels into its new place's terms, so it
|
|
121
|
+
* looks where it was and keeps its speed, and it springs to the place on `spring` (the clip to
|
|
122
|
+
* `clip`, the place's own). `delay` holds a card that stands still (the cascade). `fade: 'in'`
|
|
123
|
+
* shows a card that was hidden over `stack.reveal` ms; `'out'` fades it out, then leaves it to
|
|
124
|
+
* its place's own hiding at full opacity.
|
|
125
|
+
*/
|
|
126
|
+
fold(key: string, rebase: (look: StackLook & {
|
|
127
|
+
readonly clipping: boolean;
|
|
128
|
+
}) => StackLook, options: {
|
|
129
|
+
readonly spring: Spec;
|
|
130
|
+
readonly clip: number;
|
|
131
|
+
readonly delay?: number | undefined;
|
|
132
|
+
readonly fade?: 'in' | 'out' | undefined;
|
|
133
|
+
}): void;
|
|
134
|
+
/**
|
|
135
|
+
* Starts a leaving card (its inert copy) from a card's current look, then fades and shrinks it.
|
|
136
|
+
* A swiped card (`fling`) instead keeps flying sideways to `fling.to` px from where the finger let
|
|
137
|
+
* it go, with the release speed (px per second), and fades. `rest` is where the copy's card lay,
|
|
138
|
+
* in the copy's terms (an edge of a stack: lower, narrower, clipped); it shrinks from there.
|
|
139
|
+
*/
|
|
140
|
+
exit(key: string, from: {
|
|
141
|
+
x?: number;
|
|
142
|
+
y: number;
|
|
143
|
+
scale: number;
|
|
144
|
+
opacity: number;
|
|
145
|
+
clip?: number;
|
|
146
|
+
}, done: () => void, fling?: {
|
|
147
|
+
readonly to: number;
|
|
148
|
+
readonly velocity: number;
|
|
149
|
+
}, rest?: {
|
|
150
|
+
readonly y: number;
|
|
151
|
+
readonly s: number;
|
|
152
|
+
readonly c: number;
|
|
153
|
+
}): void;
|
|
154
|
+
/** A finger moves a card sideways to `x` px. */
|
|
155
|
+
dragCard(key: string, x: number): void;
|
|
156
|
+
/** The finger lets a card go short of clearing it: back to its place with its speed (px per second). */
|
|
157
|
+
releaseCard(key: string, velocity: number): void;
|
|
158
|
+
/** Drops a card's channels (it left the list, or its copy finished leaving). */
|
|
159
|
+
forget(key: string): void;
|
|
160
|
+
/** True while a channel runs (or waits out its delay). */
|
|
161
|
+
moving(key: string): boolean;
|
|
162
|
+
setReducedMotion(next: boolean): void;
|
|
163
|
+
setTimeScale(next: number | undefined): void;
|
|
164
|
+
/** New constants apply to transitions started from now on; running ones keep their curves. */
|
|
165
|
+
setConstants(next: NotificationCenterMotionConstants): void;
|
|
166
|
+
readonly constants: NotificationCenterMotionConstants;
|
|
167
|
+
readonly reduced: boolean;
|
|
168
|
+
/** True while a frame is scheduled; a center at rest never keeps a RAF loop. */
|
|
169
|
+
readonly running: boolean;
|
|
170
|
+
dispose(): void;
|
|
171
|
+
};
|
|
172
|
+
export type CenterMotion = ReturnType<typeof createCenterMotion>;
|
|
173
|
+
export {};
|
|
174
|
+
//# sourceMappingURL=center-motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-motion.d.ts","sourceRoot":"","sources":["../../src/react/center-motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAM/G;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,iCA+B3B,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,SAAS,IAAI,CAAC;AAI3B;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iCAAiC,GAAG,SAAS,GAAG,iCAAiC,CAc/H;AAED,KAAK,MAAM,GAAG,iCAAiC,CAAC,QAAQ,CAAC,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAahE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC3C,oCAAoC;IACpC,QAAQ,CAAC,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AG,OAAO;IAC5B,gBAAgB,OAAO,OAAO;IAgB9B,YAAY,OAAO,MAAM,GAAG,SAAS;IAWrC,8FAA8F;IAC9F,YAAY,OAAO,iCAAiC;aAChD,SAAS;aACT,OAAO;IACX,gFAAgF;aAC5E,OAAO;IACX,OAAO;EASV;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { spring as e, tween as t } from "./generators.js";
|
|
2
|
+
//#region src/react/center-motion.ts
|
|
3
|
+
var n = (e, t = 1) => 2 * Math.sqrt(e * t), r = {
|
|
4
|
+
open: {
|
|
5
|
+
stiffness: 320,
|
|
6
|
+
damping: n(320),
|
|
7
|
+
mass: 1
|
|
8
|
+
},
|
|
9
|
+
close: {
|
|
10
|
+
stiffness: 480,
|
|
11
|
+
damping: n(480),
|
|
12
|
+
mass: 1
|
|
13
|
+
},
|
|
14
|
+
travel: 56,
|
|
15
|
+
lag: .12,
|
|
16
|
+
enter: {
|
|
17
|
+
duration: 200,
|
|
18
|
+
bounce: .25,
|
|
19
|
+
scale: .25,
|
|
20
|
+
fade: 160
|
|
21
|
+
},
|
|
22
|
+
exit: {
|
|
23
|
+
duration: 300,
|
|
24
|
+
bounce: 0
|
|
25
|
+
},
|
|
26
|
+
reflow: {
|
|
27
|
+
stiffness: 448,
|
|
28
|
+
damping: n(448),
|
|
29
|
+
mass: 1
|
|
30
|
+
},
|
|
31
|
+
swap: 180,
|
|
32
|
+
swapBlur: 4,
|
|
33
|
+
reduced: 80,
|
|
34
|
+
stack: {
|
|
35
|
+
expand: {
|
|
36
|
+
stiffness: 900,
|
|
37
|
+
damping: 60,
|
|
38
|
+
mass: 2
|
|
39
|
+
},
|
|
40
|
+
collapse: {
|
|
41
|
+
stiffness: 900,
|
|
42
|
+
damping: 45,
|
|
43
|
+
mass: 1
|
|
44
|
+
},
|
|
45
|
+
step: 10,
|
|
46
|
+
shrink: .06,
|
|
47
|
+
reveal: 160,
|
|
48
|
+
blur: 4,
|
|
49
|
+
cascade: 0
|
|
50
|
+
}
|
|
51
|
+
}, i = /* @__PURE__ */ new Set(["stiffness", "mass"]);
|
|
52
|
+
function a(e) {
|
|
53
|
+
if (!e || typeof e != "object") return r;
|
|
54
|
+
let t = (e, t) => typeof t == "number" && Number.isFinite(t) && (i.has(e) ? t > 0 : t >= 0), n = (e, r) => {
|
|
55
|
+
let i = r && typeof r == "object" ? r : {}, a = {};
|
|
56
|
+
for (let [r, o] of Object.entries(e)) a[r] = typeof o == "number" ? t(r, i[r]) ? i[r] : o : n(o, i[r]);
|
|
57
|
+
return a;
|
|
58
|
+
};
|
|
59
|
+
return n(r, e);
|
|
60
|
+
}
|
|
61
|
+
var o = /* @__PURE__ */ new Map();
|
|
62
|
+
function s(t, n) {
|
|
63
|
+
if (!(n > 0)) return 0;
|
|
64
|
+
let r = Math.min(n, .95) * f, i = `${t.stiffness}/${t.damping}/${t.mass}/${r}`, a = o.get(i);
|
|
65
|
+
if (a === void 0) {
|
|
66
|
+
let n = e({
|
|
67
|
+
from: 0,
|
|
68
|
+
to: f,
|
|
69
|
+
velocity: 0,
|
|
70
|
+
...t
|
|
71
|
+
});
|
|
72
|
+
for (a = 0; a < 5e3 && n.next(a).value < r;) a++;
|
|
73
|
+
o.size > 64 && o.clear(), o.set(i, a);
|
|
74
|
+
}
|
|
75
|
+
return a;
|
|
76
|
+
}
|
|
77
|
+
var c = (e) => e.kind === "plain" ? 0 : Math.max(0, e.height - e.first), l = (e, t) => Math.max(.05, 1 - e.level * t.shrink);
|
|
78
|
+
function u(e, t, n) {
|
|
79
|
+
let r = t.clipping ? t.c : c(e);
|
|
80
|
+
if (e.kind === "plain") {
|
|
81
|
+
let n = e.top + t.y;
|
|
82
|
+
return {
|
|
83
|
+
top: n + r * t.s,
|
|
84
|
+
bottom: n + e.height * t.s,
|
|
85
|
+
scale: t.s,
|
|
86
|
+
vbottom: t.vy + e.height * t.vs,
|
|
87
|
+
vscale: t.vs
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
let i = l(e, n), a = e.list + e.first + e.level * n.step + i * t.y, o = i * t.s;
|
|
91
|
+
return {
|
|
92
|
+
top: a - o * (e.height - r),
|
|
93
|
+
bottom: a,
|
|
94
|
+
scale: o,
|
|
95
|
+
vbottom: i * t.vy,
|
|
96
|
+
vscale: i * t.vs
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function d(e, t, n) {
|
|
100
|
+
let r = Math.max(.001, t.scale), i = Math.min(e.height, Math.max(0, e.height - (t.bottom - t.top) / r));
|
|
101
|
+
if (e.kind === "plain") return {
|
|
102
|
+
y: t.bottom - e.top - e.height * r,
|
|
103
|
+
s: r,
|
|
104
|
+
c: i,
|
|
105
|
+
vy: t.vbottom - e.height * t.vscale,
|
|
106
|
+
vs: t.vscale
|
|
107
|
+
};
|
|
108
|
+
let a = l(e, n);
|
|
109
|
+
return {
|
|
110
|
+
y: (t.bottom - e.list - e.first - e.level * n.step) / a,
|
|
111
|
+
s: r / a,
|
|
112
|
+
c: i,
|
|
113
|
+
vy: t.vbottom / a,
|
|
114
|
+
vs: t.vscale / a
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
var f = 1e3, p = (e) => e === "p" || e.startsWith("x:") || e.startsWith("y:") || e.startsWith("c:") ? 0 : 1, m = (e) => e === "p" || e.startsWith("x:") || e.startsWith("y:") || e.startsWith("s:") || e.startsWith("c:"), h = [
|
|
118
|
+
"x:",
|
|
119
|
+
"y:",
|
|
120
|
+
"s:",
|
|
121
|
+
"c:",
|
|
122
|
+
"o:"
|
|
123
|
+
], g = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : 1;
|
|
124
|
+
function _(n) {
|
|
125
|
+
let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = null, c = !1, l = n.reducedMotion ?? !1, u = g(n.timeScale), d = n.constants ?? r;
|
|
126
|
+
function _(e) {
|
|
127
|
+
let t = i.get(e);
|
|
128
|
+
if (!t) {
|
|
129
|
+
let n = p(e);
|
|
130
|
+
i.set(e, t = {
|
|
131
|
+
value: n,
|
|
132
|
+
target: n,
|
|
133
|
+
velocity: 0,
|
|
134
|
+
animation: null
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return t;
|
|
138
|
+
}
|
|
139
|
+
let v = (e) => {
|
|
140
|
+
for (let t of e) if (i.get(t)?.animation) return !0;
|
|
141
|
+
return !1;
|
|
142
|
+
};
|
|
143
|
+
function y(e) {
|
|
144
|
+
for (let [t, n] of i) {
|
|
145
|
+
let r = n.animation;
|
|
146
|
+
if (!r) continue;
|
|
147
|
+
let i = Math.max(0, (e - r.start) * u), a = r.generator.next(i);
|
|
148
|
+
n.value = a.value, n.velocity = a.done ? 0 : (r.generator.velocity?.(i) ?? 0) * u, a.done && (n.animation = null, n.value = n.target), o.add(t);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function b() {
|
|
152
|
+
if (c || !o.size) return;
|
|
153
|
+
let e = new Set(o);
|
|
154
|
+
o.clear(), n.write(e);
|
|
155
|
+
}
|
|
156
|
+
function x() {
|
|
157
|
+
!c && s === null && (s = n.requestFrame(C));
|
|
158
|
+
}
|
|
159
|
+
function S() {
|
|
160
|
+
for (let [e, t] of [...a]) {
|
|
161
|
+
if (c) return;
|
|
162
|
+
a.get(e) !== t || v(t.keys) || (a.delete(e), t.done());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function C() {
|
|
166
|
+
s = null, !c && (y(n.now()), b(), S(), b(), (a.size || v(i.keys())) && x());
|
|
167
|
+
}
|
|
168
|
+
function w(e, t) {
|
|
169
|
+
let n = _(e);
|
|
170
|
+
(n.value !== t || n.animation) && o.add(e), n.value = n.target = t, n.velocity = 0, n.animation = null;
|
|
171
|
+
}
|
|
172
|
+
function T(n, r, i, a, o = 0) {
|
|
173
|
+
let s = _(n);
|
|
174
|
+
if (l) {
|
|
175
|
+
if (m(n)) return w(n, r);
|
|
176
|
+
i = { tween: d.reduced }, o = 0;
|
|
177
|
+
}
|
|
178
|
+
s.target = r, (s.value !== r || s.animation) && (s.animation = {
|
|
179
|
+
generator: "tween" in i ? t(s.value, r, i.tween) : e({
|
|
180
|
+
from: s.value,
|
|
181
|
+
to: r,
|
|
182
|
+
velocity: s.velocity / u,
|
|
183
|
+
...i
|
|
184
|
+
}),
|
|
185
|
+
start: a + o / u
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function E(e, t, n) {
|
|
189
|
+
let r = _(e), i = Number.isFinite(t) ? t : r.target;
|
|
190
|
+
r.value !== i && o.add(e), r.value = i, r.velocity = Number.isFinite(n) ? n : 0;
|
|
191
|
+
}
|
|
192
|
+
function D(e, t, n) {
|
|
193
|
+
n ? a.set(e, {
|
|
194
|
+
keys: t,
|
|
195
|
+
done: n
|
|
196
|
+
}) : a.delete(e);
|
|
197
|
+
}
|
|
198
|
+
function O(e) {
|
|
199
|
+
if (c) return;
|
|
200
|
+
let t = n.now();
|
|
201
|
+
y(t), e(t), b(), (a.size || v(i.keys())) && x();
|
|
202
|
+
}
|
|
203
|
+
let k = () => ({
|
|
204
|
+
duration: d.enter.duration,
|
|
205
|
+
bounce: d.enter.bounce
|
|
206
|
+
}), A = () => ({
|
|
207
|
+
duration: d.exit.duration,
|
|
208
|
+
bounce: d.exit.bounce
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
value(e) {
|
|
212
|
+
let t = i.get(e), n = t ? t.value : p(e);
|
|
213
|
+
return e === "p" ? n / f : n;
|
|
214
|
+
},
|
|
215
|
+
setOpen(e, t) {
|
|
216
|
+
O((n) => {
|
|
217
|
+
if (l) {
|
|
218
|
+
let t = _("fade");
|
|
219
|
+
e && t.target === 1 && _("p").value === 0 && w("fade", 0), w("p", f), T("fade", +!!e, { tween: d.reduced }, n);
|
|
220
|
+
} else w("fade", 1), T("p", e ? f : 0, e ? d.open : d.close, n);
|
|
221
|
+
D("drawer", ["p", "fade"], t);
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
setBlur(e, t) {
|
|
225
|
+
O((n) => {
|
|
226
|
+
l ? w("blur", +!!e) : T("blur", +!!e, { tween: t }, n);
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
place(e) {
|
|
230
|
+
O(() => {
|
|
231
|
+
w("p", e ? f : 0), w("fade", 1), a.delete("drawer");
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
grab() {
|
|
235
|
+
O(() => {
|
|
236
|
+
w("p", _("p").value), a.delete("drawer");
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
drag(e) {
|
|
240
|
+
O(() => {
|
|
241
|
+
Number.isFinite(e) && w("p", e * f);
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
release(e, t) {
|
|
245
|
+
O((n) => {
|
|
246
|
+
let r = _("p");
|
|
247
|
+
r.velocity = Number.isFinite(e) ? e * f : 0, T("p", f, d.open, n), D("drawer", ["p", "fade"], t);
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
fling(e) {
|
|
251
|
+
let t = _("p");
|
|
252
|
+
!c && !t.animation && (t.velocity = Number.isFinite(e) ? e * f : 0);
|
|
253
|
+
},
|
|
254
|
+
enter(e) {
|
|
255
|
+
O((t) => {
|
|
256
|
+
l || (w(`s:${e}`, d.enter.scale), T(`s:${e}`, 1, k(), t)), w(`o:${e}`, 0), T(`o:${e}`, 1, { tween: d.enter.fade }, t);
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
shift(e, t) {
|
|
260
|
+
O((n) => {
|
|
261
|
+
if (!Number.isFinite(t) || Math.abs(t) < .5) return;
|
|
262
|
+
let r = _(`y:${e}`);
|
|
263
|
+
r.value += t, o.add(`y:${e}`), T(`y:${e}`, 0, d.reflow, n);
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
fold(e, t, n) {
|
|
267
|
+
O((r) => {
|
|
268
|
+
let i = _(`y:${e}`), o = _(`s:${e}`), s = _(`c:${e}`), c = _(`o:${e}`), l = !i.animation && !o.animation && !s.animation, u = t({
|
|
269
|
+
y: i.value,
|
|
270
|
+
s: o.value,
|
|
271
|
+
c: s.value,
|
|
272
|
+
vy: i.velocity,
|
|
273
|
+
vs: o.velocity,
|
|
274
|
+
clipping: !!s.animation
|
|
275
|
+
}), f = l ? Math.max(0, n.delay ?? 0) : 0;
|
|
276
|
+
E(`y:${e}`, u.y, u.vy), E(`s:${e}`, u.s, u.vs), E(`c:${e}`, u.c, 0), T(`y:${e}`, 0, n.spring, r, f), T(`s:${e}`, 1, n.spring, r, f), T(`c:${e}`, n.clip, n.spring, r, f);
|
|
277
|
+
let p = { tween: d.stack.reveal };
|
|
278
|
+
n.fade === "out" ? (T(`o:${e}`, 0, p, r, f), D(`fade:${e}`, [`o:${e}`], () => w(`o:${e}`, 1))) : (a.delete(`fade:${e}`), n.fade === "in" && !c.animation && c.value === 1 && w(`o:${e}`, 0), (c.value !== 1 || c.animation) && T(`o:${e}`, 1, p, r, f));
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
exit(e, t, n, r, i) {
|
|
282
|
+
O((a) => {
|
|
283
|
+
w(`x:${e}`, t.x ?? 0), w(`y:${e}`, t.y), w(`s:${e}`, t.scale), w(`o:${e}`, t.opacity), w(`c:${e}`, t.clip ?? 0);
|
|
284
|
+
let o = i ?? {
|
|
285
|
+
y: 0,
|
|
286
|
+
s: 1,
|
|
287
|
+
c: 0
|
|
288
|
+
};
|
|
289
|
+
!l && r ? (_(`x:${e}`).velocity = Number.isFinite(r.velocity) ? r.velocity : 0, T(`x:${e}`, r.to, d.reflow, a), T(`y:${e}`, o.y, d.reflow, a)) : l || (T(`x:${e}`, 0, d.reflow, a), T(`y:${e}`, o.y, d.reflow, a), T(`s:${e}`, o.s * d.enter.scale, A(), a), T(`c:${e}`, o.c, d.reflow, a)), T(`o:${e}`, 0, A(), a), D(`exit:${e}`, h.map((t) => t + e), n);
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
dragCard(e, t) {
|
|
293
|
+
O(() => {
|
|
294
|
+
Number.isFinite(t) && w(`x:${e}`, t);
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
releaseCard(e, t) {
|
|
298
|
+
O((n) => {
|
|
299
|
+
let r = _(`x:${e}`);
|
|
300
|
+
r.velocity = Number.isFinite(t) ? t : 0, T(`x:${e}`, 0, d.reflow, n);
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
forget(e) {
|
|
304
|
+
for (let t of h) i.delete(t + e);
|
|
305
|
+
a.delete(`exit:${e}`), a.delete(`fade:${e}`);
|
|
306
|
+
},
|
|
307
|
+
moving(e) {
|
|
308
|
+
return !!i.get(e)?.animation;
|
|
309
|
+
},
|
|
310
|
+
setReducedMotion(e) {
|
|
311
|
+
c || l === e || O((t) => {
|
|
312
|
+
if (l = e, !l) _("fade").target === 1 && w("fade", 1);
|
|
313
|
+
else for (let [e, n] of i) n.animation && (m(e) || e === "blur" ? w(e, n.target) : (n.animation = null, n.velocity = 0, T(e, n.target, { tween: d.reduced }, t)));
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
setTimeScale(e) {
|
|
317
|
+
let t = g(e);
|
|
318
|
+
if (c || t === u) return;
|
|
319
|
+
let r = n.now();
|
|
320
|
+
y(r);
|
|
321
|
+
for (let e of i.values()) e.animation && (e.animation.start = r - (r - e.animation.start) * u / t);
|
|
322
|
+
u = t;
|
|
323
|
+
},
|
|
324
|
+
setConstants(e) {
|
|
325
|
+
d = e;
|
|
326
|
+
},
|
|
327
|
+
get constants() {
|
|
328
|
+
return d;
|
|
329
|
+
},
|
|
330
|
+
get reduced() {
|
|
331
|
+
return l;
|
|
332
|
+
},
|
|
333
|
+
get running() {
|
|
334
|
+
return s !== null;
|
|
335
|
+
},
|
|
336
|
+
dispose() {
|
|
337
|
+
c || (c = !0, s !== null && n.cancelFrame(s), s = null, a.clear(), i.clear());
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
export { r as CENTER_MOTION, s as cascadeDelay, _ as createCenterMotion, a as resolveCenterMotion, c as restClip, d as stackLook, u as stackVisual };
|
|
343
|
+
|
|
344
|
+
//# sourceMappingURL=center-motion.js.map
|