react-native-gesture-handler 2.22.1 → 2.23.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/RNGestureHandler.podspec +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +14 -0
- package/android/src/main/jni/cpp-adapter.cpp +19 -12
- package/apple/RNGestureHandler.mm +15 -8
- package/apple/RNGestureHandlerButton.mm +12 -2
- package/apple/RNGestureHandlerModule.mm +17 -5
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +6 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js +11 -2
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +21 -5
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/index.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable.js +49 -20
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/components/Text.js +10 -4
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableHighlight.js +2 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +2 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +5 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +3 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/commonjs/findNodeHandle.web.js +9 -1
- package/lib/commonjs/findNodeHandle.web.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js +8 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +5 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/LongPressGestureHandler.js +8 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +8 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +8 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PinchGestureHandler.js +8 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/RotationGestureHandler.js +8 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/TapGestureHandler.js +8 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +6 -2
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/handlers/handlersRegistry.js +7 -2
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +3 -3
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +22 -22
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +24 -24
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +6 -6
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +112 -92
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js +2 -2
- package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -6
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +13 -13
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +15 -15
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +15 -15
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +12 -12
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +4 -4
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/CircularBuffer.js +15 -15
- package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +40 -40
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +32 -13
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/InteractionManager.js +16 -18
- package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
- package/lib/commonjs/web/tools/NodeManager.js +2 -2
- package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +18 -18
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +2 -2
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +7 -0
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js +10 -2
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +22 -6
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/index.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable.js +49 -20
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/components/Text.js +8 -3
- package/lib/module/components/Text.js.map +1 -1
- package/lib/module/components/touchables/TouchableHighlight.js +2 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +2 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.js +6 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +5 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +4 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/module/findNodeHandle.web.js +8 -1
- package/lib/module/findNodeHandle.web.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js +7 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js +5 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js +7 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +7 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +7 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PinchGestureHandler.js +11 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/handlers/RotationGestureHandler.js +11 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/handlers/TapGestureHandler.js +7 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +9 -4
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/handlersRegistry.js +6 -3
- package/lib/module/handlers/handlersRegistry.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +2 -2
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +22 -22
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +24 -24
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +6 -6
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +112 -92
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +2 -2
- package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +6 -6
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +13 -13
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +15 -15
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +15 -15
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +12 -12
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +4 -4
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/CircularBuffer.js +15 -15
- package/lib/module/web/tools/CircularBuffer.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +40 -40
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +32 -13
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/InteractionManager.js +16 -16
- package/lib/module/web/tools/InteractionManager.js.map +1 -1
- package/lib/module/web/tools/NodeManager.js +2 -2
- package/lib/module/web/tools/NodeManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +18 -18
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/module/web/tools/VelocityTracker.js +1 -1
- package/lib/module/web/tools/VelocityTracker.js.map +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +27 -0
- package/lib/typescript/components/GestureButtonsProps.d.ts +18 -2
- package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -10
- package/lib/typescript/components/Pressable/index.d.ts +1 -1
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +6 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +5 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +2 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +5 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +3 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -0
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +6 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +9 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/utils.d.ts +1 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +7 -7
- package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +8 -8
- package/lib/typescript/web/handlers/GestureHandler.d.ts +33 -28
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +12 -13
- package/lib/typescript/web/tools/CircularBuffer.d.ts +3 -3
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +2 -2
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +3 -2
- package/lib/typescript/web/tools/InteractionManager.d.ts +2 -2
- package/lib/typescript/web/tools/NodeManager.d.ts +1 -1
- package/lib/typescript/web/tools/PointerTracker.d.ts +4 -4
- package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -1
- package/package.json +2 -2
- package/src/RNGestureHandlerModule.web.ts +2 -2
- package/src/components/DrawerLayout.tsx +29 -0
- package/src/components/GestureButtons.tsx +13 -2
- package/src/components/GestureButtonsProps.ts +31 -2
- package/src/components/Pressable/Pressable.tsx +22 -5
- package/src/components/Pressable/PressableProps.tsx +4 -11
- package/src/components/Pressable/index.ts +4 -1
- package/src/components/ReanimatedSwipeable.tsx +97 -66
- package/src/components/Text.tsx +13 -4
- package/src/components/touchables/TouchableHighlight.tsx +5 -0
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -0
- package/src/components/touchables/TouchableNativeFeedback.tsx +6 -1
- package/src/components/touchables/TouchableNativeFeedbackProps.tsx +3 -0
- package/src/components/touchables/TouchableOpacity.tsx +5 -0
- package/src/components/touchables/TouchableWithoutFeedback.tsx +6 -0
- package/src/findNodeHandle.web.ts +6 -0
- package/src/handlers/FlingGestureHandler.ts +10 -0
- package/src/handlers/ForceTouchGestureHandler.ts +9 -0
- package/src/handlers/LongPressGestureHandler.ts +10 -0
- package/src/handlers/NativeViewGestureHandler.ts +10 -0
- package/src/handlers/PanGestureHandler.ts +10 -0
- package/src/handlers/PinchGestureHandler.ts +10 -0
- package/src/handlers/RotationGestureHandler.ts +10 -0
- package/src/handlers/TapGestureHandler.ts +10 -0
- package/src/handlers/createHandler.tsx +11 -4
- package/src/handlers/gestures/GestureDetector/index.tsx +2 -2
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +3 -3
- package/src/handlers/gestures/GestureDetector/utils.ts +2 -2
- package/src/handlers/handlersRegistry.ts +7 -3
- package/src/index.ts +4 -1
- package/src/utils.ts +2 -2
- package/src/web/detectors/RotationGestureDetector.ts +22 -22
- package/src/web/detectors/ScaleGestureDetector.ts +24 -24
- package/src/web/handlers/FlingGestureHandler.ts +6 -7
- package/src/web/handlers/GestureHandler.ts +115 -105
- package/src/web/handlers/HoverGestureHandler.ts +2 -2
- package/src/web/handlers/IGestureHandler.ts +12 -13
- package/src/web/handlers/LongPressGestureHandler.ts +7 -7
- package/src/web/handlers/NativeViewGestureHandler.ts +14 -19
- package/src/web/handlers/PanGestureHandler.ts +17 -17
- package/src/web/handlers/PinchGestureHandler.ts +17 -21
- package/src/web/handlers/RotationGestureHandler.ts +12 -12
- package/src/web/handlers/TapGestureHandler.ts +4 -6
- package/src/web/tools/CircularBuffer.ts +15 -15
- package/src/web/tools/GestureHandlerDelegate.ts +1 -1
- package/src/web/tools/GestureHandlerOrchestrator.ts +42 -42
- package/src/web/tools/GestureHandlerWebDelegate.ts +32 -13
- package/src/web/tools/InteractionManager.ts +16 -16
- package/src/web/tools/NodeManager.ts +2 -2
- package/src/web/tools/PointerTracker.ts +20 -20
- package/src/web/tools/Vector.ts +1 -1
- package/src/web/tools/VelocityTracker.ts +1 -1
@@ -5,12 +5,22 @@ import {
|
|
5
5
|
baseGestureHandlerProps,
|
6
6
|
} from './gestureHandlerCommon';
|
7
7
|
|
8
|
+
/**
|
9
|
+
* @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
|
10
|
+
*/
|
8
11
|
export interface PinchGestureHandlerProps
|
9
12
|
extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}
|
10
13
|
|
11
14
|
export const pinchHandlerName = 'PinchGestureHandler';
|
12
15
|
|
16
|
+
/**
|
17
|
+
* @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
|
18
|
+
*/
|
13
19
|
export type PinchGestureHandler = typeof PinchGestureHandler;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
|
23
|
+
*/
|
14
24
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
15
25
|
export const PinchGestureHandler = createHandler<
|
16
26
|
PinchGestureHandlerProps,
|
@@ -5,12 +5,22 @@ import {
|
|
5
5
|
baseGestureHandlerProps,
|
6
6
|
} from './gestureHandlerCommon';
|
7
7
|
|
8
|
+
/**
|
9
|
+
* @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
|
10
|
+
*/
|
8
11
|
export interface RotationGestureHandlerProps
|
9
12
|
extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}
|
10
13
|
|
11
14
|
export const rotationHandlerName = 'RotationGestureHandler';
|
12
15
|
|
16
|
+
/**
|
17
|
+
* @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
|
18
|
+
*/
|
13
19
|
export type RotationGestureHandler = typeof RotationGestureHandler;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
|
23
|
+
*/
|
14
24
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
15
25
|
export const RotationGestureHandler = createHandler<
|
16
26
|
RotationGestureHandlerProps,
|
@@ -66,13 +66,23 @@ export interface TapGestureConfig {
|
|
66
66
|
maxDist?: number;
|
67
67
|
}
|
68
68
|
|
69
|
+
/**
|
70
|
+
* @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
|
71
|
+
*/
|
69
72
|
export interface TapGestureHandlerProps
|
70
73
|
extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,
|
71
74
|
TapGestureConfig {}
|
72
75
|
|
73
76
|
export const tapHandlerName = 'TapGestureHandler';
|
74
77
|
|
78
|
+
/**
|
79
|
+
* @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
|
80
|
+
*/
|
75
81
|
export type TapGestureHandler = typeof TapGestureHandler;
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
|
85
|
+
*/
|
76
86
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
77
87
|
export const TapGestureHandler = createHandler<
|
78
88
|
TapGestureHandlerProps,
|
@@ -8,7 +8,11 @@ import {
|
|
8
8
|
import { customDirectEventTypes } from './customDirectEventTypes';
|
9
9
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
10
10
|
import { State } from '../State';
|
11
|
-
import {
|
11
|
+
import {
|
12
|
+
handlerIDToTag,
|
13
|
+
registerOldGestureHandler,
|
14
|
+
unregisterOldGestureHandler,
|
15
|
+
} from './handlersRegistry';
|
12
16
|
import { getNextHandlerTag } from './getNextHandlerTag';
|
13
17
|
|
14
18
|
import {
|
@@ -19,7 +23,7 @@ import {
|
|
19
23
|
import { filterConfig, scheduleFlushOperations } from './utils';
|
20
24
|
import findNodeHandle from '../findNodeHandle';
|
21
25
|
import { ValueOf } from '../typeUtils';
|
22
|
-
import { deepEqual, isFabric,
|
26
|
+
import { deepEqual, isFabric, isTestEnv, tagMessage } from '../utils';
|
23
27
|
import { ActionType } from '../ActionType';
|
24
28
|
import { PressabilityDebugView } from './PressabilityDebugView';
|
25
29
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
@@ -255,6 +259,9 @@ export default function createHandler<
|
|
255
259
|
componentWillUnmount() {
|
256
260
|
this.inspectorToggleListener?.remove();
|
257
261
|
this.isMountedRef.current = false;
|
262
|
+
if (Platform.OS !== 'web') {
|
263
|
+
unregisterOldGestureHandler(this.handlerTag);
|
264
|
+
}
|
258
265
|
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
|
259
266
|
scheduleFlushOperations();
|
260
267
|
// We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
|
@@ -428,7 +435,7 @@ export default function createHandler<
|
|
428
435
|
}
|
429
436
|
|
430
437
|
render() {
|
431
|
-
if (__DEV__ && !this.context && !
|
438
|
+
if (__DEV__ && !this.context && !isTestEnv() && Platform.OS !== 'web') {
|
432
439
|
throw new Error(
|
433
440
|
name +
|
434
441
|
' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
@@ -539,7 +546,7 @@ export default function createHandler<
|
|
539
546
|
{
|
540
547
|
ref: this.refHandler,
|
541
548
|
collapsable: false,
|
542
|
-
...(
|
549
|
+
...(isTestEnv()
|
543
550
|
? {
|
544
551
|
handlerType: name,
|
545
552
|
handlerTag: this.handlerTag,
|
@@ -11,7 +11,7 @@ import findNodeHandle from '../../../findNodeHandle';
|
|
11
11
|
import { GestureType } from '../gesture';
|
12
12
|
import { UserSelect, TouchAction } from '../../gestureHandlerCommon';
|
13
13
|
import { ComposedGesture } from '../gestureComposition';
|
14
|
-
import {
|
14
|
+
import { isTestEnv } from '../../../utils';
|
15
15
|
|
16
16
|
import GestureHandlerRootViewContext from '../../../GestureHandlerRootViewContext';
|
17
17
|
import { AttachedGestureState, GestureDetectorState } from './types';
|
@@ -94,7 +94,7 @@ interface GestureDetectorProps {
|
|
94
94
|
*/
|
95
95
|
export const GestureDetector = (props: GestureDetectorProps) => {
|
96
96
|
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
97
|
-
if (__DEV__ && !rootViewContext && !
|
97
|
+
if (__DEV__ && !rootViewContext && !isTestEnv() && Platform.OS !== 'web') {
|
98
98
|
throw new Error(
|
99
99
|
'GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
100
100
|
);
|
@@ -6,7 +6,7 @@ import React, { useCallback } from 'react';
|
|
6
6
|
import findNodeHandle from '../../../findNodeHandle';
|
7
7
|
|
8
8
|
declare const global: {
|
9
|
-
|
9
|
+
isViewFlatteningDisabled: (node: unknown) => boolean | null; // JSI function
|
10
10
|
};
|
11
11
|
|
12
12
|
// Ref handler for the Wrap component attached under the GestureDetector.
|
@@ -35,9 +35,9 @@ export function useViewRefHandler(
|
|
35
35
|
updateAttachedGestures(true);
|
36
36
|
}
|
37
37
|
|
38
|
-
if (__DEV__ && isFabric() && global.
|
38
|
+
if (__DEV__ && isFabric() && global.isViewFlatteningDisabled) {
|
39
39
|
const node = getShadowNodeFromRef(ref);
|
40
|
-
if (global.
|
40
|
+
if (global.isViewFlatteningDisabled(node) === false) {
|
41
41
|
console.error(
|
42
42
|
tagMessage(
|
43
43
|
'GestureDetector has received a child that may get view-flattened. ' +
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Platform } from 'react-native';
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { isTestEnv, tagMessage } from '../../../utils';
|
4
4
|
import { GestureRef, BaseGesture, GestureType } from '../gesture';
|
5
5
|
|
6
6
|
import { flingGestureHandlerProps } from '../../FlingGestureHandler';
|
@@ -100,7 +100,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
|
100
100
|
const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;
|
101
101
|
// If none of the callbacks are worklets and the gesture is not explicitly marked with
|
102
102
|
// `.runOnJS(true)` show a warning
|
103
|
-
if (areAllNotWorklets && !
|
103
|
+
if (areAllNotWorklets && !isTestEnv()) {
|
104
104
|
console.warn(
|
105
105
|
tagMessage(
|
106
106
|
`None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { isTestEnv } from '../utils';
|
2
2
|
import { GestureType } from './gestures/gesture';
|
3
3
|
import { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';
|
4
4
|
|
@@ -13,7 +13,7 @@ export function registerHandler(
|
|
13
13
|
testID?: string
|
14
14
|
) {
|
15
15
|
gestures.set(handlerTag, handler);
|
16
|
-
if (
|
16
|
+
if (isTestEnv() && testID) {
|
17
17
|
testIDs.set(testID, handlerTag);
|
18
18
|
}
|
19
19
|
}
|
@@ -25,9 +25,13 @@ export function registerOldGestureHandler(
|
|
25
25
|
oldHandlers.set(handlerTag, handler);
|
26
26
|
}
|
27
27
|
|
28
|
+
export function unregisterOldGestureHandler(handlerTag: number) {
|
29
|
+
oldHandlers.delete(handlerTag);
|
30
|
+
}
|
31
|
+
|
28
32
|
export function unregisterHandler(handlerTag: number, testID?: string) {
|
29
33
|
gestures.delete(handlerTag);
|
30
|
-
if (
|
34
|
+
if (isTestEnv() && testID) {
|
31
35
|
testIDs.delete(testID);
|
32
36
|
}
|
33
37
|
}
|
package/src/index.ts
CHANGED
@@ -145,7 +145,10 @@ export type {
|
|
145
145
|
|
146
146
|
export type { SwipeableProps } from './components/Swipeable';
|
147
147
|
export { default as Swipeable } from './components/Swipeable';
|
148
|
-
export type {
|
148
|
+
export type {
|
149
|
+
PressableProps,
|
150
|
+
PressableStateCallbackType,
|
151
|
+
} from './components/Pressable';
|
149
152
|
export { default as Pressable } from './components/Pressable';
|
150
153
|
|
151
154
|
export type {
|
package/src/utils.ts
CHANGED
@@ -34,9 +34,9 @@ export function hasProperty(object: object, key: string) {
|
|
34
34
|
return Object.prototype.hasOwnProperty.call(object, key);
|
35
35
|
}
|
36
36
|
|
37
|
-
export function
|
37
|
+
export function isTestEnv(): boolean {
|
38
38
|
// @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.
|
39
|
-
return hasProperty(global, 'process') &&
|
39
|
+
return hasProperty(global, 'process') && process.env.NODE_ENV === 'test';
|
40
40
|
}
|
41
41
|
|
42
42
|
export function tagMessage(msg: string) {
|
@@ -18,10 +18,10 @@ export default class RotationGestureDetector
|
|
18
18
|
private previousTime = 0;
|
19
19
|
|
20
20
|
private previousAngle = 0;
|
21
|
-
private
|
21
|
+
private _rotation = 0;
|
22
22
|
|
23
|
-
private
|
24
|
-
private
|
23
|
+
private _anchorX = 0;
|
24
|
+
private _anchorY = 0;
|
25
25
|
|
26
26
|
private isInProgress = false;
|
27
27
|
|
@@ -45,28 +45,28 @@ export default class RotationGestureDetector
|
|
45
45
|
const vectorX: number = secondPointerCoords.x - firstPointerCoords.x;
|
46
46
|
const vectorY: number = secondPointerCoords.y - firstPointerCoords.y;
|
47
47
|
|
48
|
-
this.
|
49
|
-
this.
|
48
|
+
this._anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
|
49
|
+
this._anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;
|
50
50
|
|
51
51
|
// Angle diff should be positive when rotating in clockwise direction
|
52
52
|
const angle: number = -Math.atan2(vectorY, vectorX);
|
53
53
|
|
54
|
-
this.
|
54
|
+
this._rotation = Number.isNaN(this.previousAngle)
|
55
55
|
? 0
|
56
56
|
: this.previousAngle - angle;
|
57
57
|
|
58
58
|
this.previousAngle = angle;
|
59
59
|
|
60
60
|
if (this.rotation > Math.PI) {
|
61
|
-
this.
|
61
|
+
this._rotation -= Math.PI;
|
62
62
|
} else if (this.rotation < -Math.PI) {
|
63
|
-
this.
|
63
|
+
this._rotation += Math.PI;
|
64
64
|
}
|
65
65
|
|
66
66
|
if (this.rotation > Math.PI / 2) {
|
67
|
-
this.
|
67
|
+
this._rotation -= Math.PI;
|
68
68
|
} else if (this.rotation < -Math.PI / 2) {
|
69
|
-
this.
|
69
|
+
this._rotation += Math.PI;
|
70
70
|
}
|
71
71
|
}
|
72
72
|
|
@@ -85,7 +85,7 @@ export default class RotationGestureDetector
|
|
85
85
|
return;
|
86
86
|
}
|
87
87
|
|
88
|
-
const pointerIDs: IterableIterator<number> = tracker.
|
88
|
+
const pointerIDs: IterableIterator<number> = tracker.trackedPointers.keys();
|
89
89
|
|
90
90
|
this.keyPointers[0] = pointerIDs.next().value as number;
|
91
91
|
this.keyPointers[1] = pointerIDs.next().value as number;
|
@@ -143,24 +143,24 @@ export default class RotationGestureDetector
|
|
143
143
|
return true;
|
144
144
|
}
|
145
145
|
|
146
|
-
public
|
147
|
-
|
146
|
+
public reset(): void {
|
147
|
+
this.keyPointers = [NaN, NaN];
|
148
|
+
this.isInProgress = false;
|
148
149
|
}
|
149
150
|
|
150
|
-
public
|
151
|
-
return this.
|
151
|
+
public get anchorX() {
|
152
|
+
return this._anchorX;
|
152
153
|
}
|
153
154
|
|
154
|
-
public
|
155
|
-
return this.
|
155
|
+
public get anchorY() {
|
156
|
+
return this._anchorY;
|
156
157
|
}
|
157
158
|
|
158
|
-
public
|
159
|
-
return this.
|
159
|
+
public get rotation() {
|
160
|
+
return this._rotation;
|
160
161
|
}
|
161
162
|
|
162
|
-
public
|
163
|
-
this.
|
164
|
-
this.isInProgress = false;
|
163
|
+
public get timeDelta() {
|
164
|
+
return this.currentTime + this.previousTime;
|
165
165
|
}
|
166
166
|
}
|
@@ -14,10 +14,10 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
14
14
|
public onScale: (detector: ScaleGestureDetector) => boolean;
|
15
15
|
public onScaleEnd: (detector: ScaleGestureDetector) => void;
|
16
16
|
|
17
|
-
private
|
18
|
-
private
|
17
|
+
private _focusX!: number;
|
18
|
+
private _focusY!: number;
|
19
19
|
|
20
|
-
private
|
20
|
+
private _currentSpan!: number;
|
21
21
|
private prevSpan!: number;
|
22
22
|
private initialSpan!: number;
|
23
23
|
|
@@ -42,7 +42,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
42
42
|
this.currentTime = event.time;
|
43
43
|
|
44
44
|
const action: EventTypes = event.eventType;
|
45
|
-
const numOfPointers = tracker.
|
45
|
+
const numOfPointers = tracker.trackedPointersCount;
|
46
46
|
|
47
47
|
const streamComplete: boolean =
|
48
48
|
action === EventTypes.UP ||
|
@@ -86,7 +86,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
86
86
|
let devSumX = 0;
|
87
87
|
let devSumY = 0;
|
88
88
|
|
89
|
-
tracker.
|
89
|
+
tracker.trackedPointers.forEach((value, key) => {
|
90
90
|
if (key === ignoredPointer) {
|
91
91
|
return;
|
92
92
|
}
|
@@ -105,8 +105,8 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
105
105
|
|
106
106
|
// Begin/end events
|
107
107
|
const wasInProgress: boolean = this.inProgress;
|
108
|
-
this.
|
109
|
-
this.
|
108
|
+
this._focusX = focusX;
|
109
|
+
this._focusY = focusY;
|
110
110
|
|
111
111
|
if (this.inProgress && (span < this.minSpan || configChanged)) {
|
112
112
|
this.onScaleEnd(this);
|
@@ -115,7 +115,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
115
115
|
}
|
116
116
|
|
117
117
|
if (configChanged) {
|
118
|
-
this.initialSpan = this.prevSpan = this.
|
118
|
+
this.initialSpan = this.prevSpan = this._currentSpan = span;
|
119
119
|
}
|
120
120
|
|
121
121
|
if (
|
@@ -123,7 +123,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
123
123
|
span >= this.minSpan &&
|
124
124
|
(wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)
|
125
125
|
) {
|
126
|
-
this.prevSpan = this.
|
126
|
+
this.prevSpan = this._currentSpan = span;
|
127
127
|
this.prevTime = this.currentTime;
|
128
128
|
this.inProgress = this.onScaleBegin(this);
|
129
129
|
}
|
@@ -133,7 +133,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
133
133
|
return true;
|
134
134
|
}
|
135
135
|
|
136
|
-
this.
|
136
|
+
this._currentSpan = span;
|
137
137
|
|
138
138
|
if (this.inProgress && !this.onScale(this)) {
|
139
139
|
return true;
|
@@ -145,27 +145,27 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
145
145
|
return true;
|
146
146
|
}
|
147
147
|
|
148
|
-
public
|
149
|
-
|
150
|
-
|
148
|
+
public calculateScaleFactor(numOfPointers: number): number {
|
149
|
+
if (numOfPointers < 2) {
|
150
|
+
return 1;
|
151
|
+
}
|
151
152
|
|
152
|
-
|
153
|
-
return this.focusX;
|
153
|
+
return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
|
154
154
|
}
|
155
155
|
|
156
|
-
public
|
157
|
-
return this.
|
156
|
+
public get currentSpan() {
|
157
|
+
return this._currentSpan;
|
158
158
|
}
|
159
159
|
|
160
|
-
public
|
161
|
-
return this.
|
160
|
+
public get focusX() {
|
161
|
+
return this._focusX;
|
162
162
|
}
|
163
163
|
|
164
|
-
public
|
165
|
-
|
166
|
-
|
167
|
-
}
|
164
|
+
public get focusY() {
|
165
|
+
return this._focusY;
|
166
|
+
}
|
168
167
|
|
169
|
-
|
168
|
+
public get timeDelta() {
|
169
|
+
return this.currentTime - this.prevTime;
|
170
170
|
}
|
171
171
|
}
|
@@ -121,29 +121,28 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
121
121
|
}
|
122
122
|
|
123
123
|
private newPointerAction(): void {
|
124
|
-
if (this.
|
124
|
+
if (this.state === State.UNDETERMINED) {
|
125
125
|
this.startFling();
|
126
126
|
}
|
127
127
|
|
128
|
-
if (this.
|
128
|
+
if (this.state !== State.BEGAN) {
|
129
129
|
return;
|
130
130
|
}
|
131
131
|
|
132
132
|
this.tryEndFling();
|
133
133
|
|
134
134
|
if (
|
135
|
-
this.tracker.
|
136
|
-
this.maxNumberOfPointersSimultaneously
|
135
|
+
this.tracker.trackedPointersCount > this.maxNumberOfPointersSimultaneously
|
137
136
|
) {
|
138
137
|
this.maxNumberOfPointersSimultaneously =
|
139
|
-
this.tracker.
|
138
|
+
this.tracker.trackedPointersCount;
|
140
139
|
}
|
141
140
|
}
|
142
141
|
|
143
142
|
private pointerMoveAction(event: AdaptedEvent): void {
|
144
143
|
this.tracker.track(event);
|
145
144
|
|
146
|
-
if (this.
|
145
|
+
if (this.state !== State.BEGAN) {
|
147
146
|
return;
|
148
147
|
}
|
149
148
|
|
@@ -173,7 +172,7 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
173
172
|
}
|
174
173
|
|
175
174
|
private onUp(event: AdaptedEvent): void {
|
176
|
-
if (this.
|
175
|
+
if (this.state === State.BEGAN) {
|
177
176
|
this.endFling();
|
178
177
|
}
|
179
178
|
|