@xiping/react-components 1.0.39 → 1.0.43
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/dist/cjs/components/flip-text/FlipText.js +1 -1
- package/dist/cjs/components/gradient-text/index.d.ts +10 -0
- package/dist/cjs/components/gradient-text/index.js +1 -0
- package/dist/cjs/components/hyper-text/index.js +1 -1
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -9
- package/dist/cjs/components/pinch-content/PinchContent.d.ts +17 -1
- package/dist/cjs/components/pinch-content/PinchContent.js +1 -1
- package/dist/cjs/components/split-text/SplitText.js +1 -1
- package/dist/cjs/components/text-type/TextType.d.ts +26 -0
- package/dist/cjs/components/text-type/TextType.js +1 -0
- package/dist/cjs/components/text-type/index.d.ts +3 -0
- package/dist/cjs/components/typing-animation/index.js +1 -1
- package/dist/cjs/components/variable-proximity/index.d.ts +15 -0
- package/dist/cjs/components/variable-proximity/index.js +1 -0
- package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/es/components/flip-text/FlipText.js +15 -14
- package/dist/es/components/gradient-text/index.d.ts +10 -0
- package/dist/es/components/gradient-text/index.js +22 -0
- package/dist/es/components/hyper-text/index.js +27 -25
- package/dist/es/components/image-viewer/ImageViewer.js +106 -101
- package/dist/es/components/pinch-content/PinchContent.d.ts +17 -1
- package/dist/es/components/pinch-content/PinchContent.js +120 -79
- package/dist/es/components/split-text/SplitText.js +37 -35
- package/dist/es/components/text-type/TextType.d.ts +26 -0
- package/dist/es/components/text-type/TextType.js +116 -0
- package/dist/es/components/text-type/index.d.ts +3 -0
- package/dist/es/components/typing-animation/index.js +11 -13
- package/dist/es/components/variable-proximity/index.d.ts +15 -0
- package/dist/es/components/variable-proximity/index.js +140 -0
- package/dist/es/components/video-dialog/VideoDialog.js +35 -48
- package/dist/es/index.d.ts +3 -0
- package/dist/es/index.js +60 -54
- package/dist/es/react-components.css +1 -1
- package/package.json +37 -37
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as f, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
function l({
|
|
4
|
+
children: e,
|
|
5
|
+
className: i = "",
|
|
6
|
+
colors: n = ["#40ffaa", "#4079ff", "#40ffaa", "#4079ff", "#40ffaa"],
|
|
7
|
+
animationSpeed: r = 8,
|
|
8
|
+
showBorder: s = !1
|
|
9
|
+
}) {
|
|
10
|
+
const a = {
|
|
11
|
+
backgroundImage: `linear-gradient(to right, ${n.join(", ")})`,
|
|
12
|
+
animationDuration: `${r}s`
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ f("div", { className: `animated-gradient-text ${i}`, children: [
|
|
15
|
+
s && /* @__PURE__ */ t("div", { className: "gradient-overlay", style: a }),
|
|
16
|
+
/* @__PURE__ */ t("div", { className: "text-content", style: a, children: e })
|
|
17
|
+
] });
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
l as GradientText,
|
|
21
|
+
l as default
|
|
22
|
+
};
|
|
@@ -1,69 +1,71 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { cn as
|
|
2
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { cn as h } from "../../utils/utils.js";
|
|
4
4
|
import { motion as x, AnimatePresence as U } from "motion/react";
|
|
5
|
-
import { useState as M, useRef as
|
|
5
|
+
import { useState as M, useRef as d, useEffect as I } from "react";
|
|
6
|
+
/* empty css */
|
|
6
7
|
const j = Object.freeze(
|
|
7
8
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
|
|
8
9
|
), q = (n) => Math.floor(Math.random() * n);
|
|
9
|
-
function
|
|
10
|
+
function B({
|
|
10
11
|
children: n,
|
|
11
12
|
className: C,
|
|
12
|
-
duration:
|
|
13
|
-
delay:
|
|
13
|
+
duration: u = 800,
|
|
14
|
+
delay: o = 0,
|
|
14
15
|
as: E = "div",
|
|
15
|
-
startOnView:
|
|
16
|
+
startOnView: f = !1,
|
|
16
17
|
animateOnHover: F = !0,
|
|
17
18
|
characterSet: s = j,
|
|
18
19
|
...R
|
|
19
20
|
}) {
|
|
20
21
|
const b = x.create(E, {
|
|
21
22
|
forwardMotionProps: !0
|
|
22
|
-
}), [v,
|
|
23
|
+
}), [v, y] = M(
|
|
23
24
|
() => n.split("")
|
|
24
|
-
), [i,
|
|
25
|
-
F && !i && (a.current = 0,
|
|
25
|
+
), [i, r] = M(!1), a = d(0), m = d(null), D = () => {
|
|
26
|
+
F && !i && (a.current = 0, r(!0));
|
|
26
27
|
};
|
|
27
28
|
return I(() => {
|
|
28
|
-
if (!
|
|
29
|
+
if (!f) {
|
|
29
30
|
const t = setTimeout(() => {
|
|
30
|
-
|
|
31
|
-
},
|
|
31
|
+
r(!0);
|
|
32
|
+
}, o);
|
|
32
33
|
return () => clearTimeout(t);
|
|
33
34
|
}
|
|
34
35
|
const e = new IntersectionObserver(
|
|
35
36
|
([t]) => {
|
|
36
37
|
t.isIntersecting && (setTimeout(() => {
|
|
37
|
-
|
|
38
|
-
},
|
|
38
|
+
r(!0);
|
|
39
|
+
}, o), e.disconnect());
|
|
39
40
|
},
|
|
40
41
|
{ threshold: 0.1, rootMargin: "-30% 0px -30% 0px" }
|
|
41
42
|
);
|
|
42
43
|
return m.current && e.observe(m.current), () => e.disconnect();
|
|
43
|
-
}, [
|
|
44
|
+
}, [o, f]), I(() => {
|
|
44
45
|
if (!i) return;
|
|
45
46
|
const e = n.length, t = performance.now();
|
|
46
47
|
let c;
|
|
47
48
|
const l = (H) => {
|
|
48
|
-
const N = H - t,
|
|
49
|
-
a.current =
|
|
49
|
+
const N = H - t, g = Math.min(N / u, 1);
|
|
50
|
+
a.current = g * e, y(
|
|
50
51
|
(P) => P.map(
|
|
51
|
-
(
|
|
52
|
+
(T, A) => T === " " ? T : A <= a.current ? n[A] : s[q(s.length)]
|
|
52
53
|
)
|
|
53
|
-
),
|
|
54
|
+
), g < 1 ? c = requestAnimationFrame(l) : r(!1);
|
|
54
55
|
};
|
|
55
56
|
return c = requestAnimationFrame(l), () => cancelAnimationFrame(c);
|
|
56
|
-
}, [n,
|
|
57
|
+
}, [n, u, i, s]), // eslint-disable-next-line react-hooks/static-components
|
|
58
|
+
/* @__PURE__ */ p(
|
|
57
59
|
b,
|
|
58
60
|
{
|
|
59
61
|
ref: m,
|
|
60
|
-
className:
|
|
62
|
+
className: h("xiping-hyper-container", C),
|
|
61
63
|
onMouseEnter: D,
|
|
62
64
|
...R,
|
|
63
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ p(U, { children: v.map((e, t) => /* @__PURE__ */ p(
|
|
64
66
|
x.span,
|
|
65
67
|
{
|
|
66
|
-
className:
|
|
68
|
+
className: h("xiping-hyper-char", e === " " ? "xiping-hyper-space" : ""),
|
|
67
69
|
children: e.toUpperCase()
|
|
68
70
|
},
|
|
69
71
|
t
|
|
@@ -72,5 +74,5 @@ function z({
|
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
export {
|
|
75
|
-
|
|
77
|
+
B as HyperText
|
|
76
78
|
};
|
|
@@ -1,98 +1,118 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Modal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useState as
|
|
7
|
-
import
|
|
8
|
-
import { Download as
|
|
9
|
-
import { AnimatePresence as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
3
|
+
import { Modal as z, ModalContent as O, Spinner as S } from "@heroui/react";
|
|
4
|
+
import P from "../pinch-content/PinchContent.js";
|
|
5
|
+
import V from "./ImageThumbnails.js";
|
|
6
|
+
import { useState as v, useCallback as b, useEffect as x } from "react";
|
|
7
|
+
import X from "clsx";
|
|
8
|
+
import { Download as B, X as K } from "lucide-react";
|
|
9
|
+
import { AnimatePresence as W, motion as _ } from "motion/react";
|
|
10
|
+
import { cn as f } from "../../utils/utils.js";
|
|
11
|
+
/* empty css */
|
|
12
|
+
const C = (c) => {
|
|
13
|
+
c.target.closest(".xiping-main-content") && c.preventDefault();
|
|
14
|
+
}, ne = (c) => {
|
|
13
15
|
const {
|
|
14
|
-
isOpen:
|
|
15
|
-
onClose:
|
|
16
|
-
imgSrc:
|
|
17
|
-
thumbnailImages:
|
|
18
|
-
canDownload:
|
|
19
|
-
wrapperClassName:
|
|
20
|
-
closeClassName:
|
|
21
|
-
downloadClassName:
|
|
22
|
-
toolWrapperClassName:
|
|
23
|
-
initialIndex:
|
|
24
|
-
} =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
isOpen: a,
|
|
17
|
+
onClose: w,
|
|
18
|
+
imgSrc: d,
|
|
19
|
+
thumbnailImages: N,
|
|
20
|
+
canDownload: y = !1,
|
|
21
|
+
wrapperClassName: I,
|
|
22
|
+
closeClassName: E,
|
|
23
|
+
downloadClassName: L,
|
|
24
|
+
toolWrapperClassName: k,
|
|
25
|
+
initialIndex: D = 0
|
|
26
|
+
} = c, o = Array.isArray(d) ? d : [d], A = N || o, R = Math.max(
|
|
27
|
+
0,
|
|
28
|
+
Math.min(D, o.length - 1)
|
|
29
|
+
), [l, g] = v(R), [M, p] = v(!0), m = b(() => {
|
|
30
|
+
p(!0), w();
|
|
31
|
+
}, [w]), T = async () => {
|
|
32
|
+
const i = o[l];
|
|
28
33
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
} catch (
|
|
32
|
-
console.error("Error downloading image:",
|
|
34
|
+
const r = await (await fetch(i)).blob(), e = window.URL.createObjectURL(r), s = document.createElement("a");
|
|
35
|
+
s.href = e, s.download = i.split("/").pop() || "image", document.body.appendChild(s), s.click(), window.URL.revokeObjectURL(e), document.body.removeChild(s);
|
|
36
|
+
} catch (t) {
|
|
37
|
+
console.error("Error downloading image:", t);
|
|
33
38
|
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
39
|
+
}, U = () => {
|
|
40
|
+
p(!1);
|
|
41
|
+
}, j = () => {
|
|
42
|
+
p(!1);
|
|
38
43
|
};
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
return document.addEventListener("touchmove",
|
|
44
|
+
x(() => {
|
|
45
|
+
if (a)
|
|
46
|
+
return document.addEventListener("touchmove", C, {
|
|
42
47
|
passive: !1
|
|
43
48
|
}), () => {
|
|
44
|
-
document.removeEventListener("touchmove",
|
|
49
|
+
document.removeEventListener("touchmove", C);
|
|
45
50
|
};
|
|
46
|
-
}, [
|
|
47
|
-
|
|
51
|
+
}, [a]);
|
|
52
|
+
const u = b(() => {
|
|
53
|
+
"vibrate" in navigator && navigator.vibrate([50, 50, 50]);
|
|
54
|
+
}, []);
|
|
55
|
+
return x(() => {
|
|
56
|
+
if (!a) return;
|
|
57
|
+
const i = (t) => {
|
|
58
|
+
const r = t.target;
|
|
59
|
+
if (!(r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.isContentEditable))
|
|
60
|
+
switch (t.key) {
|
|
61
|
+
case "ArrowLeft":
|
|
62
|
+
t.preventDefault(), g((e) => e > 0 ? e - 1 : (u(), e));
|
|
63
|
+
break;
|
|
64
|
+
case "ArrowRight":
|
|
65
|
+
t.preventDefault(), g((e) => e < o.length - 1 ? e + 1 : (u(), e));
|
|
66
|
+
break;
|
|
67
|
+
case "Escape":
|
|
68
|
+
t.preventDefault(), m();
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return document.addEventListener("keydown", i), () => {
|
|
73
|
+
document.removeEventListener("keydown", i);
|
|
74
|
+
};
|
|
75
|
+
}, [a, o.length, m, u]), /* @__PURE__ */ n(
|
|
76
|
+
z,
|
|
48
77
|
{
|
|
49
|
-
isOpen:
|
|
78
|
+
isOpen: a,
|
|
50
79
|
size: "full",
|
|
51
80
|
onClose: m,
|
|
52
81
|
classNames: {
|
|
53
|
-
wrapper:
|
|
82
|
+
wrapper: X(I)
|
|
54
83
|
},
|
|
55
|
-
className: "
|
|
84
|
+
className: "xiping-modal-overlay",
|
|
56
85
|
hideCloseButton: !0,
|
|
57
86
|
portalContainer: document.body,
|
|
58
|
-
children: /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
onClick: m
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
),
|
|
86
|
-
/* @__PURE__ */ i("div", { className: "flex-1 min-h-0 relative flex items-center justify-center image-viewer-main-content", children: [
|
|
87
|
-
/* @__PURE__ */ e(U, { canRotate: !1, className: "w-full h-full", children: /* @__PURE__ */ e(V, { mode: "wait", children: /* @__PURE__ */ e(
|
|
88
|
-
W.img,
|
|
87
|
+
children: /* @__PURE__ */ n(O, { className: "xiping-modal-content", children: /* @__PURE__ */ h("div", { className: "xiping-wrapper", children: [
|
|
88
|
+
/* @__PURE__ */ h("div", { className: f("xiping-tool-wrapper", k), children: [
|
|
89
|
+
y && /* @__PURE__ */ n(
|
|
90
|
+
B,
|
|
91
|
+
{
|
|
92
|
+
size: 24,
|
|
93
|
+
className: f("xiping-download-icon", L),
|
|
94
|
+
onClick: T
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ n(
|
|
98
|
+
K,
|
|
99
|
+
{
|
|
100
|
+
size: 24,
|
|
101
|
+
className: f("xiping-close-icon", E),
|
|
102
|
+
onClick: m
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
106
|
+
/* @__PURE__ */ h("div", { className: "xiping-main-content", children: [
|
|
107
|
+
/* @__PURE__ */ n(P, { canRotate: !1, className: "xiping-pinch-content", children: /* @__PURE__ */ n(W, { mode: "wait", children: /* @__PURE__ */ n(
|
|
108
|
+
_.img,
|
|
89
109
|
{
|
|
90
110
|
draggable: "false",
|
|
91
|
-
src:
|
|
111
|
+
src: o[l],
|
|
92
112
|
alt: "",
|
|
93
|
-
className: "
|
|
94
|
-
onLoad:
|
|
95
|
-
onError:
|
|
113
|
+
className: "xiping-image",
|
|
114
|
+
onLoad: U,
|
|
115
|
+
onError: j,
|
|
96
116
|
initial: { opacity: 0, scale: 0.95 },
|
|
97
117
|
animate: { opacity: 1, scale: 1 },
|
|
98
118
|
exit: { opacity: 0, scale: 1.05 },
|
|
@@ -101,37 +121,22 @@ const p = (o) => {
|
|
|
101
121
|
ease: "easeInOut"
|
|
102
122
|
}
|
|
103
123
|
},
|
|
104
|
-
|
|
124
|
+
l
|
|
105
125
|
) }) }),
|
|
106
|
-
|
|
126
|
+
M && /* @__PURE__ */ n("div", { className: "xiping-loading", children: /* @__PURE__ */ n(S, { color: "white", size: "lg" }) })
|
|
107
127
|
] }),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
|
|
128
|
+
/* @__PURE__ */ n(
|
|
129
|
+
V,
|
|
110
130
|
{
|
|
111
|
-
images:
|
|
112
|
-
currentIndex:
|
|
113
|
-
onImageSelect:
|
|
131
|
+
images: A,
|
|
132
|
+
currentIndex: l,
|
|
133
|
+
onImageSelect: g
|
|
114
134
|
}
|
|
115
135
|
)
|
|
116
136
|
] }) })
|
|
117
137
|
}
|
|
118
138
|
);
|
|
119
|
-
}
|
|
120
|
-
.scrollbar-hide {
|
|
121
|
-
-ms-overflow-style: none;
|
|
122
|
-
scrollbar-width: none;
|
|
123
|
-
}
|
|
124
|
-
.scrollbar-hide::-webkit-scrollbar {
|
|
125
|
-
display: none;
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
if (typeof document < "u") {
|
|
129
|
-
const o = "image-viewer-scrollbar-hide";
|
|
130
|
-
if (!document.getElementById(o)) {
|
|
131
|
-
const t = document.createElement("style");
|
|
132
|
-
t.id = o, t.textContent = X, document.head.appendChild(t);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
139
|
+
};
|
|
135
140
|
export {
|
|
136
|
-
|
|
141
|
+
ne as default
|
|
137
142
|
};
|
|
@@ -13,6 +13,22 @@ export interface PinchContentProps {
|
|
|
13
13
|
wheelZoomFactor?: number;
|
|
14
14
|
rubberband?: boolean;
|
|
15
15
|
style?: CSSProperties;
|
|
16
|
+
/** 外部控制的缩放值(受控模式) */
|
|
17
|
+
scale?: number;
|
|
18
|
+
/** 缩放值变化时的回调 */
|
|
19
|
+
onScaleChange?: (scale: number) => void;
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
export interface PinchContentRef {
|
|
22
|
+
/** 放大 */
|
|
23
|
+
zoomIn: (factor?: number) => void;
|
|
24
|
+
/** 缩小 */
|
|
25
|
+
zoomOut: (factor?: number) => void;
|
|
26
|
+
/** 设置缩放值 */
|
|
27
|
+
setScale: (scale: number) => void;
|
|
28
|
+
/** 重置到初始状态 */
|
|
29
|
+
reset: () => void;
|
|
30
|
+
/** 获取当前缩放值 */
|
|
31
|
+
getScale: () => number;
|
|
32
|
+
}
|
|
33
|
+
declare const PinchContent: import('react').ForwardRefExoticComponent<PinchContentProps & import('react').RefAttributes<PinchContentRef>>;
|
|
18
34
|
export default PinchContent;
|
|
@@ -1,86 +1,127 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { createUseGesture as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useMount as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { jsx as U } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as W, animated as j } from "@react-spring/web";
|
|
3
|
+
import { createUseGesture as F, dragAction as H, pinchAction as O, wheelAction as k } from "@use-gesture/react";
|
|
4
|
+
import { forwardRef as q, useRef as J, useEffect as K, useImperativeHandle as Q } from "react";
|
|
5
|
+
import { useMount as T, useUnmount as V } from "ahooks";
|
|
6
|
+
import X from "clsx";
|
|
7
|
+
const Y = F([H, O, k]), i = (u) => u.preventDefault(), _ = q(
|
|
8
|
+
(u, x) => {
|
|
9
|
+
const {
|
|
10
|
+
className: p,
|
|
11
|
+
children: S,
|
|
12
|
+
pinchWithoutMove: v = !1,
|
|
13
|
+
canPinch: h = !0,
|
|
14
|
+
canDrag: y = !0,
|
|
15
|
+
canRotate: M = !0,
|
|
16
|
+
scaleBounds: r = { min: 0.3, max: 10 },
|
|
17
|
+
wheelZoomFactor: E = 1e-3,
|
|
18
|
+
rubberband: w = !0,
|
|
19
|
+
scale: m,
|
|
20
|
+
onScaleChange: d
|
|
21
|
+
} = u, a = J(null);
|
|
22
|
+
T(() => {
|
|
23
|
+
a.current?.addEventListener("gesturestart", i), a.current?.addEventListener("gesturechange", i), a.current?.addEventListener("gestureend", i);
|
|
24
|
+
}), V(() => {
|
|
25
|
+
a.current?.removeEventListener("gesturestart", i), a.current?.removeEventListener("gesturechange", i), a.current?.removeEventListener("gestureend", i);
|
|
26
|
+
});
|
|
27
|
+
const L = m ?? 1, [t, c] = W(() => ({
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
scale: L,
|
|
31
|
+
rotateZ: 0
|
|
32
|
+
}));
|
|
33
|
+
K(() => {
|
|
34
|
+
if (m !== void 0) {
|
|
35
|
+
const e = Math.min(
|
|
36
|
+
Math.max(m, r.min),
|
|
37
|
+
r.max
|
|
37
38
|
);
|
|
38
|
-
|
|
39
|
+
c.start({ scale: e });
|
|
40
|
+
}
|
|
41
|
+
}, [m, r.min, r.max, c]);
|
|
42
|
+
const g = (e) => {
|
|
43
|
+
const n = Math.min(
|
|
44
|
+
Math.max(e, r.min),
|
|
45
|
+
r.max
|
|
46
|
+
);
|
|
47
|
+
c.start({ scale: n }), d?.(n);
|
|
48
|
+
};
|
|
49
|
+
return Q(x, () => ({
|
|
50
|
+
zoomIn: (e = 1.2) => {
|
|
51
|
+
const n = t.scale.get();
|
|
52
|
+
g(n * e);
|
|
53
|
+
},
|
|
54
|
+
zoomOut: (e = 1.2) => {
|
|
55
|
+
const n = t.scale.get();
|
|
56
|
+
g(n / e);
|
|
39
57
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
g.start({ x: u, y: n });
|
|
58
|
+
setScale: (e) => {
|
|
59
|
+
g(e);
|
|
43
60
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
reset: () => {
|
|
62
|
+
c.start({ x: 0, y: 0, scale: 1, rotateZ: 0 }), d?.(1);
|
|
63
|
+
},
|
|
64
|
+
getScale: () => t.scale.get()
|
|
65
|
+
})), Y(
|
|
66
|
+
{
|
|
67
|
+
onWheel: ({ delta: [, e] }) => {
|
|
68
|
+
if (!h) return;
|
|
69
|
+
const l = t.scale.get() * (1 - e * E), s = Math.min(
|
|
70
|
+
Math.max(l, r.min),
|
|
71
|
+
r.max
|
|
72
|
+
);
|
|
73
|
+
c.start({ scale: s }), d?.(s);
|
|
74
|
+
},
|
|
75
|
+
onDrag: ({ pinching: e, cancel: n, offset: [l, s] }) => {
|
|
76
|
+
if (!y || e) return n();
|
|
77
|
+
c.start({ x: l, y: s });
|
|
78
|
+
},
|
|
79
|
+
onPinch: ({
|
|
80
|
+
origin: [e, n],
|
|
81
|
+
first: l,
|
|
82
|
+
movement: [s],
|
|
83
|
+
offset: [R, Z],
|
|
84
|
+
memo: o,
|
|
85
|
+
cancel: b
|
|
86
|
+
}) => {
|
|
87
|
+
if (!h) return b();
|
|
88
|
+
if (l) {
|
|
89
|
+
const { width: D, height: N, x: z, y: B } = a.current.getBoundingClientRect(), G = e - (z + D / 2), I = n - (B + N / 2);
|
|
90
|
+
o = [t.x.get(), t.y.get(), G, I];
|
|
91
|
+
}
|
|
92
|
+
const f = Math.min(
|
|
93
|
+
Math.max(R, r.min),
|
|
94
|
+
r.max
|
|
95
|
+
), C = o[0] - (s - 1) * o[2], P = o[1] - (s - 1) * o[3], A = {
|
|
96
|
+
scale: f,
|
|
97
|
+
rotateZ: M ? Z : t.rotateZ.get(),
|
|
98
|
+
...v ? { x: t.x.get(), y: t.y.get() } : { x: C, y: P }
|
|
99
|
+
};
|
|
100
|
+
return c.start(A), d?.(f), o;
|
|
56
101
|
}
|
|
57
|
-
const w = s[0] - (n - 1) * s[2], S = s[1] - (n - 1) * s[3], b = {
|
|
58
|
-
scale: i,
|
|
59
|
-
rotateZ: v ? E : t.rotateZ.get(),
|
|
60
|
-
...m ? { x: t.x.get(), y: t.y.get() } : { x: w, y: S }
|
|
61
|
-
};
|
|
62
|
-
return g.start(b), s;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
target: e,
|
|
67
|
-
drag: { from: () => [t.x.get(), t.y.get()] },
|
|
68
|
-
pinch: { scaleBounds: l, rubberband: y },
|
|
69
|
-
wheel: { enabled: !0 }
|
|
70
|
-
}
|
|
71
|
-
), /* @__PURE__ */ B(
|
|
72
|
-
G.div,
|
|
73
|
-
{
|
|
74
|
-
className: z("select-none", f),
|
|
75
|
-
ref: e,
|
|
76
|
-
style: {
|
|
77
|
-
...c.style,
|
|
78
|
-
...t
|
|
79
102
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
103
|
+
{
|
|
104
|
+
target: a,
|
|
105
|
+
drag: { from: () => [t.x.get(), t.y.get()] },
|
|
106
|
+
pinch: { scaleBounds: r, rubberband: w },
|
|
107
|
+
wheel: { enabled: !0 }
|
|
108
|
+
}
|
|
109
|
+
), /* @__PURE__ */ U(
|
|
110
|
+
j.div,
|
|
111
|
+
{
|
|
112
|
+
className: X(p),
|
|
113
|
+
ref: a,
|
|
114
|
+
style: {
|
|
115
|
+
userSelect: "none",
|
|
116
|
+
...u.style,
|
|
117
|
+
...t
|
|
118
|
+
},
|
|
119
|
+
children: S
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
_.displayName = "PinchContent";
|
|
84
125
|
export {
|
|
85
|
-
|
|
126
|
+
_ as default
|
|
86
127
|
};
|