@cher1shrxd/webview-stack-kit 1.0.0 → 1.0.1
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationStackView.d.ts","sourceRoot":"","sources":["../../src/components/NavigationStackView.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,+
|
|
1
|
+
{"version":3,"file":"NavigationStackView.d.ts","sourceRoot":"","sources":["../../src/components/NavigationStackView.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,+CA4H/B,CAAC"}
|
|
@@ -7,6 +7,20 @@ export const NavigationStackView = () => {
|
|
|
7
7
|
const { stack, pop, remove } = useStack();
|
|
8
8
|
const topScreenRef = useRef(null);
|
|
9
9
|
const dragInfo = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handlePopState = (e) => {
|
|
12
|
+
e.preventDefault?.();
|
|
13
|
+
if (stack.length > 1) {
|
|
14
|
+
pop();
|
|
15
|
+
window.history.pushState(null, '', window.location.href);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
window.history.pushState(null, '', window.location.href);
|
|
19
|
+
window.addEventListener('popstate', handlePopState);
|
|
20
|
+
return () => {
|
|
21
|
+
window.removeEventListener('popstate', handlePopState);
|
|
22
|
+
};
|
|
23
|
+
}, [stack.length, pop]);
|
|
10
24
|
const handleDragEnd = useCallback(() => {
|
|
11
25
|
if (!dragInfo.current?.isDragging)
|
|
12
26
|
return;
|
|
@@ -35,9 +49,12 @@ export const NavigationStackView = () => {
|
|
|
35
49
|
else {
|
|
36
50
|
clientX = e.clientX;
|
|
37
51
|
}
|
|
52
|
+
const distance = clientX - dragInfo.current.startX;
|
|
53
|
+
if (distance < 0)
|
|
54
|
+
return;
|
|
38
55
|
dragInfo.current.lastX = clientX;
|
|
39
56
|
if (topScreenRef.current) {
|
|
40
|
-
topScreenRef.current.style.transform = `translateX(${
|
|
57
|
+
topScreenRef.current.style.transform = `translateX(${distance}px)`;
|
|
41
58
|
}
|
|
42
59
|
}, []);
|
|
43
60
|
const handleDragStart = useCallback((e, index) => {
|
|
@@ -52,6 +69,10 @@ export const NavigationStackView = () => {
|
|
|
52
69
|
else {
|
|
53
70
|
clientX = e.clientX;
|
|
54
71
|
}
|
|
72
|
+
// 화면 왼쪽 가장자리에서만 스와이프 시작 허용 (왼쪽 20% 이내)
|
|
73
|
+
const screenWidth = window.innerWidth;
|
|
74
|
+
if (clientX > screenWidth * 0.2)
|
|
75
|
+
return;
|
|
55
76
|
dragInfo.current = {
|
|
56
77
|
isDragging: true,
|
|
57
78
|
startX: clientX,
|