kitzo 2.3.29 → 2.3.30
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import f from "../triggerToasts.js";
|
|
2
|
-
let e = null, l = null,
|
|
2
|
+
let e = null, l = null, u = 0, r = 0, i = !1, o = !1, a = null;
|
|
3
3
|
const w = 2, m = 90, v = 20, E = 100;
|
|
4
4
|
function b(t) {
|
|
5
|
-
const
|
|
6
|
-
return
|
|
5
|
+
const n = Math.sign(t) || 1, s = Math.abs(t), p = v * (1 - Math.exp(-s / E));
|
|
6
|
+
return n * p;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function d(t) {
|
|
9
9
|
if (!t) return !1;
|
|
10
|
-
const
|
|
11
|
-
return
|
|
10
|
+
const n = t.dataset.swipeable === "true", s = t.dataset.isPromise === "true";
|
|
11
|
+
return n && !s;
|
|
12
12
|
}
|
|
13
13
|
function c(t = !0) {
|
|
14
14
|
if (!e) return;
|
|
@@ -19,41 +19,41 @@ function c(t = !0) {
|
|
|
19
19
|
console.error("");
|
|
20
20
|
}
|
|
21
21
|
e.style.setProperty("--swipe-x", "0px"), e.classList.remove("is-swiping");
|
|
22
|
-
const
|
|
23
|
-
if (e = null, l = null, a = null,
|
|
24
|
-
const
|
|
22
|
+
const n = e;
|
|
23
|
+
if (e = null, l = null, a = null, i = !1, o = !1, r = 0, !n.matches(":hover")) {
|
|
24
|
+
const s = new MouseEvent("mouseleave", {
|
|
25
25
|
bubbles: !0,
|
|
26
26
|
cancelable: !0,
|
|
27
27
|
view: window
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
n.dispatchEvent(s);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
document.addEventListener("pointerdown", (t) => {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
document.body.style.userSelect = "none", e =
|
|
33
|
+
const s = t.target.closest(".kitzo-toast");
|
|
34
|
+
if (s) {
|
|
35
|
+
document.body.style.userSelect = "none", e = s, l = s.id, u = t.clientX, r = 0, i = !0, o = !1, a = t.pointerId;
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
s.setPointerCapture(t.pointerId);
|
|
38
38
|
} catch {
|
|
39
39
|
console.error("");
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
document.addEventListener("pointermove", (t) => {
|
|
44
|
-
if (!
|
|
45
|
-
const
|
|
46
|
-
e.style.setProperty("--swipe-x", `${
|
|
44
|
+
if (!i || !e || (r = t.clientX - u, !o && Math.abs(r) > w && (o = !0, e.classList.add("is-swiping")), !o)) return;
|
|
45
|
+
const s = d(e) ? r : b(r);
|
|
46
|
+
e.style.setProperty("--swipe-x", `${s}px`);
|
|
47
47
|
});
|
|
48
48
|
document.addEventListener("pointerup", () => {
|
|
49
|
-
if (!
|
|
49
|
+
if (!i || !e || l == null) {
|
|
50
50
|
c();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
const t =
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
e.style.setProperty("--exit-x", `${
|
|
53
|
+
const t = d(e);
|
|
54
|
+
if (o && t && Math.abs(r) > m) {
|
|
55
|
+
const n = r > 0 ? 1 : -1, s = Math.abs(r) + 300;
|
|
56
|
+
e.style.setProperty("--exit-x", `${n * s}px`), e.dataset.exit = "swipe", f.dismiss(l);
|
|
57
57
|
}
|
|
58
58
|
c();
|
|
59
59
|
});
|
|
@@ -61,8 +61,8 @@ document.addEventListener("pointercancel", () => {
|
|
|
61
61
|
c();
|
|
62
62
|
});
|
|
63
63
|
window.addEventListener("blur", () => {
|
|
64
|
-
|
|
64
|
+
i && c();
|
|
65
65
|
});
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
o as dragStarted
|
|
68
68
|
};
|