react-panel-layout 0.6.0 → 0.6.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.
- package/dist/{FloatingPanelFrame-SgYLc6Ud.js → FloatingPanelFrame-3eU9AwPo.js} +2 -2
- package/dist/{FloatingPanelFrame-SgYLc6Ud.js.map → FloatingPanelFrame-3eU9AwPo.js.map} +1 -1
- package/dist/FloatingWindow-CUXnEtrb.js +827 -0
- package/dist/FloatingWindow-CUXnEtrb.js.map +1 -0
- package/dist/FloatingWindow-DMwyK0eK.cjs +2 -0
- package/dist/FloatingWindow-DMwyK0eK.cjs.map +1 -0
- package/dist/GridLayout-DKTg_N61.cjs +2 -0
- package/dist/{GridLayout-B4VRsC0r.cjs.map → GridLayout-DKTg_N61.cjs.map} +1 -1
- package/dist/{GridLayout-BltqeCPK.js → GridLayout-UWNxXw77.js} +34 -35
- package/dist/{GridLayout-BltqeCPK.js.map → GridLayout-UWNxXw77.js.map} +1 -1
- package/dist/{HorizontalDivider-WF1k_qND.js → HorizontalDivider-DdxzfV0l.js} +3 -3
- package/dist/{HorizontalDivider-WF1k_qND.js.map → HorizontalDivider-DdxzfV0l.js.map} +1 -1
- package/dist/{HorizontalDivider-B5Z-KZLk.cjs → HorizontalDivider-_pgV4Mcv.cjs} +2 -2
- package/dist/{HorizontalDivider-B5Z-KZLk.cjs.map → HorizontalDivider-_pgV4Mcv.cjs.map} +1 -1
- package/dist/{PanelSystem-Dr1TBhxM.js → PanelSystem-BqUzNtf2.js} +5 -5
- package/dist/{PanelSystem-Dr1TBhxM.js.map → PanelSystem-BqUzNtf2.js.map} +1 -1
- package/dist/{PanelSystem-Bs8bQwQF.cjs → PanelSystem-D603LKKv.cjs} +2 -2
- package/dist/{PanelSystem-Bs8bQwQF.cjs.map → PanelSystem-D603LKKv.cjs.map} +1 -1
- package/dist/ResizeHandle-CBcAS918.cjs +2 -0
- package/dist/{ResizeHandle-CScipO5l.cjs.map → ResizeHandle-CBcAS918.cjs.map} +1 -1
- package/dist/{ResizeHandle-CdA_JYfN.js → ResizeHandle-CXjc1meV.js} +28 -29
- package/dist/{ResizeHandle-CdA_JYfN.js.map → ResizeHandle-CXjc1meV.js.map} +1 -1
- package/dist/SwipePivotTabBar-DWrCuwEI.js +411 -0
- package/dist/SwipePivotTabBar-DWrCuwEI.js.map +1 -0
- package/dist/SwipePivotTabBar-fjjXkpj7.cjs +2 -0
- package/dist/SwipePivotTabBar-fjjXkpj7.cjs.map +1 -0
- package/dist/components/gesture/SwipeSafeZone.d.ts +40 -0
- package/dist/components/window/Drawer.d.ts +3 -1
- package/dist/components/window/DrawerLayers.d.ts +1 -1
- package/dist/components/window/drawerStyles.d.ts +69 -0
- package/dist/components/window/drawerSwipeConfig.d.ts +29 -0
- package/dist/components/window/useDrawerSwipeTransform.d.ts +23 -0
- package/dist/config.cjs +1 -1
- package/dist/config.js +3 -3
- package/dist/constants/styles.d.ts +17 -0
- package/dist/dialog/index.d.ts +69 -0
- package/dist/floating.js +1 -1
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +2 -2
- package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +7 -0
- package/dist/hooks/gesture/types.d.ts +48 -5
- package/dist/hooks/gesture/utils.d.ts +19 -0
- package/dist/hooks/useAnimationFrame.d.ts +2 -0
- package/dist/hooks/useOperationContinuity.d.ts +64 -0
- package/dist/hooks/useResizeObserver.d.ts +33 -1
- package/dist/hooks/useSharedElementTransition.d.ts +112 -0
- package/dist/hooks/useSwipeContentTransform.d.ts +9 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/modules/dialog/AlertDialog.d.ts +9 -0
- package/dist/modules/dialog/DialogContainer.d.ts +37 -0
- package/dist/modules/dialog/Modal.d.ts +26 -0
- package/dist/modules/dialog/SwipeDialogContainer.d.ts +16 -0
- package/dist/modules/dialog/dialogAnimationUtils.d.ts +113 -0
- package/dist/modules/dialog/types.d.ts +183 -0
- package/dist/modules/dialog/useDialog.d.ts +39 -0
- package/dist/modules/dialog/useDialogContainer.d.ts +47 -0
- package/dist/modules/dialog/useDialogSwipeInput.d.ts +70 -0
- package/dist/modules/dialog/useDialogTransform.d.ts +82 -0
- package/dist/modules/drawer/types.d.ts +74 -0
- package/dist/modules/drawer/useDrawerSwipeInput.d.ts +24 -0
- package/dist/modules/pivot/SwipePivotTabBar.d.ts +3 -0
- package/dist/modules/stack/SwipeStackContent.d.ts +6 -3
- package/dist/modules/stack/SwipeStackOutlet.d.ts +4 -4
- package/dist/modules/stack/computeSwipeStackTransform.d.ts +1 -1
- package/dist/panels.cjs +1 -1
- package/dist/panels.js +1 -1
- package/dist/pivot.cjs +1 -1
- package/dist/pivot.js +1 -1
- package/dist/resizer.cjs +1 -1
- package/dist/resizer.js +2 -2
- package/dist/stack.cjs +1 -1
- package/dist/stack.cjs.map +1 -1
- package/dist/stack.js +503 -762
- package/dist/stack.js.map +1 -1
- package/dist/sticky-header/calculateStickyMetrics.d.ts +28 -0
- package/dist/sticky-header.cjs +1 -1
- package/dist/sticky-header.cjs.map +1 -1
- package/dist/sticky-header.js +59 -51
- package/dist/sticky-header.js.map +1 -1
- package/dist/{styles-DPPuJ0sf.js → styles-NkjuMOVS.js} +13 -13
- package/dist/{styles-DPPuJ0sf.js.map → styles-NkjuMOVS.js.map} +1 -1
- package/dist/styles-qf6ptVLD.cjs.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/useDocumentPointerEvents-DXxw3qWj.js +54 -0
- package/dist/useDocumentPointerEvents-DXxw3qWj.js.map +1 -0
- package/dist/useDocumentPointerEvents-DxDSOtip.cjs +2 -0
- package/dist/useDocumentPointerEvents-DxDSOtip.cjs.map +1 -0
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs +2 -0
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +1 -0
- package/dist/useNativeGestureGuard-CGYo6O0r.js +347 -0
- package/dist/useNativeGestureGuard-CGYo6O0r.js.map +1 -0
- package/dist/window/index.d.ts +2 -0
- package/dist/window.cjs +1 -1
- package/dist/window.cjs.map +1 -1
- package/dist/window.js +114 -103
- package/dist/window.js.map +1 -1
- package/package.json +6 -1
- package/src/components/gesture/SwipeSafeZone.tsx +69 -0
- package/src/components/window/Drawer.tsx +249 -162
- package/src/components/window/DrawerLayers.tsx +13 -3
- package/src/components/window/drawerStyles.spec.ts +263 -0
- package/src/components/window/drawerStyles.ts +228 -0
- package/src/components/window/drawerSwipeConfig.spec.ts +131 -0
- package/src/components/window/drawerSwipeConfig.ts +112 -0
- package/src/components/window/useDrawerSwipeTransform.spec.ts +234 -0
- package/src/components/window/useDrawerSwipeTransform.ts +129 -0
- package/src/constants/styles.ts +19 -0
- package/src/demo/pages/Dialog/alerts/index.tsx +22 -0
- package/src/demo/pages/Dialog/card/index.tsx +22 -0
- package/src/demo/pages/Dialog/components/AlertDialogDemo.tsx +124 -0
- package/src/demo/pages/Dialog/components/CardExpandDemo.module.css +243 -0
- package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +204 -0
- package/src/demo/pages/Dialog/components/CustomAlertDialogDemo.tsx +219 -0
- package/src/demo/pages/Dialog/components/DialogDemos.module.css +77 -0
- package/src/demo/pages/Dialog/components/ModalBasics.tsx +45 -0
- package/src/demo/pages/Dialog/components/SwipeDialogDemo.module.css +77 -0
- package/src/demo/pages/Dialog/components/SwipeDialogDemo.tsx +181 -0
- package/src/demo/pages/Dialog/custom-alert/index.tsx +22 -0
- package/src/demo/pages/Dialog/modal/index.tsx +17 -0
- package/src/demo/pages/Dialog/swipe/index.tsx +22 -0
- package/src/demo/pages/Drawer/components/DrawerSwipe.module.css +316 -0
- package/src/demo/pages/Drawer/components/DrawerSwipe.tsx +178 -0
- package/src/demo/pages/Drawer/swipe/index.tsx +17 -0
- package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +54 -23
- package/src/demo/pages/Pivot/swipe-debug/index.tsx +1 -1
- package/src/demo/pages/Stack/components/StackBasics.spec.tsx +152 -0
- package/src/demo/pages/Stack/components/StackBasics.tsx +179 -95
- package/src/demo/pages/Stack/components/StackTablet.spec.tsx +120 -0
- package/src/demo/pages/Stack/components/StackTablet.tsx +42 -21
- package/src/demo/routes.tsx +22 -1
- package/src/dialog/index.ts +85 -0
- package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +68 -64
- package/src/hooks/gesture/testing/createGestureSimulator.ts +112 -37
- package/src/hooks/gesture/types.ts +83 -6
- package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +22 -14
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +91 -31
- package/src/hooks/gesture/useNativeGestureGuard.ts +3 -1
- package/src/hooks/gesture/utils.ts +91 -0
- package/src/hooks/useAnimatedVisibility.spec.ts +44 -24
- package/src/hooks/useAnimatedVisibility.ts +28 -2
- package/src/hooks/useAnimationFrame.ts +8 -0
- package/src/hooks/useOperationContinuity.spec.ts +387 -0
- package/src/hooks/useOperationContinuity.ts +135 -0
- package/src/hooks/useResizeObserver.spec.tsx +277 -0
- package/src/hooks/useResizeObserver.tsx +108 -39
- package/src/hooks/useScrollContainer.ts +4 -10
- package/src/hooks/useSharedElementTransition.ts +333 -0
- package/src/hooks/useSwipeContentTransform.spec.ts +18 -18
- package/src/hooks/useSwipeContentTransform.ts +166 -28
- package/src/modules/dialog/AlertDialog.spec.tsx +387 -0
- package/src/modules/dialog/AlertDialog.tsx +221 -0
- package/src/modules/dialog/DialogContainer.spec.tsx +228 -0
- package/src/modules/dialog/DialogContainer.tsx +188 -0
- package/src/modules/dialog/Modal.spec.tsx +220 -0
- package/src/modules/dialog/Modal.tsx +182 -0
- package/src/modules/dialog/SwipeDialogContainer.tsx +208 -0
- package/src/modules/dialog/dialogAnimationUtils.spec.ts +253 -0
- package/src/modules/dialog/dialogAnimationUtils.ts +297 -0
- package/src/modules/dialog/types.ts +186 -0
- package/src/modules/dialog/useDialog.spec.tsx +447 -0
- package/src/modules/dialog/useDialog.ts +214 -0
- package/src/modules/dialog/useDialogContainer.spec.ts +331 -0
- package/src/modules/dialog/useDialogContainer.ts +150 -0
- package/src/modules/dialog/useDialogSwipeInput.spec.ts +157 -0
- package/src/modules/dialog/useDialogSwipeInput.ts +319 -0
- package/src/modules/dialog/useDialogTransform.spec.ts +370 -0
- package/src/modules/dialog/useDialogTransform.ts +407 -0
- package/src/modules/drawer/types.ts +102 -0
- package/src/modules/drawer/useDrawerSwipeInput.spec.ts +566 -0
- package/src/modules/drawer/useDrawerSwipeInput.ts +399 -0
- package/src/modules/panels/rendering/ContentRegistry.spec.tsx +21 -14
- package/src/modules/pivot/SwipePivotContent.position.spec.tsx +12 -8
- package/src/modules/pivot/SwipePivotContent.spec.tsx +55 -25
- package/src/modules/pivot/SwipePivotContent.tsx +2 -2
- package/src/modules/pivot/SwipePivotTabBar.spec.tsx +85 -68
- package/src/modules/pivot/SwipePivotTabBar.tsx +75 -15
- package/src/modules/pivot/scaleInputState.spec.ts +11 -2
- package/src/modules/pivot/usePivot.spec.ts +17 -3
- package/src/modules/pivot/usePivotSwipeInput.spec.ts +182 -123
- package/src/modules/stack/SwipeStackContent.spec.tsx +387 -100
- package/src/modules/stack/SwipeStackContent.tsx +43 -33
- package/src/modules/stack/SwipeStackOutlet.spec.tsx +14 -16
- package/src/modules/stack/SwipeStackOutlet.tsx +6 -6
- package/src/modules/stack/computeSwipeStackTransform.spec.ts +5 -5
- package/src/modules/stack/computeSwipeStackTransform.ts +3 -3
- package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1133 -0
- package/src/modules/stack/useStackAnimationState.spec.ts +3 -1
- package/src/modules/stack/useStackAnimationState.ts +18 -13
- package/src/modules/stack/useStackNavigation.spec.ts +198 -3
- package/src/modules/stack/useStackNavigation.tsx +113 -56
- package/src/modules/stack/useStackSwipeInput.spec.ts +65 -32
- package/src/modules/stack/useStackSwipeInput.ts +1 -1
- package/src/sticky-header/StickyArea.tsx +29 -57
- package/src/sticky-header/calculateStickyMetrics.spec.ts +105 -0
- package/src/sticky-header/calculateStickyMetrics.ts +50 -0
- package/src/types.ts +18 -0
- package/src/window/index.ts +2 -0
- package/dist/FloatingWindow-BpdOpg_L.js +0 -400
- package/dist/FloatingWindow-BpdOpg_L.js.map +0 -1
- package/dist/FloatingWindow-TCDNY5gE.cjs +0 -2
- package/dist/FloatingWindow-TCDNY5gE.cjs.map +0 -1
- package/dist/GridLayout-B4VRsC0r.cjs +0 -2
- package/dist/ResizeHandle-CScipO5l.cjs +0 -2
- package/dist/SwipePivotTabBar-BGO9X94m.js +0 -407
- package/dist/SwipePivotTabBar-BGO9X94m.js.map +0 -1
- package/dist/SwipePivotTabBar-BrQismcZ.cjs +0 -2
- package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +0 -1
- package/dist/useDocumentPointerEvents-CKdhGXd0.js +0 -46
- package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +0 -1
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +0 -2
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +0 -1
- package/dist/useEffectEvent-Dp7HLCf0.js +0 -13
- package/dist/useEffectEvent-Dp7HLCf0.js.map +0 -1
- package/dist/useEffectEvent-huSsGUnl.cjs +0 -2
- package/dist/useEffectEvent-huSsGUnl.cjs.map +0 -1
|
@@ -8,67 +8,64 @@
|
|
|
8
8
|
* 4. Button navigation: when navigationDepth changes without swipe, panels should animate
|
|
9
9
|
*/
|
|
10
10
|
import { render, act } from "@testing-library/react";
|
|
11
|
-
import { beforeEach, afterEach, vi } from "vitest";
|
|
12
11
|
import { SwipeStackContent } from "./SwipeStackContent.js";
|
|
13
|
-
import type {
|
|
12
|
+
import type { ContinuousOperationState } from "../../hooks/gesture/types.js";
|
|
14
13
|
|
|
15
14
|
// Mock requestAnimationFrame for animation testing
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const rafState = {
|
|
16
|
+
callbacks: [] as FrameRequestCallback[],
|
|
17
|
+
id: 0,
|
|
18
|
+
mockTimestamp: 0,
|
|
19
|
+
originalRAF: globalThis.requestAnimationFrame,
|
|
20
|
+
originalCAF: globalThis.cancelAnimationFrame,
|
|
21
|
+
};
|
|
19
22
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const resetRafState = (): void => {
|
|
24
|
+
rafState.callbacks = [];
|
|
25
|
+
rafState.id = 0;
|
|
26
|
+
rafState.mockTimestamp = 0;
|
|
27
|
+
};
|
|
24
28
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const mockRAF = (callback: FrameRequestCallback): number => {
|
|
30
|
+
rafState.callbacks = [...rafState.callbacks, callback];
|
|
31
|
+
rafState.id += 1;
|
|
32
|
+
return rafState.id;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const mockCAF = (): void => {};
|
|
28
36
|
|
|
29
37
|
/**
|
|
30
38
|
* Flush all pending RAF callbacks.
|
|
31
39
|
* @param advanceMs - How much to advance the mock timestamp (default: 400ms to complete 300ms animation)
|
|
32
40
|
*/
|
|
33
|
-
const flushRAF = (advanceMs = 400) => {
|
|
34
|
-
mockTimestamp += advanceMs;
|
|
35
|
-
const callbacks =
|
|
36
|
-
|
|
37
|
-
callbacks.forEach(cb => cb(mockTimestamp));
|
|
41
|
+
const flushRAF = (advanceMs = 400): void => {
|
|
42
|
+
rafState.mockTimestamp += advanceMs;
|
|
43
|
+
const callbacks = rafState.callbacks;
|
|
44
|
+
rafState.callbacks = [];
|
|
45
|
+
callbacks.forEach((cb) => cb(rafState.mockTimestamp));
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
beforeEach(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
vi.stubGlobal("requestAnimationFrame", mockRAF);
|
|
45
|
-
vi.stubGlobal("cancelAnimationFrame", mockCAF);
|
|
49
|
+
resetRafState();
|
|
50
|
+
globalThis.requestAnimationFrame = mockRAF;
|
|
51
|
+
globalThis.cancelAnimationFrame = mockCAF;
|
|
46
52
|
});
|
|
47
53
|
|
|
48
54
|
afterEach(() => {
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
globalThis.requestAnimationFrame = rafState.originalRAF;
|
|
56
|
+
globalThis.cancelAnimationFrame = rafState.originalCAF;
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
const IDLE_STATE:
|
|
59
|
+
const IDLE_STATE: ContinuousOperationState = {
|
|
54
60
|
phase: "idle",
|
|
55
61
|
displacement: { x: 0, y: 0 },
|
|
56
62
|
velocity: { x: 0, y: 0 },
|
|
57
|
-
direction: 0,
|
|
58
63
|
};
|
|
59
64
|
|
|
60
|
-
const
|
|
61
|
-
phase: "
|
|
65
|
+
const createOperatingState = (displacementX: number): ContinuousOperationState => ({
|
|
66
|
+
phase: "operating",
|
|
62
67
|
displacement: { x: displacementX, y: 0 },
|
|
63
68
|
velocity: { x: 0.5, y: 0 },
|
|
64
|
-
direction: displacementX > 0 ? 1 : displacementX < 0 ? -1 : 0,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const createTrackingState = (displacementX: number): SwipeInputState => ({
|
|
68
|
-
phase: "tracking",
|
|
69
|
-
displacement: { x: displacementX, y: 0 },
|
|
70
|
-
velocity: { x: 0.1, y: 0 },
|
|
71
|
-
direction: 0,
|
|
72
69
|
});
|
|
73
70
|
|
|
74
71
|
describe("SwipeStackContent", () => {
|
|
@@ -80,7 +77,7 @@ describe("SwipeStackContent", () => {
|
|
|
80
77
|
depth={0}
|
|
81
78
|
navigationDepth={0}
|
|
82
79
|
isActive={true}
|
|
83
|
-
|
|
80
|
+
operationState={IDLE_STATE}
|
|
84
81
|
containerSize={400}
|
|
85
82
|
>
|
|
86
83
|
<div>Test Content</div>
|
|
@@ -97,7 +94,7 @@ describe("SwipeStackContent", () => {
|
|
|
97
94
|
depth={1}
|
|
98
95
|
navigationDepth={1}
|
|
99
96
|
isActive={true}
|
|
100
|
-
|
|
97
|
+
operationState={IDLE_STATE}
|
|
101
98
|
containerSize={400}
|
|
102
99
|
>
|
|
103
100
|
Content
|
|
@@ -118,7 +115,7 @@ describe("SwipeStackContent", () => {
|
|
|
118
115
|
depth={0}
|
|
119
116
|
navigationDepth={1}
|
|
120
117
|
isActive={false}
|
|
121
|
-
|
|
118
|
+
operationState={IDLE_STATE}
|
|
122
119
|
containerSize={400}
|
|
123
120
|
>
|
|
124
121
|
Content
|
|
@@ -138,7 +135,7 @@ describe("SwipeStackContent", () => {
|
|
|
138
135
|
depth={1}
|
|
139
136
|
navigationDepth={1}
|
|
140
137
|
isActive={true}
|
|
141
|
-
|
|
138
|
+
operationState={IDLE_STATE}
|
|
142
139
|
containerSize={400}
|
|
143
140
|
>
|
|
144
141
|
Content
|
|
@@ -156,7 +153,7 @@ describe("SwipeStackContent", () => {
|
|
|
156
153
|
depth={0}
|
|
157
154
|
navigationDepth={1}
|
|
158
155
|
isActive={false}
|
|
159
|
-
|
|
156
|
+
operationState={IDLE_STATE}
|
|
160
157
|
containerSize={400}
|
|
161
158
|
>
|
|
162
159
|
Content
|
|
@@ -174,7 +171,7 @@ describe("SwipeStackContent", () => {
|
|
|
174
171
|
depth={0}
|
|
175
172
|
navigationDepth={1}
|
|
176
173
|
isActive={false}
|
|
177
|
-
|
|
174
|
+
operationState={createOperatingState(100)}
|
|
178
175
|
containerSize={400}
|
|
179
176
|
>
|
|
180
177
|
Content
|
|
@@ -194,7 +191,7 @@ describe("SwipeStackContent", () => {
|
|
|
194
191
|
depth={1}
|
|
195
192
|
navigationDepth={1}
|
|
196
193
|
isActive={true}
|
|
197
|
-
|
|
194
|
+
operationState={IDLE_STATE}
|
|
198
195
|
containerSize={400}
|
|
199
196
|
>
|
|
200
197
|
Content
|
|
@@ -208,7 +205,7 @@ describe("SwipeStackContent", () => {
|
|
|
208
205
|
depth={1}
|
|
209
206
|
navigationDepth={1}
|
|
210
207
|
isActive={true}
|
|
211
|
-
|
|
208
|
+
operationState={createOperatingState(150)}
|
|
212
209
|
containerSize={400}
|
|
213
210
|
>
|
|
214
211
|
Content
|
|
@@ -226,7 +223,7 @@ describe("SwipeStackContent", () => {
|
|
|
226
223
|
depth={0}
|
|
227
224
|
navigationDepth={1}
|
|
228
225
|
isActive={false}
|
|
229
|
-
|
|
226
|
+
operationState={IDLE_STATE}
|
|
230
227
|
containerSize={400}
|
|
231
228
|
>
|
|
232
229
|
Content
|
|
@@ -240,7 +237,7 @@ describe("SwipeStackContent", () => {
|
|
|
240
237
|
depth={0}
|
|
241
238
|
navigationDepth={1}
|
|
242
239
|
isActive={false}
|
|
243
|
-
|
|
240
|
+
operationState={createOperatingState(200)}
|
|
244
241
|
containerSize={400}
|
|
245
242
|
>
|
|
246
243
|
Content
|
|
@@ -261,7 +258,7 @@ describe("SwipeStackContent", () => {
|
|
|
261
258
|
depth={3}
|
|
262
259
|
navigationDepth={3}
|
|
263
260
|
isActive={true}
|
|
264
|
-
|
|
261
|
+
operationState={IDLE_STATE}
|
|
265
262
|
containerSize={400}
|
|
266
263
|
>
|
|
267
264
|
Content
|
|
@@ -281,7 +278,7 @@ describe("SwipeStackContent", () => {
|
|
|
281
278
|
depth={1}
|
|
282
279
|
navigationDepth={1}
|
|
283
280
|
isActive={true}
|
|
284
|
-
|
|
281
|
+
operationState={IDLE_STATE}
|
|
285
282
|
containerSize={400}
|
|
286
283
|
>
|
|
287
284
|
Content
|
|
@@ -299,7 +296,7 @@ describe("SwipeStackContent", () => {
|
|
|
299
296
|
depth={0}
|
|
300
297
|
navigationDepth={1}
|
|
301
298
|
isActive={false}
|
|
302
|
-
|
|
299
|
+
operationState={IDLE_STATE}
|
|
303
300
|
containerSize={400}
|
|
304
301
|
>
|
|
305
302
|
Content
|
|
@@ -319,7 +316,7 @@ describe("SwipeStackContent", () => {
|
|
|
319
316
|
depth={1}
|
|
320
317
|
navigationDepth={1}
|
|
321
318
|
isActive={true}
|
|
322
|
-
|
|
319
|
+
operationState={IDLE_STATE}
|
|
323
320
|
containerSize={400}
|
|
324
321
|
>
|
|
325
322
|
Content
|
|
@@ -339,7 +336,7 @@ describe("SwipeStackContent", () => {
|
|
|
339
336
|
depth={1}
|
|
340
337
|
navigationDepth={1}
|
|
341
338
|
isActive={true}
|
|
342
|
-
|
|
339
|
+
operationState={createOperatingState(50)}
|
|
343
340
|
containerSize={400}
|
|
344
341
|
>
|
|
345
342
|
Content
|
|
@@ -355,7 +352,7 @@ describe("SwipeStackContent", () => {
|
|
|
355
352
|
depth={1}
|
|
356
353
|
navigationDepth={1}
|
|
357
354
|
isActive={true}
|
|
358
|
-
|
|
355
|
+
operationState={createOperatingState(100)}
|
|
359
356
|
containerSize={400}
|
|
360
357
|
>
|
|
361
358
|
Content
|
|
@@ -370,7 +367,7 @@ describe("SwipeStackContent", () => {
|
|
|
370
367
|
depth={1}
|
|
371
368
|
navigationDepth={1}
|
|
372
369
|
isActive={true}
|
|
373
|
-
|
|
370
|
+
operationState={createOperatingState(250)}
|
|
374
371
|
containerSize={400}
|
|
375
372
|
>
|
|
376
373
|
Content
|
|
@@ -386,7 +383,7 @@ describe("SwipeStackContent", () => {
|
|
|
386
383
|
depth={0}
|
|
387
384
|
navigationDepth={1}
|
|
388
385
|
isActive={false}
|
|
389
|
-
|
|
386
|
+
operationState={IDLE_STATE}
|
|
390
387
|
containerSize={400}
|
|
391
388
|
>
|
|
392
389
|
Content
|
|
@@ -406,7 +403,7 @@ describe("SwipeStackContent", () => {
|
|
|
406
403
|
depth={0}
|
|
407
404
|
navigationDepth={1}
|
|
408
405
|
isActive={false}
|
|
409
|
-
|
|
406
|
+
operationState={createOperatingState(100)}
|
|
410
407
|
containerSize={400}
|
|
411
408
|
>
|
|
412
409
|
Content
|
|
@@ -423,7 +420,7 @@ describe("SwipeStackContent", () => {
|
|
|
423
420
|
depth={0}
|
|
424
421
|
navigationDepth={1}
|
|
425
422
|
isActive={false}
|
|
426
|
-
|
|
423
|
+
operationState={createOperatingState(200)}
|
|
427
424
|
containerSize={400}
|
|
428
425
|
>
|
|
429
426
|
Content
|
|
@@ -438,7 +435,7 @@ describe("SwipeStackContent", () => {
|
|
|
438
435
|
depth={0}
|
|
439
436
|
navigationDepth={1}
|
|
440
437
|
isActive={false}
|
|
441
|
-
|
|
438
|
+
operationState={createOperatingState(400)}
|
|
442
439
|
containerSize={400}
|
|
443
440
|
>
|
|
444
441
|
Content
|
|
@@ -454,7 +451,7 @@ describe("SwipeStackContent", () => {
|
|
|
454
451
|
depth={1}
|
|
455
452
|
navigationDepth={1}
|
|
456
453
|
isActive={true}
|
|
457
|
-
|
|
454
|
+
operationState={IDLE_STATE}
|
|
458
455
|
containerSize={400}
|
|
459
456
|
>
|
|
460
457
|
Content
|
|
@@ -470,7 +467,7 @@ describe("SwipeStackContent", () => {
|
|
|
470
467
|
depth={1}
|
|
471
468
|
navigationDepth={1}
|
|
472
469
|
isActive={true}
|
|
473
|
-
|
|
470
|
+
operationState={createOperatingState(-100)}
|
|
474
471
|
containerSize={400}
|
|
475
472
|
>
|
|
476
473
|
Content
|
|
@@ -488,7 +485,7 @@ describe("SwipeStackContent", () => {
|
|
|
488
485
|
depth={1}
|
|
489
486
|
navigationDepth={1}
|
|
490
487
|
isActive={true}
|
|
491
|
-
|
|
488
|
+
operationState={IDLE_STATE}
|
|
492
489
|
containerSize={400}
|
|
493
490
|
>
|
|
494
491
|
Content
|
|
@@ -504,7 +501,7 @@ describe("SwipeStackContent", () => {
|
|
|
504
501
|
depth={1}
|
|
505
502
|
navigationDepth={1}
|
|
506
503
|
isActive={true}
|
|
507
|
-
|
|
504
|
+
operationState={createOperatingState(150)}
|
|
508
505
|
containerSize={400}
|
|
509
506
|
>
|
|
510
507
|
Content
|
|
@@ -519,7 +516,7 @@ describe("SwipeStackContent", () => {
|
|
|
519
516
|
depth={1}
|
|
520
517
|
navigationDepth={1}
|
|
521
518
|
isActive={true}
|
|
522
|
-
|
|
519
|
+
operationState={IDLE_STATE}
|
|
523
520
|
containerSize={400}
|
|
524
521
|
>
|
|
525
522
|
Content
|
|
@@ -543,7 +540,7 @@ describe("SwipeStackContent", () => {
|
|
|
543
540
|
depth={0}
|
|
544
541
|
navigationDepth={1}
|
|
545
542
|
isActive={false}
|
|
546
|
-
|
|
543
|
+
operationState={IDLE_STATE}
|
|
547
544
|
containerSize={400}
|
|
548
545
|
>
|
|
549
546
|
Content
|
|
@@ -559,7 +556,7 @@ describe("SwipeStackContent", () => {
|
|
|
559
556
|
depth={0}
|
|
560
557
|
navigationDepth={1}
|
|
561
558
|
isActive={false}
|
|
562
|
-
|
|
559
|
+
operationState={createOperatingState(200)}
|
|
563
560
|
containerSize={400}
|
|
564
561
|
>
|
|
565
562
|
Content
|
|
@@ -575,7 +572,7 @@ describe("SwipeStackContent", () => {
|
|
|
575
572
|
depth={0}
|
|
576
573
|
navigationDepth={1}
|
|
577
574
|
isActive={false}
|
|
578
|
-
|
|
575
|
+
operationState={IDLE_STATE}
|
|
579
576
|
containerSize={400}
|
|
580
577
|
>
|
|
581
578
|
Content
|
|
@@ -601,7 +598,7 @@ describe("SwipeStackContent", () => {
|
|
|
601
598
|
depth={0}
|
|
602
599
|
navigationDepth={1}
|
|
603
600
|
isActive={false}
|
|
604
|
-
|
|
601
|
+
operationState={IDLE_STATE}
|
|
605
602
|
containerSize={400}
|
|
606
603
|
>
|
|
607
604
|
Content
|
|
@@ -619,7 +616,7 @@ describe("SwipeStackContent", () => {
|
|
|
619
616
|
depth={0}
|
|
620
617
|
navigationDepth={0}
|
|
621
618
|
isActive={true}
|
|
622
|
-
|
|
619
|
+
operationState={IDLE_STATE}
|
|
623
620
|
containerSize={400}
|
|
624
621
|
>
|
|
625
622
|
Content
|
|
@@ -647,7 +644,7 @@ describe("SwipeStackContent", () => {
|
|
|
647
644
|
depth={1}
|
|
648
645
|
navigationDepth={1}
|
|
649
646
|
isActive={true}
|
|
650
|
-
|
|
647
|
+
operationState={IDLE_STATE}
|
|
651
648
|
containerSize={400}
|
|
652
649
|
>
|
|
653
650
|
Content
|
|
@@ -665,7 +662,7 @@ describe("SwipeStackContent", () => {
|
|
|
665
662
|
depth={1}
|
|
666
663
|
navigationDepth={0}
|
|
667
664
|
isActive={false}
|
|
668
|
-
|
|
665
|
+
operationState={IDLE_STATE}
|
|
669
666
|
containerSize={400}
|
|
670
667
|
>
|
|
671
668
|
Content
|
|
@@ -697,7 +694,7 @@ describe("SwipeStackContent", () => {
|
|
|
697
694
|
depth={1}
|
|
698
695
|
navigationDepth={1}
|
|
699
696
|
isActive={true}
|
|
700
|
-
|
|
697
|
+
operationState={IDLE_STATE}
|
|
701
698
|
containerSize={400}
|
|
702
699
|
animateOnMount={true}
|
|
703
700
|
>
|
|
@@ -729,7 +726,7 @@ describe("SwipeStackContent", () => {
|
|
|
729
726
|
depth={1}
|
|
730
727
|
navigationDepth={0}
|
|
731
728
|
isActive={false}
|
|
732
|
-
|
|
729
|
+
operationState={IDLE_STATE}
|
|
733
730
|
containerSize={400}
|
|
734
731
|
>
|
|
735
732
|
Content
|
|
@@ -747,7 +744,7 @@ describe("SwipeStackContent", () => {
|
|
|
747
744
|
depth={1}
|
|
748
745
|
navigationDepth={1}
|
|
749
746
|
isActive={true}
|
|
750
|
-
|
|
747
|
+
operationState={IDLE_STATE}
|
|
751
748
|
containerSize={400}
|
|
752
749
|
>
|
|
753
750
|
Content
|
|
@@ -775,7 +772,7 @@ describe("SwipeStackContent", () => {
|
|
|
775
772
|
depth={0}
|
|
776
773
|
navigationDepth={0}
|
|
777
774
|
isActive={true}
|
|
778
|
-
|
|
775
|
+
operationState={IDLE_STATE}
|
|
779
776
|
containerSize={400}
|
|
780
777
|
>
|
|
781
778
|
Content
|
|
@@ -793,7 +790,7 @@ describe("SwipeStackContent", () => {
|
|
|
793
790
|
depth={0}
|
|
794
791
|
navigationDepth={1}
|
|
795
792
|
isActive={false}
|
|
796
|
-
|
|
793
|
+
operationState={IDLE_STATE}
|
|
797
794
|
containerSize={400}
|
|
798
795
|
>
|
|
799
796
|
Content
|
|
@@ -828,7 +825,7 @@ describe("SwipeStackContent", () => {
|
|
|
828
825
|
depth={1}
|
|
829
826
|
navigationDepth={1}
|
|
830
827
|
isActive={true}
|
|
831
|
-
|
|
828
|
+
operationState={IDLE_STATE}
|
|
832
829
|
containerSize={400}
|
|
833
830
|
animateOnMount={true}
|
|
834
831
|
>
|
|
@@ -857,7 +854,7 @@ describe("SwipeStackContent", () => {
|
|
|
857
854
|
depth={1}
|
|
858
855
|
navigationDepth={0}
|
|
859
856
|
isActive={false}
|
|
860
|
-
|
|
857
|
+
operationState={IDLE_STATE}
|
|
861
858
|
containerSize={400}
|
|
862
859
|
animateOnMount={true}
|
|
863
860
|
>
|
|
@@ -889,7 +886,7 @@ describe("SwipeStackContent", () => {
|
|
|
889
886
|
depth={0}
|
|
890
887
|
navigationDepth={0}
|
|
891
888
|
isActive={true}
|
|
892
|
-
|
|
889
|
+
operationState={IDLE_STATE}
|
|
893
890
|
containerSize={400}
|
|
894
891
|
>
|
|
895
892
|
Content
|
|
@@ -906,7 +903,7 @@ describe("SwipeStackContent", () => {
|
|
|
906
903
|
depth={0}
|
|
907
904
|
navigationDepth={1}
|
|
908
905
|
isActive={false}
|
|
909
|
-
|
|
906
|
+
operationState={IDLE_STATE}
|
|
910
907
|
containerSize={400}
|
|
911
908
|
>
|
|
912
909
|
Content
|
|
@@ -931,7 +928,7 @@ describe("SwipeStackContent", () => {
|
|
|
931
928
|
depth={0}
|
|
932
929
|
navigationDepth={0}
|
|
933
930
|
isActive={true}
|
|
934
|
-
|
|
931
|
+
operationState={IDLE_STATE}
|
|
935
932
|
containerSize={400}
|
|
936
933
|
>
|
|
937
934
|
Content
|
|
@@ -959,7 +956,7 @@ describe("SwipeStackContent", () => {
|
|
|
959
956
|
depth={1}
|
|
960
957
|
navigationDepth={1}
|
|
961
958
|
isActive={true}
|
|
962
|
-
|
|
959
|
+
operationState={IDLE_STATE}
|
|
963
960
|
containerSize={400}
|
|
964
961
|
>
|
|
965
962
|
Content
|
|
@@ -977,7 +974,7 @@ describe("SwipeStackContent", () => {
|
|
|
977
974
|
depth={0}
|
|
978
975
|
navigationDepth={0}
|
|
979
976
|
isActive={true}
|
|
980
|
-
|
|
977
|
+
operationState={IDLE_STATE}
|
|
981
978
|
containerSize={400}
|
|
982
979
|
>
|
|
983
980
|
Content
|
|
@@ -995,7 +992,7 @@ describe("SwipeStackContent", () => {
|
|
|
995
992
|
depth={0}
|
|
996
993
|
navigationDepth={1}
|
|
997
994
|
isActive={false}
|
|
998
|
-
|
|
995
|
+
operationState={IDLE_STATE}
|
|
999
996
|
containerSize={400}
|
|
1000
997
|
>
|
|
1001
998
|
Content
|
|
@@ -1013,7 +1010,7 @@ describe("SwipeStackContent", () => {
|
|
|
1013
1010
|
depth={1}
|
|
1014
1011
|
navigationDepth={1}
|
|
1015
1012
|
isActive={true}
|
|
1016
|
-
|
|
1013
|
+
operationState={IDLE_STATE}
|
|
1017
1014
|
containerSize={400}
|
|
1018
1015
|
showShadow={false}
|
|
1019
1016
|
>
|
|
@@ -1034,7 +1031,7 @@ describe("SwipeStackContent", () => {
|
|
|
1034
1031
|
depth={0}
|
|
1035
1032
|
navigationDepth={1}
|
|
1036
1033
|
isActive={false}
|
|
1037
|
-
|
|
1034
|
+
operationState={IDLE_STATE}
|
|
1038
1035
|
containerSize={400}
|
|
1039
1036
|
displayMode="stack"
|
|
1040
1037
|
>
|
|
@@ -1054,7 +1051,7 @@ describe("SwipeStackContent", () => {
|
|
|
1054
1051
|
depth={1}
|
|
1055
1052
|
navigationDepth={1}
|
|
1056
1053
|
isActive={true}
|
|
1057
|
-
|
|
1054
|
+
operationState={IDLE_STATE}
|
|
1058
1055
|
containerSize={400}
|
|
1059
1056
|
displayMode="stack"
|
|
1060
1057
|
>
|
|
@@ -1074,7 +1071,7 @@ describe("SwipeStackContent", () => {
|
|
|
1074
1071
|
depth={0}
|
|
1075
1072
|
navigationDepth={1}
|
|
1076
1073
|
isActive={false}
|
|
1077
|
-
|
|
1074
|
+
operationState={IDLE_STATE}
|
|
1078
1075
|
containerSize={400}
|
|
1079
1076
|
displayMode="overlay"
|
|
1080
1077
|
>
|
|
@@ -1096,7 +1093,7 @@ describe("SwipeStackContent", () => {
|
|
|
1096
1093
|
depth={0}
|
|
1097
1094
|
navigationDepth={1}
|
|
1098
1095
|
isActive={false}
|
|
1099
|
-
|
|
1096
|
+
operationState={IDLE_STATE}
|
|
1100
1097
|
containerSize={400}
|
|
1101
1098
|
>
|
|
1102
1099
|
Content
|
|
@@ -1114,7 +1111,7 @@ describe("SwipeStackContent", () => {
|
|
|
1114
1111
|
depth={1}
|
|
1115
1112
|
navigationDepth={1}
|
|
1116
1113
|
isActive={true}
|
|
1117
|
-
|
|
1114
|
+
operationState={IDLE_STATE}
|
|
1118
1115
|
containerSize={400}
|
|
1119
1116
|
>
|
|
1120
1117
|
Content
|
|
@@ -1132,7 +1129,7 @@ describe("SwipeStackContent", () => {
|
|
|
1132
1129
|
depth={0}
|
|
1133
1130
|
navigationDepth={1}
|
|
1134
1131
|
isActive={false}
|
|
1135
|
-
|
|
1132
|
+
operationState={IDLE_STATE}
|
|
1136
1133
|
containerSize={400}
|
|
1137
1134
|
>
|
|
1138
1135
|
Content
|
|
@@ -1140,9 +1137,8 @@ describe("SwipeStackContent", () => {
|
|
|
1140
1137
|
);
|
|
1141
1138
|
|
|
1142
1139
|
// At rest, should have dimming
|
|
1143
|
-
|
|
1144
|
-
expect(
|
|
1145
|
-
const initialOpacity = overlay.style.backgroundColor;
|
|
1140
|
+
const initialOverlay = container.querySelector("[data-dimming-overlay]") as HTMLElement;
|
|
1141
|
+
expect(initialOverlay).toBeInTheDocument();
|
|
1146
1142
|
|
|
1147
1143
|
// During swipe at 100% progress, dimming should be gone
|
|
1148
1144
|
rerender(
|
|
@@ -1151,16 +1147,16 @@ describe("SwipeStackContent", () => {
|
|
|
1151
1147
|
depth={0}
|
|
1152
1148
|
navigationDepth={1}
|
|
1153
1149
|
isActive={false}
|
|
1154
|
-
|
|
1150
|
+
operationState={createOperatingState(400)}
|
|
1155
1151
|
containerSize={400}
|
|
1156
1152
|
>
|
|
1157
1153
|
Content
|
|
1158
1154
|
</SwipeStackContent>,
|
|
1159
1155
|
);
|
|
1160
1156
|
|
|
1161
|
-
|
|
1157
|
+
const overlayAfter = container.querySelector("[data-dimming-overlay]") as HTMLElement;
|
|
1162
1158
|
// At 100% swipe, opacity should be 0 (no overlay)
|
|
1163
|
-
expect(
|
|
1159
|
+
expect(overlayAfter).not.toBeInTheDocument();
|
|
1164
1160
|
});
|
|
1165
1161
|
|
|
1166
1162
|
it("can disable dimming with showDimming=false", () => {
|
|
@@ -1170,7 +1166,7 @@ describe("SwipeStackContent", () => {
|
|
|
1170
1166
|
depth={0}
|
|
1171
1167
|
navigationDepth={1}
|
|
1172
1168
|
isActive={false}
|
|
1173
|
-
|
|
1169
|
+
operationState={IDLE_STATE}
|
|
1174
1170
|
containerSize={400}
|
|
1175
1171
|
showDimming={false}
|
|
1176
1172
|
>
|
|
@@ -1183,6 +1179,297 @@ describe("SwipeStackContent", () => {
|
|
|
1183
1179
|
});
|
|
1184
1180
|
});
|
|
1185
1181
|
|
|
1182
|
+
describe("navigation during animation", () => {
|
|
1183
|
+
it("handles push during back animation", () => {
|
|
1184
|
+
// Scenario: Panel is animating back (going from active to hidden)
|
|
1185
|
+
// User quickly clicks to push forward again
|
|
1186
|
+
const { container, rerender } = render(
|
|
1187
|
+
<SwipeStackContent
|
|
1188
|
+
id="panel1"
|
|
1189
|
+
depth={1}
|
|
1190
|
+
navigationDepth={1}
|
|
1191
|
+
isActive={true}
|
|
1192
|
+
operationState={IDLE_STATE}
|
|
1193
|
+
containerSize={400}
|
|
1194
|
+
>
|
|
1195
|
+
Content
|
|
1196
|
+
</SwipeStackContent>,
|
|
1197
|
+
);
|
|
1198
|
+
|
|
1199
|
+
const element = container.firstChild as HTMLElement;
|
|
1200
|
+
expect(element.style.transform).toBe("translateX(0px)");
|
|
1201
|
+
|
|
1202
|
+
// Step 1: Go back - panel becomes hidden, starts animating to off-screen
|
|
1203
|
+
rerender(
|
|
1204
|
+
<SwipeStackContent
|
|
1205
|
+
id="panel1"
|
|
1206
|
+
depth={1}
|
|
1207
|
+
navigationDepth={0}
|
|
1208
|
+
isActive={false}
|
|
1209
|
+
operationState={IDLE_STATE}
|
|
1210
|
+
containerSize={400}
|
|
1211
|
+
>
|
|
1212
|
+
Content
|
|
1213
|
+
</SwipeStackContent>,
|
|
1214
|
+
);
|
|
1215
|
+
|
|
1216
|
+
// Start animation but don't complete it
|
|
1217
|
+
act(() => {
|
|
1218
|
+
flushRAF(0);
|
|
1219
|
+
flushRAF(100); // Partial animation
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
// Panel should be somewhere between 0 and 400
|
|
1223
|
+
const midAnimationTransform = element.style.transform;
|
|
1224
|
+
expect(midAnimationTransform).not.toBe("translateX(0px)");
|
|
1225
|
+
expect(midAnimationTransform).not.toBe("translateX(400px)");
|
|
1226
|
+
|
|
1227
|
+
// Step 2: Push again - panel becomes active again DURING animation
|
|
1228
|
+
rerender(
|
|
1229
|
+
<SwipeStackContent
|
|
1230
|
+
id="panel1"
|
|
1231
|
+
depth={1}
|
|
1232
|
+
navigationDepth={1}
|
|
1233
|
+
isActive={true}
|
|
1234
|
+
operationState={IDLE_STATE}
|
|
1235
|
+
containerSize={400}
|
|
1236
|
+
>
|
|
1237
|
+
Content
|
|
1238
|
+
</SwipeStackContent>,
|
|
1239
|
+
);
|
|
1240
|
+
|
|
1241
|
+
// Complete all pending animations
|
|
1242
|
+
act(() => {
|
|
1243
|
+
flushRAF(0);
|
|
1244
|
+
flushRAF(400);
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
// Panel should end up at center (0), visible
|
|
1248
|
+
expect(element.style.transform).toBe("translateX(0px)");
|
|
1249
|
+
expect(element.style.visibility).toBe("visible");
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
it("handles back during push animation", () => {
|
|
1253
|
+
// Scenario: New panel is animating in from off-screen
|
|
1254
|
+
// User quickly clicks back before animation completes
|
|
1255
|
+
const { container, rerender } = render(
|
|
1256
|
+
<SwipeStackContent
|
|
1257
|
+
id="panel1"
|
|
1258
|
+
depth={1}
|
|
1259
|
+
navigationDepth={1}
|
|
1260
|
+
isActive={true}
|
|
1261
|
+
operationState={IDLE_STATE}
|
|
1262
|
+
containerSize={400}
|
|
1263
|
+
animateOnMount={true}
|
|
1264
|
+
>
|
|
1265
|
+
Content
|
|
1266
|
+
</SwipeStackContent>,
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
const element = container.firstChild as HTMLElement;
|
|
1270
|
+
|
|
1271
|
+
// Panel starts off-screen
|
|
1272
|
+
expect(element.style.transform).toBe("translateX(400px)");
|
|
1273
|
+
|
|
1274
|
+
// Start animation but don't complete it
|
|
1275
|
+
act(() => {
|
|
1276
|
+
flushRAF(0);
|
|
1277
|
+
flushRAF(100); // Partial animation
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
// Panel should be somewhere between 400 and 0
|
|
1281
|
+
const midAnimationTransform = element.style.transform;
|
|
1282
|
+
expect(midAnimationTransform).not.toBe("translateX(400px)");
|
|
1283
|
+
expect(midAnimationTransform).not.toBe("translateX(0px)");
|
|
1284
|
+
|
|
1285
|
+
// Go back during animation
|
|
1286
|
+
rerender(
|
|
1287
|
+
<SwipeStackContent
|
|
1288
|
+
id="panel1"
|
|
1289
|
+
depth={1}
|
|
1290
|
+
navigationDepth={0}
|
|
1291
|
+
isActive={false}
|
|
1292
|
+
operationState={IDLE_STATE}
|
|
1293
|
+
containerSize={400}
|
|
1294
|
+
animateOnMount={true}
|
|
1295
|
+
>
|
|
1296
|
+
Content
|
|
1297
|
+
</SwipeStackContent>,
|
|
1298
|
+
);
|
|
1299
|
+
|
|
1300
|
+
// Complete all pending animations
|
|
1301
|
+
act(() => {
|
|
1302
|
+
flushRAF(0);
|
|
1303
|
+
flushRAF(400);
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
// Panel should end up off-screen (400), hidden
|
|
1307
|
+
expect(element.style.transform).toBe("translateX(400px)");
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
it("handles rapid back-push-back sequence during animations", () => {
|
|
1311
|
+
const { container, rerender } = render(
|
|
1312
|
+
<SwipeStackContent
|
|
1313
|
+
id="panel1"
|
|
1314
|
+
depth={1}
|
|
1315
|
+
navigationDepth={1}
|
|
1316
|
+
isActive={true}
|
|
1317
|
+
operationState={IDLE_STATE}
|
|
1318
|
+
containerSize={400}
|
|
1319
|
+
>
|
|
1320
|
+
Content
|
|
1321
|
+
</SwipeStackContent>,
|
|
1322
|
+
);
|
|
1323
|
+
|
|
1324
|
+
const element = container.firstChild as HTMLElement;
|
|
1325
|
+
expect(element.style.transform).toBe("translateX(0px)");
|
|
1326
|
+
|
|
1327
|
+
// Back
|
|
1328
|
+
rerender(
|
|
1329
|
+
<SwipeStackContent
|
|
1330
|
+
id="panel1"
|
|
1331
|
+
depth={1}
|
|
1332
|
+
navigationDepth={0}
|
|
1333
|
+
isActive={false}
|
|
1334
|
+
operationState={IDLE_STATE}
|
|
1335
|
+
containerSize={400}
|
|
1336
|
+
>
|
|
1337
|
+
Content
|
|
1338
|
+
</SwipeStackContent>,
|
|
1339
|
+
);
|
|
1340
|
+
|
|
1341
|
+
act(() => {
|
|
1342
|
+
flushRAF(0);
|
|
1343
|
+
flushRAF(50);
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// Push (before back animation completes)
|
|
1347
|
+
rerender(
|
|
1348
|
+
<SwipeStackContent
|
|
1349
|
+
id="panel1"
|
|
1350
|
+
depth={1}
|
|
1351
|
+
navigationDepth={1}
|
|
1352
|
+
isActive={true}
|
|
1353
|
+
operationState={IDLE_STATE}
|
|
1354
|
+
containerSize={400}
|
|
1355
|
+
>
|
|
1356
|
+
Content
|
|
1357
|
+
</SwipeStackContent>,
|
|
1358
|
+
);
|
|
1359
|
+
|
|
1360
|
+
act(() => {
|
|
1361
|
+
flushRAF(0);
|
|
1362
|
+
flushRAF(50);
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
// Back again (before push animation completes)
|
|
1366
|
+
rerender(
|
|
1367
|
+
<SwipeStackContent
|
|
1368
|
+
id="panel1"
|
|
1369
|
+
depth={1}
|
|
1370
|
+
navigationDepth={0}
|
|
1371
|
+
isActive={false}
|
|
1372
|
+
operationState={IDLE_STATE}
|
|
1373
|
+
containerSize={400}
|
|
1374
|
+
>
|
|
1375
|
+
Content
|
|
1376
|
+
</SwipeStackContent>,
|
|
1377
|
+
);
|
|
1378
|
+
|
|
1379
|
+
// Complete all animations
|
|
1380
|
+
act(() => {
|
|
1381
|
+
flushRAF(0);
|
|
1382
|
+
flushRAF(400);
|
|
1383
|
+
});
|
|
1384
|
+
|
|
1385
|
+
// Final state: should be off-screen (hidden)
|
|
1386
|
+
expect(element.style.transform).toBe("translateX(400px)");
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
it("panel remains visible and usable after rapid navigation", () => {
|
|
1390
|
+
// This is the bug scenario: after rapid back-and-forth, panel becomes permanently hidden
|
|
1391
|
+
const { container, rerender } = render(
|
|
1392
|
+
<SwipeStackContent
|
|
1393
|
+
id="panel1"
|
|
1394
|
+
depth={1}
|
|
1395
|
+
navigationDepth={1}
|
|
1396
|
+
isActive={true}
|
|
1397
|
+
operationState={IDLE_STATE}
|
|
1398
|
+
containerSize={400}
|
|
1399
|
+
>
|
|
1400
|
+
Content
|
|
1401
|
+
</SwipeStackContent>,
|
|
1402
|
+
);
|
|
1403
|
+
|
|
1404
|
+
const element = container.firstChild as HTMLElement;
|
|
1405
|
+
|
|
1406
|
+
// Rapid sequence without waiting for animations
|
|
1407
|
+
for (let i = 0; i < 5; i++) {
|
|
1408
|
+
// Go back
|
|
1409
|
+
rerender(
|
|
1410
|
+
<SwipeStackContent
|
|
1411
|
+
id="panel1"
|
|
1412
|
+
depth={1}
|
|
1413
|
+
navigationDepth={0}
|
|
1414
|
+
isActive={false}
|
|
1415
|
+
operationState={IDLE_STATE}
|
|
1416
|
+
containerSize={400}
|
|
1417
|
+
>
|
|
1418
|
+
Content
|
|
1419
|
+
</SwipeStackContent>,
|
|
1420
|
+
);
|
|
1421
|
+
|
|
1422
|
+
act(() => {
|
|
1423
|
+
flushRAF(0);
|
|
1424
|
+
flushRAF(30);
|
|
1425
|
+
});
|
|
1426
|
+
|
|
1427
|
+
// Push forward
|
|
1428
|
+
rerender(
|
|
1429
|
+
<SwipeStackContent
|
|
1430
|
+
id="panel1"
|
|
1431
|
+
depth={1}
|
|
1432
|
+
navigationDepth={1}
|
|
1433
|
+
isActive={true}
|
|
1434
|
+
operationState={IDLE_STATE}
|
|
1435
|
+
containerSize={400}
|
|
1436
|
+
>
|
|
1437
|
+
Content
|
|
1438
|
+
</SwipeStackContent>,
|
|
1439
|
+
);
|
|
1440
|
+
|
|
1441
|
+
act(() => {
|
|
1442
|
+
flushRAF(0);
|
|
1443
|
+
flushRAF(30);
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// Final state: panel should be active
|
|
1448
|
+
rerender(
|
|
1449
|
+
<SwipeStackContent
|
|
1450
|
+
id="panel1"
|
|
1451
|
+
depth={1}
|
|
1452
|
+
navigationDepth={1}
|
|
1453
|
+
isActive={true}
|
|
1454
|
+
operationState={IDLE_STATE}
|
|
1455
|
+
containerSize={400}
|
|
1456
|
+
>
|
|
1457
|
+
Content
|
|
1458
|
+
</SwipeStackContent>,
|
|
1459
|
+
);
|
|
1460
|
+
|
|
1461
|
+
// Complete all animations
|
|
1462
|
+
act(() => {
|
|
1463
|
+
flushRAF(0);
|
|
1464
|
+
flushRAF(400);
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// Panel should be visible at center
|
|
1468
|
+
expect(element.style.transform).toBe("translateX(0px)");
|
|
1469
|
+
expect(element.style.visibility).toBe("visible");
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1186
1473
|
describe("swipe commit (navigation changes)", () => {
|
|
1187
1474
|
it("active panel moves off-screen when navigation depth decreases", () => {
|
|
1188
1475
|
const { container, rerender } = render(
|
|
@@ -1191,7 +1478,7 @@ describe("SwipeStackContent", () => {
|
|
|
1191
1478
|
depth={1}
|
|
1192
1479
|
navigationDepth={1}
|
|
1193
1480
|
isActive={true}
|
|
1194
|
-
|
|
1481
|
+
operationState={IDLE_STATE}
|
|
1195
1482
|
containerSize={400}
|
|
1196
1483
|
>
|
|
1197
1484
|
Content
|
|
@@ -1209,7 +1496,7 @@ describe("SwipeStackContent", () => {
|
|
|
1209
1496
|
depth={1}
|
|
1210
1497
|
navigationDepth={0}
|
|
1211
1498
|
isActive={false}
|
|
1212
|
-
|
|
1499
|
+
operationState={IDLE_STATE}
|
|
1213
1500
|
containerSize={400}
|
|
1214
1501
|
>
|
|
1215
1502
|
Content
|
|
@@ -1236,7 +1523,7 @@ describe("SwipeStackContent", () => {
|
|
|
1236
1523
|
depth={0}
|
|
1237
1524
|
navigationDepth={1}
|
|
1238
1525
|
isActive={false}
|
|
1239
|
-
|
|
1526
|
+
operationState={IDLE_STATE}
|
|
1240
1527
|
containerSize={400}
|
|
1241
1528
|
>
|
|
1242
1529
|
Content
|
|
@@ -1254,7 +1541,7 @@ describe("SwipeStackContent", () => {
|
|
|
1254
1541
|
depth={0}
|
|
1255
1542
|
navigationDepth={0}
|
|
1256
1543
|
isActive={true}
|
|
1257
|
-
|
|
1544
|
+
operationState={IDLE_STATE}
|
|
1258
1545
|
containerSize={400}
|
|
1259
1546
|
>
|
|
1260
1547
|
Content
|