react-native-screen-transitions 3.2.1 → 3.3.0-beta.0
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/README.md +1 -1
- package/lib/commonjs/shared/components/create-transition-aware-component.js +8 -2
- package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/shared/components/{root-transition-aware.js → screen-container.js} +28 -12
- package/lib/commonjs/shared/components/screen-container.js.map +1 -0
- package/lib/commonjs/shared/configs/presets.js +3 -3
- package/lib/commonjs/shared/configs/presets.js.map +1 -1
- package/lib/commonjs/shared/configs/specs.js +6 -1
- package/lib/commonjs/shared/configs/specs.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +36 -188
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js +334 -0
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -0
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +47 -4
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js +3 -3
- package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
- package/lib/commonjs/shared/hooks/lifecycle/use-open-transition.js +25 -3
- package/lib/commonjs/shared/hooks/lifecycle/use-open-transition.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +61 -2
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/commonjs/shared/hooks/use-backdrop-pointer-events.js +32 -0
- package/lib/commonjs/shared/hooks/use-backdrop-pointer-events.js.map +1 -0
- package/lib/commonjs/shared/providers/gestures.provider.js +4 -2
- package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/screen-composer.js +2 -2
- package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/commonjs/shared/utils/animation/{start-screen-transition.js → animate-to-progress.js} +11 -7
- package/lib/commonjs/shared/utils/animation/animate-to-progress.js.map +1 -0
- package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js +71 -0
- package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/commonjs/shared/utils/gesture/determine-snap-target.js +56 -0
- package/lib/commonjs/shared/utils/gesture/determine-snap-target.js.map +1 -0
- package/lib/commonjs/shared/utils/gesture/validate-snap-points.js +31 -0
- package/lib/commonjs/shared/utils/gesture/validate-snap-points.js.map +1 -0
- package/lib/commonjs/shared/utils/gesture/velocity.js +11 -0
- package/lib/commonjs/shared/utils/gesture/velocity.js.map +1 -1
- package/lib/module/shared/components/create-transition-aware-component.js +8 -2
- package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/shared/components/screen-container.js +64 -0
- package/lib/module/shared/components/screen-container.js.map +1 -0
- package/lib/module/shared/configs/presets.js +3 -3
- package/lib/module/shared/configs/presets.js.map +1 -1
- package/lib/module/shared/configs/specs.js +5 -0
- package/lib/module/shared/configs/specs.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +36 -187
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js +328 -0
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -0
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js +47 -4
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/module/shared/hooks/lifecycle/use-close-transition.js +3 -3
- package/lib/module/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
- package/lib/module/shared/hooks/lifecycle/use-open-transition.js +25 -3
- package/lib/module/shared/hooks/lifecycle/use-open-transition.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-screen-state.js +63 -4
- package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/module/shared/hooks/use-backdrop-pointer-events.js +28 -0
- package/lib/module/shared/hooks/use-backdrop-pointer-events.js.map +1 -0
- package/lib/module/shared/providers/gestures.provider.js +4 -2
- package/lib/module/shared/providers/gestures.provider.js.map +1 -1
- package/lib/module/shared/providers/screen/screen-composer.js +2 -2
- package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/module/shared/utils/animation/{start-screen-transition.js → animate-to-progress.js} +9 -5
- package/lib/module/shared/utils/animation/animate-to-progress.js.map +1 -0
- package/lib/module/shared/utils/gesture/check-gesture-activation.js +70 -0
- package/lib/module/shared/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/module/shared/utils/gesture/determine-snap-target.js +52 -0
- package/lib/module/shared/utils/gesture/determine-snap-target.js.map +1 -0
- package/lib/module/shared/utils/gesture/validate-snap-points.js +26 -0
- package/lib/module/shared/utils/gesture/validate-snap-points.js.map +1 -0
- package/lib/module/shared/utils/gesture/velocity.js +11 -0
- package/lib/module/shared/utils/gesture/velocity.js.map +1 -1
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container.d.ts +6 -0
- package/lib/typescript/shared/components/screen-container.d.ts.map +1 -0
- package/lib/typescript/shared/configs/specs.d.ts +1 -0
- package/lib/typescript/shared/configs/specs.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts +34 -0
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts +5 -1
- package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/lifecycle/use-open-transition.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts +14 -0
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/use-backdrop-pointer-events.d.ts +15 -0
- package/lib/typescript/shared/hooks/use-backdrop-pointer-events.d.ts.map +1 -0
- package/lib/typescript/shared/providers/gestures.provider.d.ts +1 -0
- package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +28 -2
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +26 -0
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts +19 -0
- package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts.map +1 -0
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts +24 -0
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/determine-snap-target.d.ts +26 -0
- package/lib/typescript/shared/utils/gesture/determine-snap-target.d.ts.map +1 -0
- package/lib/typescript/shared/utils/gesture/validate-snap-points.d.ts +13 -0
- package/lib/typescript/shared/utils/gesture/validate-snap-points.d.ts.map +1 -0
- package/lib/typescript/shared/utils/gesture/velocity.d.ts +1 -0
- package/lib/typescript/shared/utils/gesture/velocity.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/shared/__tests__/determine-snap-target.test.ts +268 -0
- package/src/shared/__tests__/gesture-activation.test.ts +247 -0
- package/src/shared/__tests__/validate-snap-points.test.ts +125 -0
- package/src/shared/components/create-transition-aware-component.tsx +11 -1
- package/src/shared/components/screen-container.tsx +65 -0
- package/src/shared/configs/presets.ts +3 -3
- package/src/shared/configs/specs.ts +6 -0
- package/src/shared/hooks/gestures/use-build-gestures.tsx +33 -253
- package/src/shared/hooks/gestures/use-screen-gesture-handlers.ts +436 -0
- package/src/shared/hooks/gestures/use-scroll-registry.tsx +52 -1
- package/src/shared/hooks/lifecycle/use-close-transition.ts +3 -3
- package/src/shared/hooks/lifecycle/use-open-transition.ts +27 -3
- package/src/shared/hooks/navigation/use-screen-state.tsx +106 -2
- package/src/shared/hooks/use-backdrop-pointer-events.ts +32 -0
- package/src/shared/providers/gestures.provider.tsx +3 -2
- package/src/shared/providers/screen/screen-composer.tsx +2 -2
- package/src/shared/types/animation.types.ts +29 -2
- package/src/shared/types/screen.types.ts +29 -0
- package/src/shared/utils/animation/{start-screen-transition.ts → animate-to-progress.ts} +19 -7
- package/src/shared/utils/gesture/check-gesture-activation.ts +78 -0
- package/src/shared/utils/gesture/determine-snap-target.ts +75 -0
- package/src/shared/utils/gesture/validate-snap-points.ts +37 -0
- package/src/shared/utils/gesture/velocity.ts +10 -0
- package/lib/commonjs/shared/components/root-transition-aware.js.map +0 -1
- package/lib/commonjs/shared/hooks/use-stack-pointer-events.js +0 -23
- package/lib/commonjs/shared/hooks/use-stack-pointer-events.js.map +0 -1
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +0 -1
- package/lib/module/shared/components/root-transition-aware.js +0 -48
- package/lib/module/shared/components/root-transition-aware.js.map +0 -1
- package/lib/module/shared/hooks/use-stack-pointer-events.js +0 -20
- package/lib/module/shared/hooks/use-stack-pointer-events.js.map +0 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js.map +0 -1
- package/lib/typescript/shared/components/root-transition-aware.d.ts +0 -6
- package/lib/typescript/shared/components/root-transition-aware.d.ts.map +0 -1
- package/lib/typescript/shared/hooks/use-stack-pointer-events.d.ts +0 -10
- package/lib/typescript/shared/hooks/use-stack-pointer-events.d.ts.map +0 -1
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts +0 -13
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +0 -1
- package/src/shared/components/root-transition-aware.tsx +0 -49
- package/src/shared/hooks/use-stack-pointer-events.ts +0 -15
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { StackActions } from "@react-navigation/native";
|
|
2
2
|
import { useCallback, useMemo, useRef } from "react";
|
|
3
3
|
import { useWindowDimensions } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
type GestureStateChangeEvent,
|
|
7
|
-
type GestureTouchEvent,
|
|
8
|
-
type GestureType,
|
|
9
|
-
type GestureUpdateEvent,
|
|
10
|
-
type PanGestureHandlerEventPayload,
|
|
11
|
-
} from "react-native-gesture-handler";
|
|
12
|
-
import type { GestureStateManagerType } from "react-native-gesture-handler/lib/typescript/handlers/gestures/gestureStateManager";
|
|
13
|
-
import { type SharedValue, useSharedValue } from "react-native-reanimated";
|
|
4
|
+
import { Gesture, type GestureType } from "react-native-gesture-handler";
|
|
5
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
14
6
|
import {
|
|
15
7
|
DEFAULT_GESTURE_ACTIVATION_AREA,
|
|
16
8
|
DEFAULT_GESTURE_DIRECTION,
|
|
@@ -24,17 +16,7 @@ import type {
|
|
|
24
16
|
import { useKeys } from "../../providers/screen/keys.provider";
|
|
25
17
|
import { AnimationStore } from "../../stores/animation.store";
|
|
26
18
|
import { GestureStore, type GestureStoreMap } from "../../stores/gesture.store";
|
|
27
|
-
import {
|
|
28
|
-
type GestureDirection,
|
|
29
|
-
GestureOffsetState,
|
|
30
|
-
} from "../../types/gesture.types";
|
|
31
|
-
import { startScreenTransition } from "../../utils/animation/start-screen-transition";
|
|
32
|
-
import { applyOffsetRules } from "../../utils/gesture/check-gesture-activation";
|
|
33
|
-
import { determineDismissal } from "../../utils/gesture/determine-dismissal";
|
|
34
|
-
import { mapGestureToProgress } from "../../utils/gesture/map-gesture-to-progress";
|
|
35
|
-
import { resetGestureValues } from "../../utils/gesture/reset-gesture-values";
|
|
36
|
-
import { velocity } from "../../utils/gesture/velocity";
|
|
37
|
-
import useStableCallbackValue from "../use-stable-callback-value";
|
|
19
|
+
import { useScreenGestureHandlers } from "./use-screen-gesture-handlers";
|
|
38
20
|
|
|
39
21
|
interface BuildGesturesHookProps {
|
|
40
22
|
scrollConfig: SharedValue<ScrollConfig | null>;
|
|
@@ -53,18 +35,12 @@ export const useBuildGestures = ({
|
|
|
53
35
|
const dimensions = useWindowDimensions();
|
|
54
36
|
|
|
55
37
|
const { current } = useKeys();
|
|
56
|
-
const navState = current.navigation.getState();
|
|
57
|
-
const isFirstScreen =
|
|
58
|
-
navState.routes.findIndex((r) => r.key === current.route.key) === 0;
|
|
59
38
|
|
|
60
|
-
const
|
|
61
|
-
x: 0,
|
|
62
|
-
y: 0,
|
|
63
|
-
});
|
|
39
|
+
const navState = current.navigation.getState();
|
|
64
40
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
);
|
|
41
|
+
const isFirstScreen = useMemo(() => {
|
|
42
|
+
return navState.routes.findIndex((r) => r.key === current.route.key) === 0;
|
|
43
|
+
}, [navState.routes, current.route.key]);
|
|
68
44
|
|
|
69
45
|
// Ref for external gesture coordination (e.g., swipeable lists)
|
|
70
46
|
const panGestureRef = useRef<GestureType | undefined>(undefined);
|
|
@@ -81,27 +57,19 @@ export const useBuildGestures = ({
|
|
|
81
57
|
gestureActivationArea = DEFAULT_GESTURE_ACTIVATION_AREA,
|
|
82
58
|
gestureResponseDistance,
|
|
83
59
|
transitionSpec,
|
|
60
|
+
snapPoints,
|
|
84
61
|
} = current.options;
|
|
85
62
|
|
|
86
|
-
|
|
63
|
+
// Dismiss gesture is controlled by gestureEnabled (disabled for first screen)
|
|
64
|
+
const canDismiss = Boolean(
|
|
87
65
|
isFirstScreen ? false : current.options.gestureEnabled,
|
|
88
66
|
);
|
|
89
67
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
vertical: directionsArray.includes("vertical") || isBidirectional,
|
|
98
|
-
verticalInverted:
|
|
99
|
-
directionsArray.includes("vertical-inverted") || isBidirectional,
|
|
100
|
-
horizontal: directionsArray.includes("horizontal") || isBidirectional,
|
|
101
|
-
horizontalInverted:
|
|
102
|
-
directionsArray.includes("horizontal-inverted") || isBidirectional,
|
|
103
|
-
};
|
|
104
|
-
}, [gestureDirection]);
|
|
68
|
+
// Snap navigation works independently - enabled when snap points exist
|
|
69
|
+
// This matches iOS native sheet behavior where gestureEnabled: false
|
|
70
|
+
// disables dismiss but you can still drag between detents
|
|
71
|
+
const hasSnapPoints = Array.isArray(snapPoints) && snapPoints.length > 0;
|
|
72
|
+
const gestureEnabled = canDismiss || hasSnapPoints;
|
|
105
73
|
|
|
106
74
|
const handleDismiss = useCallback(() => {
|
|
107
75
|
// If an ancestor navigator is already dismissing, skip this dismiss to
|
|
@@ -127,212 +95,24 @@ export const useBuildGestures = ({
|
|
|
127
95
|
});
|
|
128
96
|
}, [current, ancestorContext]);
|
|
129
97
|
|
|
130
|
-
const onTouchesDown
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const touch = e.changedTouches[0];
|
|
149
|
-
|
|
150
|
-
const { isSwipingDown, isSwipingUp, isSwipingRight, isSwipingLeft } =
|
|
151
|
-
applyOffsetRules({
|
|
152
|
-
touch,
|
|
153
|
-
directions,
|
|
154
|
-
manager,
|
|
155
|
-
dimensions,
|
|
156
|
-
gestureOffsetState,
|
|
157
|
-
initialTouch: initialTouch.value,
|
|
158
|
-
activationArea: gestureActivationArea,
|
|
159
|
-
responseDistance: gestureResponseDistance,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
if (gestureOffsetState.value === GestureOffsetState.FAILED) {
|
|
163
|
-
manager.fail();
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Keep pending until thresholds are met; no eager activation.
|
|
168
|
-
if (gestureAnimationValues.isDragging?.value) {
|
|
169
|
-
manager.activate();
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const maxScrollY = scrollConfig.value?.contentHeight
|
|
174
|
-
? scrollConfig.value.contentHeight - scrollConfig.value.layoutHeight
|
|
175
|
-
: 0;
|
|
176
|
-
|
|
177
|
-
const maxScrollX = scrollConfig.value?.contentWidth
|
|
178
|
-
? scrollConfig.value.contentWidth - scrollConfig.value.layoutWidth
|
|
179
|
-
: 0;
|
|
180
|
-
|
|
181
|
-
const recognizedDirection =
|
|
182
|
-
isSwipingDown || isSwipingUp || isSwipingRight || isSwipingLeft;
|
|
183
|
-
|
|
184
|
-
const scrollCfg = scrollConfig.value;
|
|
185
|
-
|
|
186
|
-
let shouldActivate = false;
|
|
187
|
-
let activatedDirection: GestureDirection | null = null;
|
|
188
|
-
|
|
189
|
-
if (recognizedDirection) {
|
|
190
|
-
if (directions.vertical && isSwipingDown) {
|
|
191
|
-
shouldActivate = scrollCfg ? scrollCfg.y <= 0 : true;
|
|
192
|
-
if (shouldActivate) activatedDirection = "vertical";
|
|
193
|
-
}
|
|
194
|
-
if (directions.horizontal && isSwipingRight) {
|
|
195
|
-
shouldActivate = scrollCfg ? scrollCfg.x <= 0 : true;
|
|
196
|
-
if (shouldActivate) activatedDirection = "horizontal";
|
|
197
|
-
}
|
|
198
|
-
if (directions.verticalInverted && isSwipingUp) {
|
|
199
|
-
shouldActivate = scrollCfg ? scrollCfg.y >= maxScrollY : true;
|
|
200
|
-
if (shouldActivate) activatedDirection = "vertical-inverted";
|
|
201
|
-
}
|
|
202
|
-
if (directions.horizontalInverted && isSwipingLeft) {
|
|
203
|
-
shouldActivate = scrollCfg ? scrollCfg.x >= maxScrollX : true;
|
|
204
|
-
if (shouldActivate) activatedDirection = "horizontal-inverted";
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (recognizedDirection && !shouldActivate) {
|
|
209
|
-
manager.fail();
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
shouldActivate &&
|
|
215
|
-
gestureOffsetState.value === GestureOffsetState.PASSED &&
|
|
216
|
-
!gestureAnimationValues.isDismissing?.value
|
|
217
|
-
) {
|
|
218
|
-
gestureAnimationValues.direction.value = activatedDirection;
|
|
219
|
-
manager.activate();
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
const onStart = useStableCallbackValue(() => {
|
|
226
|
-
"worklet";
|
|
227
|
-
gestureAnimationValues.isDragging.value = 1;
|
|
228
|
-
gestureAnimationValues.isDismissing.value = 0;
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const onUpdate = useStableCallbackValue(
|
|
232
|
-
(event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => {
|
|
233
|
-
"worklet";
|
|
234
|
-
|
|
235
|
-
let gestureProgress = 0;
|
|
236
|
-
|
|
237
|
-
const { translationX, translationY } = event;
|
|
238
|
-
const { width, height } = dimensions;
|
|
239
|
-
|
|
240
|
-
gestureAnimationValues.x.value = translationX;
|
|
241
|
-
gestureAnimationValues.y.value = translationY;
|
|
242
|
-
gestureAnimationValues.normalizedX.value = Math.max(
|
|
243
|
-
-1,
|
|
244
|
-
Math.min(1, translationX / width),
|
|
245
|
-
);
|
|
246
|
-
gestureAnimationValues.normalizedY.value = Math.max(
|
|
247
|
-
-1,
|
|
248
|
-
Math.min(1, translationY / height),
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
let maxProgress = 0;
|
|
252
|
-
|
|
253
|
-
const allowedDown = directions.vertical;
|
|
254
|
-
const allowedUp = directions.verticalInverted;
|
|
255
|
-
const allowedRight = directions.horizontal;
|
|
256
|
-
const allowedLeft = directions.horizontalInverted;
|
|
257
|
-
|
|
258
|
-
if (allowedRight && event.translationX > 0) {
|
|
259
|
-
const currentProgress = mapGestureToProgress(
|
|
260
|
-
translationX,
|
|
261
|
-
dimensions.width,
|
|
262
|
-
);
|
|
263
|
-
maxProgress = Math.max(maxProgress, currentProgress);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (allowedLeft && event.translationX < 0) {
|
|
267
|
-
const currentProgress = mapGestureToProgress(
|
|
268
|
-
-translationX,
|
|
269
|
-
dimensions.width,
|
|
270
|
-
);
|
|
271
|
-
maxProgress = Math.max(maxProgress, currentProgress);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (allowedDown && event.translationY > 0) {
|
|
275
|
-
const currentProgress = mapGestureToProgress(
|
|
276
|
-
translationY,
|
|
277
|
-
dimensions.height,
|
|
278
|
-
);
|
|
279
|
-
maxProgress = Math.max(maxProgress, currentProgress);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (allowedUp && event.translationY < 0) {
|
|
283
|
-
const currentProgress = mapGestureToProgress(
|
|
284
|
-
-translationY,
|
|
285
|
-
dimensions.height,
|
|
286
|
-
);
|
|
287
|
-
maxProgress = Math.max(maxProgress, currentProgress);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
gestureProgress = maxProgress;
|
|
291
|
-
|
|
292
|
-
if (gestureDrivesProgress) {
|
|
293
|
-
animations.progress.value = 1 - gestureProgress;
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
const onEnd = useStableCallbackValue(
|
|
299
|
-
(event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
|
|
300
|
-
"worklet";
|
|
301
|
-
|
|
302
|
-
const { shouldDismiss } = determineDismissal({
|
|
303
|
-
event,
|
|
304
|
-
directions,
|
|
305
|
-
dimensions,
|
|
306
|
-
gestureVelocityImpact,
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
const spec = shouldDismiss ? transitionSpec?.close : transitionSpec?.open;
|
|
310
|
-
|
|
311
|
-
resetGestureValues({
|
|
312
|
-
spec,
|
|
313
|
-
gestures: gestureAnimationValues,
|
|
314
|
-
shouldDismiss,
|
|
315
|
-
event,
|
|
316
|
-
dimensions,
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
const initialVelocity = velocity.calculateProgressVelocity({
|
|
320
|
-
animations,
|
|
321
|
-
shouldDismiss,
|
|
322
|
-
event,
|
|
323
|
-
dimensions,
|
|
324
|
-
directions,
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
startScreenTransition({
|
|
328
|
-
target: shouldDismiss ? "close" : "open",
|
|
329
|
-
onAnimationFinish: shouldDismiss ? handleDismiss : undefined,
|
|
330
|
-
spec: transitionSpec,
|
|
331
|
-
animations,
|
|
332
|
-
initialVelocity,
|
|
333
|
-
});
|
|
334
|
-
},
|
|
335
|
-
);
|
|
98
|
+
const { onTouchesDown, onTouchesMove, onStart, onUpdate, onEnd } =
|
|
99
|
+
useScreenGestureHandlers({
|
|
100
|
+
dimensions,
|
|
101
|
+
animations,
|
|
102
|
+
gestureAnimationValues,
|
|
103
|
+
gestureDirection,
|
|
104
|
+
gestureDrivesProgress,
|
|
105
|
+
gestureVelocityImpact,
|
|
106
|
+
scrollConfig,
|
|
107
|
+
gestureActivationArea,
|
|
108
|
+
gestureResponseDistance,
|
|
109
|
+
snapPoints,
|
|
110
|
+
canDismiss,
|
|
111
|
+
transitionSpec,
|
|
112
|
+
handleDismiss,
|
|
113
|
+
ancestorIsDismissing:
|
|
114
|
+
ancestorContext?.gestureAnimationValues.isDismissing,
|
|
115
|
+
});
|
|
336
116
|
|
|
337
117
|
// Memoize gestures to keep stable references - critical for RNGH
|
|
338
118
|
// Child gestures reference ancestor's pan via requireExternalGestureToFail,
|