@seed-design/stackflow 1.1.20 → 1.1.21
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/lib/_virtual/_rolldown/runtime.cjs +34 -0
- package/lib/_virtual/_rolldown/runtime.js +14 -0
- package/lib/components/AppBar/AppBar.cjs +86 -102
- package/lib/components/AppBar/AppBar.js +84 -98
- package/lib/components/AppBar/AppBar.namespace.cjs +20 -16
- package/lib/components/AppBar/AppBar.namespace.js +15 -1
- package/lib/components/AppBar/index.cjs +17 -18
- package/lib/components/AppBar/index.js +3 -3
- package/lib/components/AppScreen/AppScreen.cjs +46 -61
- package/lib/components/AppScreen/AppScreen.js +45 -57
- package/lib/components/AppScreen/AppScreen.namespace.cjs +17 -13
- package/lib/components/AppScreen/AppScreen.namespace.js +12 -1
- package/lib/components/AppScreen/index.cjs +14 -15
- package/lib/components/AppScreen/index.js +3 -3
- package/lib/components/index.cjs +30 -26
- package/lib/components/index.js +5 -6
- package/lib/hooks/index.cjs +3 -9
- package/lib/hooks/index.js +2 -1
- package/lib/hooks/useActivityZIndexBase.cjs +12 -11
- package/lib/hooks/useActivityZIndexBase.js +11 -7
- package/lib/index.cjs +41 -32
- package/lib/index.js +8 -10
- package/lib/plugin.cjs +16 -16
- package/lib/plugin.js +14 -12
- package/lib/primitive/AppBar/AppBar.cjs +41 -33
- package/lib/primitive/AppBar/AppBar.js +40 -29
- package/lib/primitive/AppBar/AppBar.namespace.cjs +16 -12
- package/lib/primitive/AppBar/AppBar.namespace.js +11 -1
- package/lib/primitive/AppBar/anatomy.cjs +18 -0
- package/lib/primitive/AppBar/anatomy.d.ts +15 -0
- package/lib/primitive/AppBar/anatomy.js +18 -0
- package/lib/primitive/AppBar/index.cjs +13 -14
- package/lib/primitive/AppBar/index.js +3 -3
- package/lib/primitive/AppBar/useAppBar.cjs +29 -36
- package/lib/primitive/AppBar/useAppBar.js +28 -32
- package/lib/primitive/AppBar/useAppBarContext.cjs +11 -18
- package/lib/primitive/AppBar/useAppBarContext.js +10 -14
- package/lib/primitive/AppScreen/AppScreen.cjs +49 -52
- package/lib/primitive/AppScreen/AppScreen.js +48 -48
- package/lib/primitive/AppScreen/AppScreen.namespace.cjs +16 -12
- package/lib/primitive/AppScreen/AppScreen.namespace.js +11 -1
- package/lib/primitive/AppScreen/anatomy.cjs +17 -0
- package/lib/primitive/AppScreen/anatomy.d.ts +14 -0
- package/lib/primitive/AppScreen/anatomy.js +17 -0
- package/lib/primitive/AppScreen/index.cjs +15 -16
- package/lib/primitive/AppScreen/index.js +4 -4
- package/lib/primitive/AppScreen/useAppScreen.cjs +60 -63
- package/lib/primitive/AppScreen/useAppScreen.js +59 -59
- package/lib/primitive/AppScreen/useAppScreenContext.cjs +11 -18
- package/lib/primitive/AppScreen/useAppScreenContext.js +10 -14
- package/lib/primitive/GlobalInteraction/GlobalInteraction.cjs +21 -26
- package/lib/primitive/GlobalInteraction/GlobalInteraction.js +20 -22
- package/lib/primitive/GlobalInteraction/animation.cjs +303 -0
- package/lib/primitive/GlobalInteraction/animation.d.ts +16 -0
- package/lib/primitive/GlobalInteraction/animation.js +299 -0
- package/lib/primitive/GlobalInteraction/constants.cjs +9 -0
- package/lib/primitive/GlobalInteraction/constants.d.ts +19 -0
- package/lib/primitive/GlobalInteraction/constants.js +8 -0
- package/lib/primitive/GlobalInteraction/dom.cjs +147 -0
- package/lib/primitive/GlobalInteraction/dom.d.ts +44 -0
- package/lib/primitive/GlobalInteraction/dom.js +140 -0
- package/lib/primitive/GlobalInteraction/index.cjs +5 -11
- package/lib/primitive/GlobalInteraction/index.js +3 -2
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.cjs +220 -133
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.d.ts +10 -26
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +219 -129
- package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.cjs +11 -18
- package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.js +10 -14
- package/lib/primitive/GlobalInteraction/useSwipeBack.cjs +71 -55
- package/lib/primitive/GlobalInteraction/useSwipeBack.d.ts +19 -2
- package/lib/primitive/GlobalInteraction/useSwipeBack.js +70 -51
- package/lib/primitive/index.cjs +55 -27
- package/lib/primitive/index.js +26 -9
- package/lib/primitive/private/useElementOffset.cjs +29 -51
- package/lib/primitive/private/useElementOffset.js +27 -28
- package/lib/primitive/private/useTopActivity.cjs +22 -31
- package/lib/primitive/private/useTopActivity.js +21 -27
- package/lib/utils/createStyleContext.cjs +91 -74
- package/lib/utils/createStyleContext.js +89 -70
- package/lib/utils/styled.cjs +13 -20
- package/lib/utils/styled.js +12 -16
- package/package.json +4 -4
- package/src/components/AppBar/AppBar.tsx +9 -3
- package/src/primitive/AppBar/AppBar.tsx +4 -1
- package/src/primitive/AppBar/anatomy.ts +16 -0
- package/src/primitive/AppBar/useAppBar.tsx +2 -1
- package/src/primitive/AppScreen/anatomy.ts +15 -0
- package/src/primitive/AppScreen/useAppScreen.tsx +5 -4
- package/src/primitive/GlobalInteraction/animation.ts +447 -0
- package/src/primitive/GlobalInteraction/constants.ts +24 -0
- package/src/primitive/GlobalInteraction/dom.ts +211 -0
- package/src/primitive/GlobalInteraction/useGlobalInteraction.ts +302 -129
- package/src/primitive/GlobalInteraction/useSwipeBack.ts +64 -26
|
@@ -1,136 +1,223 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_useTopActivity = require("../private/useTopActivity.cjs");
|
|
4
|
+
const require_dom = require("./dom.cjs");
|
|
5
|
+
const require_animation = require("./animation.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
//#region src/primitive/GlobalInteraction/useGlobalInteraction.ts
|
|
8
|
+
var IDLE_CONTEXT = Object.freeze({
|
|
9
|
+
x0: 0,
|
|
10
|
+
t0: 0,
|
|
11
|
+
displacement: 0,
|
|
12
|
+
displacementRatio: 0,
|
|
13
|
+
velocity: 0
|
|
14
|
+
});
|
|
15
|
+
var DEFAULT_DISPLACEMENT_RATIO_THRESHOLD = .4;
|
|
16
|
+
var DEFAULT_VELOCITY_THRESHOLD = 1;
|
|
10
17
|
function useGlobalInteraction() {
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
18
|
+
const swipeBackStateRef = (0, react.useRef)("idle");
|
|
19
|
+
const swipeBackContextRef = (0, react.useRef)({ ...IDLE_CONTEXT });
|
|
20
|
+
const stackRef = (0, react.useRef)(null);
|
|
21
|
+
const cachedTargetsRef = (0, react.useRef)(null);
|
|
22
|
+
const runningAnimsRef = (0, react.useRef)([]);
|
|
23
|
+
const appBarBgScrubAnimRef = (0, react.useRef)(null);
|
|
24
|
+
const swipeStyleRef = (0, react.useRef)(null);
|
|
25
|
+
const pendingPushRAFRef = (0, react.useRef)(null);
|
|
26
|
+
const skipNextExitRef = (0, react.useRef)(false);
|
|
27
|
+
/** Cancel any running WAAPI animations and clear the ref. */
|
|
28
|
+
const stopRunningAnims = (0, react.useCallback)(() => {
|
|
29
|
+
require_animation.cancelAll(runningAnimsRef.current);
|
|
30
|
+
runningAnimsRef.current = [];
|
|
31
|
+
}, []);
|
|
32
|
+
/** Cancel the in-place scrub animation on the AppBar background. */
|
|
33
|
+
const stopAppBarBgScrub = (0, react.useCallback)(() => {
|
|
34
|
+
appBarBgScrubAnimRef.current?.cancel();
|
|
35
|
+
appBarBgScrubAnimRef.current = null;
|
|
36
|
+
}, []);
|
|
37
|
+
/** Cancel a pending deferred push animation, if any. */
|
|
38
|
+
const cancelPendingPushRAF = (0, react.useCallback)(() => {
|
|
39
|
+
if (pendingPushRAFRef.current !== null) {
|
|
40
|
+
cancelAnimationFrame(pendingPushRAFRef.current);
|
|
41
|
+
pendingPushRAFRef.current = null;
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
/** Update swipe-back-state attribute on the stack DOM element. */
|
|
45
|
+
const setSwipeBackState = (0, react.useCallback)((state) => {
|
|
46
|
+
swipeBackStateRef.current = state;
|
|
47
|
+
if (stackRef.current) stackRef.current.dataset["swipeBackState"] = state;
|
|
48
|
+
}, []);
|
|
49
|
+
const startSwipeBack = (0, react.useCallback)(({ x0, t0 }) => {
|
|
50
|
+
cancelPendingPushRAF();
|
|
51
|
+
stopRunningAnims();
|
|
52
|
+
stopAppBarBgScrub();
|
|
53
|
+
swipeBackContextRef.current = {
|
|
54
|
+
...IDLE_CONTEXT,
|
|
55
|
+
x0,
|
|
56
|
+
t0
|
|
57
|
+
};
|
|
58
|
+
if (stackRef.current) {
|
|
59
|
+
cachedTargetsRef.current = require_dom.findTransitionTargets(stackRef.current);
|
|
60
|
+
swipeStyleRef.current = require_dom.readTransitionStyle(stackRef.current);
|
|
61
|
+
}
|
|
62
|
+
setSwipeBackState("swiping");
|
|
63
|
+
}, [
|
|
64
|
+
cancelPendingPushRAF,
|
|
65
|
+
stopRunningAnims,
|
|
66
|
+
stopAppBarBgScrub,
|
|
67
|
+
setSwipeBackState
|
|
68
|
+
]);
|
|
69
|
+
const moveSwipeBack = (0, react.useCallback)(({ x, t }) => {
|
|
70
|
+
const ctx = swipeBackContextRef.current;
|
|
71
|
+
const displacement = Math.max(0, x - ctx.x0);
|
|
72
|
+
const displacementRatio = displacement / window.innerWidth;
|
|
73
|
+
const velocity = displacement / (t - ctx.t0);
|
|
74
|
+
ctx.displacement = displacement;
|
|
75
|
+
ctx.displacementRatio = displacementRatio;
|
|
76
|
+
ctx.velocity = velocity;
|
|
77
|
+
const targets = cachedTargetsRef.current;
|
|
78
|
+
if (targets && swipeStyleRef.current === "slideFromRightIOS") {
|
|
79
|
+
require_dom.applySwipeStyles(targets, displacement, displacementRatio);
|
|
80
|
+
appBarBgScrubAnimRef.current = require_animation.scrubAppBarBackground(targets.topAppBarBackground, `translate3d(${displacement}px, 0, 0)`, appBarBgScrubAnimRef.current);
|
|
81
|
+
}
|
|
82
|
+
return ctx;
|
|
83
|
+
}, []);
|
|
84
|
+
const endSwipeBack = (0, react.useCallback)((thresholds = {}) => {
|
|
85
|
+
const { displacementRatioThreshold = DEFAULT_DISPLACEMENT_RATIO_THRESHOLD, velocityThreshold = DEFAULT_VELOCITY_THRESHOLD } = thresholds;
|
|
86
|
+
const ctx = swipeBackContextRef.current;
|
|
87
|
+
const swiped = ctx.displacementRatio > displacementRatioThreshold || ctx.velocity > velocityThreshold;
|
|
88
|
+
const targets = cachedTargetsRef.current;
|
|
89
|
+
if (!targets) {
|
|
90
|
+
setSwipeBackState("idle");
|
|
91
|
+
return swiped;
|
|
92
|
+
}
|
|
93
|
+
if (swipeStyleRef.current !== "slideFromRightIOS") {
|
|
94
|
+
cachedTargetsRef.current = null;
|
|
95
|
+
swipeStyleRef.current = null;
|
|
96
|
+
setSwipeBackState("idle");
|
|
97
|
+
return swiped;
|
|
98
|
+
}
|
|
99
|
+
stopAppBarBgScrub();
|
|
100
|
+
const onFinish = (animations, pin) => {
|
|
101
|
+
pin();
|
|
102
|
+
require_animation.cancelAll(animations);
|
|
103
|
+
if (runningAnimsRef.current === animations) {
|
|
104
|
+
runningAnimsRef.current = [];
|
|
105
|
+
cachedTargetsRef.current = null;
|
|
106
|
+
swipeStyleRef.current = null;
|
|
107
|
+
setSwipeBackState("idle");
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
if (swiped) {
|
|
111
|
+
setSwipeBackState("completing");
|
|
112
|
+
skipNextExitRef.current = true;
|
|
113
|
+
const { animations, finished } = require_animation.animateSwipeComplete(targets, ctx.displacement);
|
|
114
|
+
runningAnimsRef.current = animations;
|
|
115
|
+
finished.then(() => onFinish(animations, () => require_dom.setPostExitPositions(targets)));
|
|
116
|
+
} else {
|
|
117
|
+
setSwipeBackState("canceling");
|
|
118
|
+
const { animations, finished } = require_animation.animateSwipeCancel(targets, ctx.displacement);
|
|
119
|
+
runningAnimsRef.current = animations;
|
|
120
|
+
finished.then(() => onFinish(animations, () => require_dom.setIdlePositions(targets)));
|
|
121
|
+
}
|
|
122
|
+
return swiped;
|
|
123
|
+
}, [setSwipeBackState, stopAppBarBgScrub]);
|
|
124
|
+
const resetSwipeBack = (0, react.useCallback)(() => {
|
|
125
|
+
stopRunningAnims();
|
|
126
|
+
stopAppBarBgScrub();
|
|
127
|
+
if (cachedTargetsRef.current) require_dom.clearAllStyles(cachedTargetsRef.current);
|
|
128
|
+
cachedTargetsRef.current = null;
|
|
129
|
+
swipeStyleRef.current = null;
|
|
130
|
+
swipeBackContextRef.current = { ...IDLE_CONTEXT };
|
|
131
|
+
setSwipeBackState("idle");
|
|
132
|
+
}, [
|
|
133
|
+
stopRunningAnims,
|
|
134
|
+
stopAppBarBgScrub,
|
|
135
|
+
setSwipeBackState
|
|
136
|
+
]);
|
|
137
|
+
const topActivity = require_useTopActivity.useTopActivity();
|
|
138
|
+
const prevTransitionStateRef = (0, react.useRef)(topActivity.transitionState);
|
|
139
|
+
(0, react.useLayoutEffect)(() => {
|
|
140
|
+
const prev = prevTransitionStateRef.current;
|
|
141
|
+
const next = topActivity.transitionState;
|
|
142
|
+
prevTransitionStateRef.current = next;
|
|
143
|
+
const stackEl = stackRef.current;
|
|
144
|
+
if (!stackEl) return;
|
|
145
|
+
const swipeState = swipeBackStateRef.current;
|
|
146
|
+
if (next === "enter-active" && prev !== "enter-active") {
|
|
147
|
+
if (swipeState !== "idle") return;
|
|
148
|
+
stopRunningAnims();
|
|
149
|
+
cancelPendingPushRAF();
|
|
150
|
+
pendingPushRAFRef.current = requestAnimationFrame(() => {
|
|
151
|
+
pendingPushRAFRef.current = null;
|
|
152
|
+
const style = require_dom.readTransitionStyle(stackEl);
|
|
153
|
+
const targets = require_dom.findTransitionTargets(stackEl);
|
|
154
|
+
const { animations, finished } = require_animation.animateTransition(targets, "push", style);
|
|
155
|
+
runningAnimsRef.current = animations;
|
|
156
|
+
finished.then(() => {
|
|
157
|
+
require_dom.setIdlePositions(targets, style);
|
|
158
|
+
require_animation.cancelAll(animations);
|
|
159
|
+
if (runningAnimsRef.current === animations) runningAnimsRef.current = [];
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (next === "exit-active" && prev !== "exit-active") {
|
|
164
|
+
if (skipNextExitRef.current) {
|
|
165
|
+
skipNextExitRef.current = false;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (swipeState !== "idle") return;
|
|
169
|
+
cancelPendingPushRAF();
|
|
170
|
+
stopRunningAnims();
|
|
171
|
+
const style = require_dom.readTransitionStyle(stackEl);
|
|
172
|
+
const targets = require_dom.findTransitionTargets(stackEl);
|
|
173
|
+
const { animations, finished } = require_animation.animateTransition(targets, "pop", style);
|
|
174
|
+
runningAnimsRef.current = animations;
|
|
175
|
+
finished.then(() => {
|
|
176
|
+
require_dom.setPostExitPositions(targets, style);
|
|
177
|
+
require_animation.cancelAll(animations);
|
|
178
|
+
if (runningAnimsRef.current === animations) runningAnimsRef.current = [];
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, [
|
|
182
|
+
topActivity.transitionState,
|
|
183
|
+
stopRunningAnims,
|
|
184
|
+
cancelPendingPushRAF
|
|
185
|
+
]);
|
|
186
|
+
(0, react.useEffect)(() => {
|
|
187
|
+
return () => {
|
|
188
|
+
cancelPendingPushRAF();
|
|
189
|
+
stopRunningAnims();
|
|
190
|
+
stopAppBarBgScrub();
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
cancelPendingPushRAF,
|
|
194
|
+
stopRunningAnims,
|
|
195
|
+
stopAppBarBgScrub
|
|
196
|
+
]);
|
|
197
|
+
const stackProps = (0, react.useMemo)(() => ({
|
|
198
|
+
"data-swipe-back-state": swipeBackStateRef.current,
|
|
199
|
+
"data-global-transition-state": topActivity.transitionState,
|
|
200
|
+
"data-top-activity-type": topActivity.activityType,
|
|
201
|
+
"data-top-transition-style": topActivity.transitionStyle
|
|
202
|
+
}), [
|
|
203
|
+
topActivity.transitionState,
|
|
204
|
+
topActivity.activityType,
|
|
205
|
+
topActivity.transitionStyle
|
|
206
|
+
]);
|
|
207
|
+
return (0, react.useMemo)(() => ({
|
|
208
|
+
stackRef,
|
|
209
|
+
startSwipeBack,
|
|
210
|
+
moveSwipeBack,
|
|
211
|
+
endSwipeBack,
|
|
212
|
+
resetSwipeBack,
|
|
213
|
+
stackProps
|
|
214
|
+
}), [
|
|
215
|
+
startSwipeBack,
|
|
216
|
+
moveSwipeBack,
|
|
217
|
+
endSwipeBack,
|
|
218
|
+
resetSwipeBack,
|
|
219
|
+
stackProps
|
|
220
|
+
]);
|
|
134
221
|
}
|
|
135
|
-
|
|
222
|
+
//#endregion
|
|
136
223
|
exports.useGlobalInteraction = useGlobalInteraction;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RefObject,
|
|
1
|
+
import { RefObject, HTMLAttributes } from 'react';
|
|
2
2
|
export type SwipeBackState = "idle" | "swiping" | "canceling" | "completing";
|
|
3
3
|
export type UseGlobalInteractionReturn = ReturnType<typeof useGlobalInteraction>;
|
|
4
4
|
export interface SwipeBackContext {
|
|
@@ -8,25 +8,17 @@ export interface SwipeBackContext {
|
|
|
8
8
|
displacementRatio: number;
|
|
9
9
|
velocity: number;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface SwipeBackThresholds {
|
|
12
12
|
/**
|
|
13
|
-
* The threshold to determine whether the swipe back is intentional.
|
|
13
|
+
* The threshold to determine whether the swipe back is intentional, by displacement ratio.
|
|
14
14
|
* @default 0.4
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
displacementRatioThreshold?: number;
|
|
17
17
|
/**
|
|
18
|
-
* The threshold to determine whether the swipe back is intentional.
|
|
18
|
+
* The threshold to determine whether the swipe back is intentional, by velocity.
|
|
19
19
|
* @default 1
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
onSwipeBackStart?: () => void;
|
|
23
|
-
onSwipeBackMove?: (props: {
|
|
24
|
-
displacement: number;
|
|
25
|
-
displacementRatio: number;
|
|
26
|
-
}) => void;
|
|
27
|
-
onSwipeBackEnd?: (props: {
|
|
28
|
-
swiped: boolean;
|
|
29
|
-
}) => void;
|
|
21
|
+
velocityThreshold?: number;
|
|
30
22
|
}
|
|
31
23
|
export interface StartSwipeBackProps {
|
|
32
24
|
x0: number;
|
|
@@ -36,19 +28,11 @@ export interface MoveSwipeBackProps {
|
|
|
36
28
|
x: number;
|
|
37
29
|
t: number;
|
|
38
30
|
}
|
|
39
|
-
export interface EndSwipeBackProps {
|
|
40
|
-
}
|
|
41
31
|
export declare function useGlobalInteraction(): {
|
|
42
32
|
stackRef: RefObject<HTMLDivElement | null>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
getSwipeBackEvents: (props: SwipeBackProps) => {
|
|
48
|
-
startSwipeBack: ({ x0, t0 }: StartSwipeBackProps) => void;
|
|
49
|
-
moveSwipeBack: ({ x, t }: MoveSwipeBackProps) => void;
|
|
50
|
-
endSwipeBack: (_: EndSwipeBackProps) => void;
|
|
51
|
-
reset: () => void;
|
|
52
|
-
};
|
|
33
|
+
startSwipeBack: ({ x0, t0 }: StartSwipeBackProps) => void;
|
|
34
|
+
moveSwipeBack: ({ x, t }: MoveSwipeBackProps) => SwipeBackContext;
|
|
35
|
+
endSwipeBack: (thresholds?: SwipeBackThresholds) => boolean;
|
|
36
|
+
resetSwipeBack: () => void;
|
|
53
37
|
stackProps: HTMLAttributes<HTMLElement>;
|
|
54
38
|
};
|