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, d = 0, r = 0, o = !1, i = !1, a = 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 s = Math.sign(t) || 1, n = Math.abs(t), p = v * (1 - Math.exp(-n / E));
6
- return s * p;
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 u(t) {
8
+ function d(t) {
9
9
  if (!t) return !1;
10
- const s = t.dataset.swipeable === "true", n = t.dataset.isPromise === "true";
11
- return s && !n;
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 s = e;
23
- if (e = null, l = null, a = null, o = !1, i = !1, r = 0, !s.matches(":hover")) {
24
- const n = new MouseEvent("mouseleave", {
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
- s.dispatchEvent(n);
29
+ n.dispatchEvent(s);
30
30
  }
31
31
  }
32
32
  document.addEventListener("pointerdown", (t) => {
33
- const n = t.target.closest(".kitzo-toast");
34
- if (n) {
35
- document.body.style.userSelect = "none", e = n, l = n.id, d = t.clientX, r = 0, o = !0, i = !1, a = t.pointerId;
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
- n.setPointerCapture(t.pointerId);
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 (!o || !e || (r = t.clientX - d, !i && Math.abs(r) > w && (i = !0, e.classList.add("is-swiping")), !i)) return;
45
- const n = u(e) ? r : b(r);
46
- e.style.setProperty("--swipe-x", `${n}px`);
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 (!o || !e || l == null) {
49
+ if (!i || !e || l == null) {
50
50
  c();
51
51
  return;
52
52
  }
53
- const t = u(e);
54
- if (i && t && Math.abs(r) > m) {
55
- const s = r > 0 ? 1 : -1, n = window.innerWidth / 2 + 50;
56
- e.style.setProperty("--exit-x", `${s * n}px`), e.dataset.exit = "swipe", f.dismiss(l);
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
- o && c();
64
+ i && c();
65
65
  });
66
66
  export {
67
- i as dragStarted
67
+ o as dragStarted
68
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "2.3.29",
3
+ "version": "2.3.30",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [