hero-animate 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/dist/react.js +43 -42
  2. package/package.json +1 -1
package/dist/react.js CHANGED
@@ -1,64 +1,65 @@
1
1
  import { n as e } from "./heroTransition-KNWyrgvQ.js";
2
- import { useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
3
- import { jsx as a } from "react/jsx-runtime";
2
+ import { useEffect as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
3
+ import { jsx as o } from "react/jsx-runtime";
4
4
  // lib/react.tsx
5
- function o({ open: o, masked: s = !0, ghostOnly: c = !1, panelSelector: l = ".modal-panel", anchor: u, spring: d, springAccel: f, onEntered: p, onExited: m, className: h, style: g, children: _ }) {
6
- let [v, y] = i(o), b = r(null), x = r("closed"), S = r(0), C = r(u), w = r(p), T = r(m);
7
- t(() => {
8
- C.current = u, w.current = p, T.current = m;
5
+ var s = typeof window < "u" ? n : t;
6
+ function c({ open: n, masked: c = !0, ghostOnly: l = !1, panelSelector: u = ".modal-panel", anchor: d, spring: f, springAccel: p, onEntered: m, onExited: h, className: g, style: _, children: v }) {
7
+ let [y, b] = a(n), x = i(null), S = i("closed"), C = i(0), w = i(d), T = i(m), E = i(h);
8
+ s(() => {
9
+ w.current = d, T.current = m, E.current = h;
9
10
  });
10
- let E = JSON.stringify(d ?? null), D = JSON.stringify(f ?? null), O = n(() => e((e) => e instanceof HTMLElement ? e.querySelector(l) : null, {
11
- masked: s,
12
- ghostOnly: c,
13
- panelSelector: l,
14
- anchor: () => C.current?.() ?? null,
15
- spring: d,
16
- springAccel: f
11
+ let D = JSON.stringify(f ?? null), O = JSON.stringify(p ?? null), k = r(() => e((e) => e instanceof HTMLElement ? e.querySelector(u) : null, {
12
+ masked: c,
13
+ ghostOnly: l,
14
+ panelSelector: u,
15
+ anchor: () => w.current?.() ?? null,
16
+ spring: f,
17
+ springAccel: p
17
18
  }), [
18
- s,
19
19
  c,
20
20
  l,
21
- E,
22
- D
21
+ u,
22
+ D,
23
+ O
23
24
  ]);
24
- return t(() => {
25
- if (o) {
26
- if (!v) {
27
- y(!0);
25
+ return s(() => {
26
+ if (n) {
27
+ if (!y) {
28
+ b(!0);
28
29
  return;
29
30
  }
30
- let e = b.current;
31
+ let e = x.current;
31
32
  if (!e) return;
32
- let t = x.current;
33
+ let t = S.current;
33
34
  if (t === "entering" || t === "open") return;
34
- let n = ++S.current;
35
- x.current = "entering", O.onEnter(e, () => {
36
- n === S.current && (x.current = "open", w.current?.());
35
+ let n = ++C.current;
36
+ S.current = "entering", k.onEnter(e, () => {
37
+ n === C.current && (S.current = "open", T.current?.());
37
38
  });
38
39
  return;
39
40
  }
40
- if (!v) return;
41
- let e = b.current;
41
+ if (!y) return;
42
+ let e = x.current;
42
43
  if (!e) {
43
- y(!1);
44
+ b(!1);
44
45
  return;
45
46
  }
46
- if (x.current === "leaving") return;
47
- let t = ++S.current;
48
- x.current = "leaving", O.onLeave(e, () => {
49
- t === S.current && (x.current = "closed", y(!1), T.current?.());
47
+ if (S.current === "leaving") return;
48
+ let t = ++C.current;
49
+ S.current = "leaving", k.onLeave(e, () => {
50
+ t === C.current && (S.current = "closed", b(!1), E.current?.());
50
51
  });
51
52
  }, [
52
- o,
53
- v,
54
- O
53
+ n,
54
+ y,
55
+ k
55
56
  ]), t(() => () => {
56
- S.current++, x.current = "closed", O.cancel();
57
- }, [O]), v ? /* @__PURE__ */ a("div", {
58
- ref: b,
59
- className: h,
60
- style: g,
61
- children: _
57
+ C.current++, S.current = "closed", k.cancel();
58
+ }, [k]), y ? /* @__PURE__ */ o("div", {
59
+ ref: x,
60
+ className: g,
61
+ style: _,
62
+ children: v
62
63
  }) : null;
63
64
  }
64
- export { o as HeroTransition };
65
+ export { c as HeroTransition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hero-animate",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "iOS 风格「图标 ⇄ 窗口」形变转场,框架无关核心 + Vue/React 组件",
6
6
  "author": "SinJayXie",