react-native-gesture-handler 2.1.3 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +8 -3
- package/RNGestureHandler.podspec +27 -3
- package/android/build.gradle +82 -9
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +47 -12
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +50 -14
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +7 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +8 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +6 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ScaleGestureDetector.java +558 -0
- package/android/src/fabric/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +29 -0
- package/android/src/fabric/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +12 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +29 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +40 -13
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +119 -55
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +9 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +17 -2
- package/android/src/main/jni/Android.mk +53 -0
- package/android/src/main/jni/OnLoad.cpp +9 -0
- package/android/src/main/jni/RNGestureHandlerComponentsRegistry.cpp +71 -0
- package/android/src/main/jni/RNGestureHandlerComponentsRegistry.h +34 -0
- package/android/src/main/jni/cpp-adapter.cpp +41 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +47 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +22 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +25 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +16 -0
- package/android/src/paper/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +13 -0
- package/ios/Handlers/RNFlingHandler.m +2 -0
- package/ios/Handlers/RNPanHandler.m +2 -0
- package/ios/Handlers/RNPinchHandler.m +2 -0
- package/ios/Handlers/RNRotationHandler.m +2 -0
- package/ios/RNGestureHandler.h +3 -8
- package/ios/RNGestureHandler.m +2 -10
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/RNGestureHandlerActionType.h +8 -0
- package/ios/RNGestureHandlerButtonComponentView.h +17 -0
- package/ios/RNGestureHandlerButtonComponentView.mm +48 -0
- package/ios/RNGestureHandlerButtonManager.h +5 -0
- package/ios/RNGestureHandlerButtonManager.m +30 -0
- package/ios/RNGestureHandlerManager.h +2 -4
- package/ios/{RNGestureHandlerManager.m → RNGestureHandlerManager.mm} +92 -20
- package/ios/{RNGestureHandlerModule.m → RNGestureHandlerModule.mm} +91 -36
- package/ios/RNGestureHandlerRegistry.h +1 -2
- package/ios/RNGestureHandlerRegistry.m +2 -11
- package/ios/RNGestureHandlerRootViewComponentView.mm +21 -0
- package/lib/commonjs/ActionType.js +15 -0
- package/lib/commonjs/ActionType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +6 -6
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +2 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +4 -2
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +2 -2
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +5 -2
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +22 -20
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +21 -0
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +21 -0
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.js +24 -0
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
- package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js +4 -2
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +8 -4
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/LongPressGestureHandler.js +4 -2
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +4 -2
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +4 -2
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PinchGestureHandler.js +4 -2
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/RotationGestureHandler.js +4 -2
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/TapGestureHandler.js +4 -2
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +74 -8
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +6 -2
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +84 -32
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +25 -8
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +16 -1
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +7 -4
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +4 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/handlers/handlersRegistry.js +42 -6
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +10 -0
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils.js +375 -0
- package/lib/commonjs/jestUtils.js.map +1 -0
- package/lib/commonjs/utils.js +38 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/ActionType.js +7 -0
- package/lib/module/ActionType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +5 -6
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +2 -3
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -2
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +1 -1
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +2 -2
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +4 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/Swipeable.js +22 -20
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +9 -0
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +9 -0
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.js +17 -0
- package/lib/module/getShadowNodeFromRef.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.web.js +8 -0
- package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/module/handlers/FlingGestureHandler.js +2 -1
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js +5 -3
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js +2 -1
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +2 -1
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +2 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PinchGestureHandler.js +2 -1
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/handlers/RotationGestureHandler.js +2 -1
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/handlers/TapGestureHandler.js +2 -1
- package/lib/module/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +74 -9
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/createNativeWrapper.js +6 -2
- package/lib/module/handlers/createNativeWrapper.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +79 -32
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +25 -7
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +16 -1
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +6 -4
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js +2 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/handlers/handlersRegistry.js +34 -6
- package/lib/module/handlers/handlersRegistry.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +6 -0
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils.js +350 -0
- package/lib/module/jestUtils.js.map +1 -0
- package/lib/module/utils.js +28 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +7 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +5 -2
- package/lib/typescript/GestureHandlerRootView.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +3 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerButton.d.ts +2 -2
- package/lib/typescript/components/Swipeable.d.ts +12 -4
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +3 -2
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +3 -2
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +2 -4
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +4 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -2
- package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -2
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -2
- package/lib/typescript/handlers/handlersRegistry.d.ts +10 -2
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/jestUtils.d.ts +28 -0
- package/lib/typescript/utils.d.ts +6 -0
- package/package.json +39 -16
- package/src/ActionType.ts +9 -0
- package/src/GestureHandlerRootView.android.tsx +14 -14
- package/src/GestureHandlerRootView.tsx +4 -4
- package/src/RNGestureHandlerModule.ts +11 -6
- package/src/RNGestureHandlerModule.web.ts +2 -1
- package/src/components/DrawerLayout.tsx +8 -2
- package/src/components/GestureHandlerButton.tsx +7 -4
- package/src/components/Swipeable.tsx +28 -22
- package/src/fabric/RNGestureHandlerButtonNativeComponent.js +27 -0
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +19 -0
- package/src/getShadowNodeFromRef.ts +19 -0
- package/src/getShadowNodeFromRef.web.ts +7 -0
- package/src/handlers/FlingGestureHandler.ts +3 -1
- package/src/handlers/ForceTouchGestureHandler.ts +8 -2
- package/src/handlers/LongPressGestureHandler.ts +5 -3
- package/src/handlers/NativeViewGestureHandler.ts +3 -1
- package/src/handlers/PanGestureHandler.ts +5 -3
- package/src/handlers/PinchGestureHandler.ts +3 -1
- package/src/handlers/RotationGestureHandler.ts +3 -1
- package/src/handlers/TapGestureHandler.ts +3 -1
- package/src/handlers/createHandler.ts +80 -5
- package/src/handlers/createNativeWrapper.tsx +7 -1
- package/src/handlers/gestureHandlerCommon.ts +2 -5
- package/src/handlers/gestures/GestureDetector.tsx +110 -37
- package/src/handlers/gestures/eventReceiver.ts +23 -19
- package/src/handlers/gestures/forceTouchGesture.ts +1 -1
- package/src/handlers/gestures/gesture.ts +21 -1
- package/src/handlers/gestures/gestureStateManager.ts +9 -12
- package/src/handlers/gestures/panGesture.ts +1 -1
- package/src/handlers/gestures/pinchGesture.ts +1 -1
- package/src/handlers/gestures/reanimatedWrapper.ts +4 -1
- package/src/handlers/handlersRegistry.ts +44 -6
- package/src/index.ts +4 -0
- package/src/init.ts +6 -0
- package/src/jestUtils.ts +506 -0
- package/src/utils.ts +38 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +0 -18
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +0 -17
@@ -0,0 +1,7 @@
|
|
1
|
+
// Used by GestureDetector (unsupported on web at the moment) to check whether the
|
2
|
+
// attached view may get flattened on Fabric. Original implementation causes errors
|
3
|
+
// on web due to the static resolution of `require` statements by webpack breaking
|
4
|
+
// the conditional importing.
|
5
|
+
export function getShadowNodeFromRef(_ref: any) {
|
6
|
+
return null;
|
7
|
+
}
|
@@ -42,13 +42,15 @@ export interface FlingGestureHandlerProps
|
|
42
42
|
extends BaseGestureHandlerProps<FlingGestureHandlerEventPayload>,
|
43
43
|
FlingGestureConfig {}
|
44
44
|
|
45
|
+
export const flingHandlerName = 'FlingGestureHandler';
|
46
|
+
|
45
47
|
export type FlingGestureHandler = typeof FlingGestureHandler;
|
46
48
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
47
49
|
export const FlingGestureHandler = createHandler<
|
48
50
|
FlingGestureHandlerProps,
|
49
51
|
FlingGestureHandlerEventPayload
|
50
52
|
>({
|
51
|
-
name:
|
53
|
+
name: flingHandlerName,
|
52
54
|
allowedProps: [
|
53
55
|
...baseGestureHandlerProps,
|
54
56
|
...flingGestureHandlerProps,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { tagMessage } from '../utils';
|
2
3
|
import PlatformConstants from '../PlatformConstants';
|
3
4
|
import createHandler from './createHandler';
|
4
5
|
import {
|
@@ -16,7 +17,9 @@ class ForceTouchFallback extends React.Component {
|
|
16
17
|
static forceTouchAvailable = false;
|
17
18
|
componentDidMount() {
|
18
19
|
console.warn(
|
19
|
-
|
20
|
+
tagMessage(
|
21
|
+
'ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'
|
22
|
+
)
|
20
23
|
);
|
21
24
|
}
|
22
25
|
render() {
|
@@ -64,13 +67,16 @@ export interface ForceTouchGestureHandlerProps
|
|
64
67
|
export type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {
|
65
68
|
forceTouchAvailable: boolean;
|
66
69
|
};
|
70
|
+
|
71
|
+
export const forceTouchHandlerName = 'ForceTouchGestureHandler';
|
72
|
+
|
67
73
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
68
74
|
export const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable
|
69
75
|
? createHandler<
|
70
76
|
ForceTouchGestureHandlerProps,
|
71
77
|
ForceTouchGestureHandlerEventPayload
|
72
78
|
>({
|
73
|
-
name:
|
79
|
+
name: forceTouchHandlerName,
|
74
80
|
allowedProps: [
|
75
81
|
...baseGestureHandlerProps,
|
76
82
|
...forceTouchGestureHandlerProps,
|
@@ -27,7 +27,7 @@ export type LongPressGestureHandlerEventPayload = {
|
|
27
27
|
/**
|
28
28
|
* X coordinate, expressed in points, of the current position of the pointer
|
29
29
|
* (finger or a leading pointer when there are multiple fingers placed)
|
30
|
-
* relative to the
|
30
|
+
* relative to the window. It is recommended to use `absoluteX` instead of
|
31
31
|
* `x` in cases when the view attached to the handler can be transformed as an
|
32
32
|
* effect of the gesture.
|
33
33
|
*/
|
@@ -36,7 +36,7 @@ export type LongPressGestureHandlerEventPayload = {
|
|
36
36
|
/**
|
37
37
|
* Y coordinate, expressed in points, of the current position of the pointer
|
38
38
|
* (finger or a leading pointer when there are multiple fingers placed)
|
39
|
-
* relative to the
|
39
|
+
* relative to the window. It is recommended to use `absoluteY` instead of
|
40
40
|
* `y` in cases when the view attached to the handler can be transformed as an
|
41
41
|
* effect of the gesture.
|
42
42
|
*/
|
@@ -69,13 +69,15 @@ export interface LongPressGestureHandlerProps
|
|
69
69
|
extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,
|
70
70
|
LongPressGestureConfig {}
|
71
71
|
|
72
|
+
export const longPressHandlerName = 'LongPressGestureHandler';
|
73
|
+
|
72
74
|
export type LongPressGestureHandler = typeof LongPressGestureHandler;
|
73
75
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
74
76
|
export const LongPressGestureHandler = createHandler<
|
75
77
|
LongPressGestureHandlerProps,
|
76
78
|
LongPressGestureHandlerEventPayload
|
77
79
|
>({
|
78
|
-
name:
|
80
|
+
name: longPressHandlerName,
|
79
81
|
allowedProps: [
|
80
82
|
...baseGestureHandlerProps,
|
81
83
|
...longPressGestureHandlerProps,
|
@@ -41,13 +41,15 @@ export const nativeViewProps = [
|
|
41
41
|
...nativeViewGestureHandlerProps,
|
42
42
|
] as const;
|
43
43
|
|
44
|
+
export const nativeViewHandlerName = 'NativeViewGestureHandler';
|
45
|
+
|
44
46
|
export type NativeViewGestureHandler = typeof NativeViewGestureHandler;
|
45
47
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
46
48
|
export const NativeViewGestureHandler = createHandler<
|
47
49
|
NativeViewGestureHandlerProps,
|
48
50
|
NativeViewGestureHandlerPayload
|
49
51
|
>({
|
50
|
-
name:
|
52
|
+
name: nativeViewHandlerName,
|
51
53
|
allowedProps: nativeViewProps,
|
52
54
|
config: {},
|
53
55
|
});
|
@@ -47,7 +47,7 @@ export type PanGestureHandlerEventPayload = {
|
|
47
47
|
|
48
48
|
/**
|
49
49
|
* X coordinate of the current position of the pointer (finger or a leading
|
50
|
-
* pointer when there are multiple fingers placed) relative to the
|
50
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
51
51
|
* The value is expressed in point units. It is recommended to use it instead
|
52
52
|
* of `x` in cases when the original view can be transformed as an effect of
|
53
53
|
* the gesture.
|
@@ -56,7 +56,7 @@ export type PanGestureHandlerEventPayload = {
|
|
56
56
|
|
57
57
|
/**
|
58
58
|
* Y coordinate of the current position of the pointer (finger or a leading
|
59
|
-
* pointer when there are multiple fingers placed) relative to the
|
59
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
60
60
|
* The value is expressed in point units. It is recommended to use it instead
|
61
61
|
* of `y` in cases when the original view can be transformed as an
|
62
62
|
* effect of the gesture.
|
@@ -181,13 +181,15 @@ export interface PanGestureHandlerProps
|
|
181
181
|
failOffsetX?: number | number[];
|
182
182
|
}
|
183
183
|
|
184
|
+
export const panHandlerName = 'PanGestureHandler';
|
185
|
+
|
184
186
|
export type PanGestureHandler = typeof PanGestureHandler;
|
185
187
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
186
188
|
export const PanGestureHandler = createHandler<
|
187
189
|
PanGestureHandlerProps,
|
188
190
|
PanGestureHandlerEventPayload
|
189
191
|
>({
|
190
|
-
name:
|
192
|
+
name: panHandlerName,
|
191
193
|
allowedProps: [
|
192
194
|
...baseGestureHandlerProps,
|
193
195
|
...panGestureHandlerProps,
|
@@ -34,13 +34,15 @@ export type PinchGestureHandlerEventPayload = {
|
|
34
34
|
export interface PinchGestureHandlerProps
|
35
35
|
extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}
|
36
36
|
|
37
|
+
export const pinchHandlerName = 'PinchGestureHandler';
|
38
|
+
|
37
39
|
export type PinchGestureHandler = typeof PinchGestureHandler;
|
38
40
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
39
41
|
export const PinchGestureHandler = createHandler<
|
40
42
|
PinchGestureHandlerProps,
|
41
43
|
PinchGestureHandlerEventPayload
|
42
44
|
>({
|
43
|
-
name:
|
45
|
+
name: pinchHandlerName,
|
44
46
|
allowedProps: baseGestureHandlerProps,
|
45
47
|
config: {},
|
46
48
|
});
|
@@ -34,13 +34,15 @@ export type RotationGestureHandlerEventPayload = {
|
|
34
34
|
export interface RotationGestureHandlerProps
|
35
35
|
extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}
|
36
36
|
|
37
|
+
export const rotationHandlerName = 'RotationGestureHandler';
|
38
|
+
|
37
39
|
export type RotationGestureHandler = typeof RotationGestureHandler;
|
38
40
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
39
41
|
export const RotationGestureHandler = createHandler<
|
40
42
|
RotationGestureHandlerProps,
|
41
43
|
RotationGestureHandlerEventPayload
|
42
44
|
>({
|
43
|
-
name:
|
45
|
+
name: rotationHandlerName,
|
44
46
|
allowedProps: baseGestureHandlerProps,
|
45
47
|
config: {},
|
46
48
|
});
|
@@ -75,13 +75,15 @@ export interface TapGestureHandlerProps
|
|
75
75
|
extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,
|
76
76
|
TapGestureConfig {}
|
77
77
|
|
78
|
+
export const tapHandlerName = 'TapGestureHandler';
|
79
|
+
|
78
80
|
export type TapGestureHandler = typeof TapGestureHandler;
|
79
81
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
80
82
|
export const TapGestureHandler = createHandler<
|
81
83
|
TapGestureHandlerProps,
|
82
84
|
TapGestureHandlerEventPayload
|
83
85
|
>({
|
84
|
-
name:
|
86
|
+
name: tapHandlerName,
|
85
87
|
allowedProps: [
|
86
88
|
...baseGestureHandlerProps,
|
87
89
|
...tapGestureHandlerProps,
|
@@ -11,7 +11,11 @@ import deepEqual from 'lodash/isEqual';
|
|
11
11
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
12
12
|
import type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';
|
13
13
|
import { State } from '../State';
|
14
|
-
import {
|
14
|
+
import {
|
15
|
+
handlerIDToTag,
|
16
|
+
getNextHandlerTag,
|
17
|
+
registerOldGestureHandler,
|
18
|
+
} from './handlersRegistry';
|
15
19
|
|
16
20
|
import {
|
17
21
|
BaseGestureHandlerProps,
|
@@ -21,14 +25,35 @@ import {
|
|
21
25
|
findNodeHandle,
|
22
26
|
} from './gestureHandlerCommon';
|
23
27
|
import { ValueOf } from '../typeUtils';
|
28
|
+
import { isFabric, isJestEnv, tagMessage } from '../utils';
|
29
|
+
import { ActionType } from '../ActionType';
|
24
30
|
|
25
31
|
const UIManagerAny = UIManager as any;
|
26
32
|
|
33
|
+
const customGHEventsConfigFabricAndroid = {
|
34
|
+
topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
|
35
|
+
topOnGestureHandlerStateChange: {
|
36
|
+
registrationName: 'onGestureHandlerStateChange',
|
37
|
+
},
|
38
|
+
};
|
39
|
+
|
27
40
|
const customGHEventsConfig = {
|
28
41
|
onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
|
29
42
|
onGestureHandlerStateChange: {
|
30
43
|
registrationName: 'onGestureHandlerStateChange',
|
31
44
|
},
|
45
|
+
|
46
|
+
// When using React Native Gesture Handler for Animated.event with useNativeDriver: true
|
47
|
+
// on Android with Fabric enabled, the native part still sends the native events to JS
|
48
|
+
// but prefixed with "top". We cannot simply rename the events above so they are prefixed
|
49
|
+
// with "top" instead of "on" because in such case Animated.events would not be registered.
|
50
|
+
// That's why we need to register another pair of event names.
|
51
|
+
// The incoming events will be queued but never handled.
|
52
|
+
// Without this piece of code below, you'll get the following JS error:
|
53
|
+
// Unsupported top level event type "topOnGestureHandlerEvent" dispatched
|
54
|
+
...(isFabric() &&
|
55
|
+
Platform.OS === 'android' &&
|
56
|
+
customGHEventsConfigFabricAndroid),
|
32
57
|
};
|
33
58
|
|
34
59
|
// Add gesture specific events to genericDirectEventTypes object exported from UIManager
|
@@ -122,6 +147,18 @@ type InternalEventHandlers = {
|
|
122
147
|
onGestureHandlerStateChange?: (event: any) => void;
|
123
148
|
};
|
124
149
|
|
150
|
+
let showedRngh2Notice = false;
|
151
|
+
function showRngh2NoticeIfNeeded() {
|
152
|
+
if (!showedRngh2Notice) {
|
153
|
+
console.warn(
|
154
|
+
tagMessage(
|
155
|
+
"Seems like you're using an old API with gesture components, check out new Gestures system!"
|
156
|
+
)
|
157
|
+
);
|
158
|
+
showedRngh2Notice = true;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
125
162
|
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
126
163
|
export default function createHandler<
|
127
164
|
T extends BaseGestureHandlerProps<U>,
|
@@ -162,6 +199,9 @@ export default function createHandler<
|
|
162
199
|
}
|
163
200
|
handlerIDToTag[props.id] = this.handlerTag;
|
164
201
|
}
|
202
|
+
if (__DEV__ && !isJestEnv()) {
|
203
|
+
showRngh2NoticeIfNeeded();
|
204
|
+
}
|
165
205
|
}
|
166
206
|
|
167
207
|
componentDidMount() {
|
@@ -224,7 +264,9 @@ export default function createHandler<
|
|
224
264
|
|
225
265
|
private onGestureHandlerEvent = (event: GestureEvent<U>) => {
|
226
266
|
if (event.nativeEvent.handlerTag === this.handlerTag) {
|
227
|
-
this.props.onGestureEvent
|
267
|
+
if (typeof this.props.onGestureEvent === 'function') {
|
268
|
+
this.props.onGestureEvent?.(event);
|
269
|
+
}
|
228
270
|
} else {
|
229
271
|
this.props.onGestureHandlerEvent?.(event);
|
230
272
|
}
|
@@ -235,7 +277,9 @@ export default function createHandler<
|
|
235
277
|
event: HandlerStateChangeEvent<U>
|
236
278
|
) => {
|
237
279
|
if (event.nativeEvent.handlerTag === this.handlerTag) {
|
238
|
-
this.props.onHandlerStateChange
|
280
|
+
if (typeof this.props.onHandlerStateChange === 'function') {
|
281
|
+
this.props.onHandlerStateChange?.(event);
|
282
|
+
}
|
239
283
|
|
240
284
|
const state: ValueOf<typeof State> = event.nativeEvent.state;
|
241
285
|
const stateEventName = stateToPropMappings[state];
|
@@ -283,14 +327,38 @@ export default function createHandler<
|
|
283
327
|
(RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(
|
284
328
|
this.handlerTag,
|
285
329
|
newViewTag,
|
286
|
-
|
330
|
+
ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
287
331
|
this.propsRef
|
288
332
|
);
|
289
333
|
} else {
|
334
|
+
registerOldGestureHandler(this.handlerTag, {
|
335
|
+
onGestureEvent: this.onGestureHandlerEvent,
|
336
|
+
onGestureStateChange: this.onGestureHandlerStateChange,
|
337
|
+
});
|
338
|
+
|
339
|
+
const actionType = (() => {
|
340
|
+
if (
|
341
|
+
this.props?.onGestureEvent &&
|
342
|
+
'current' in this.props.onGestureEvent
|
343
|
+
) {
|
344
|
+
// Reanimated worklet
|
345
|
+
return ActionType.REANIMATED_WORKLET;
|
346
|
+
} else if (
|
347
|
+
this.props?.onGestureEvent &&
|
348
|
+
'__isNative' in this.props.onGestureEvent
|
349
|
+
) {
|
350
|
+
// Animated.event with useNativeDriver: true
|
351
|
+
return ActionType.NATIVE_ANIMATED_EVENT;
|
352
|
+
} else {
|
353
|
+
// JS callback or Animated.event with useNativeDriver: false
|
354
|
+
return ActionType.JS_FUNCTION_OLD_API;
|
355
|
+
}
|
356
|
+
})();
|
357
|
+
|
290
358
|
RNGestureHandlerModule.attachGestureHandler(
|
291
359
|
this.handlerTag,
|
292
360
|
newViewTag,
|
293
|
-
|
361
|
+
actionType
|
294
362
|
);
|
295
363
|
}
|
296
364
|
};
|
@@ -420,6 +488,13 @@ export default function createHandler<
|
|
420
488
|
{
|
421
489
|
ref: this.refHandler,
|
422
490
|
collapsable: false,
|
491
|
+
...(isJestEnv()
|
492
|
+
? {
|
493
|
+
handlerType: name,
|
494
|
+
handlerTag: this.handlerTag,
|
495
|
+
}
|
496
|
+
: {}),
|
497
|
+
testID: this.props.testID ?? child.props.testID,
|
423
498
|
...events,
|
424
499
|
},
|
425
500
|
grandChildren
|
@@ -68,7 +68,13 @@ export default function createNativeWrapper<P>(
|
|
68
68
|
);
|
69
69
|
});
|
70
70
|
|
71
|
-
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
72
|
+
ComponentWrapper.displayName =
|
73
|
+
Component?.displayName ||
|
74
|
+
// @ts-ignore if render doesn't exist it will return undefined and go further
|
75
|
+
Component?.render?.name ||
|
76
|
+
(typeof Component === 'string' && Component) ||
|
77
|
+
'ComponentWrapper';
|
72
78
|
|
73
79
|
return ComponentWrapper;
|
74
80
|
}
|
@@ -43,11 +43,7 @@ export interface GestureEventPayload {
|
|
43
43
|
numberOfPointers: number;
|
44
44
|
state: ValueOf<typeof State>;
|
45
45
|
}
|
46
|
-
|
47
|
-
export interface HandlerStateChangeEventPayload {
|
48
|
-
handlerTag: number;
|
49
|
-
numberOfPointers: number;
|
50
|
-
state: ValueOf<typeof State>;
|
46
|
+
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
51
47
|
oldState: ValueOf<typeof State>;
|
52
48
|
}
|
53
49
|
|
@@ -114,6 +110,7 @@ export type BaseGestureHandlerProps<
|
|
114
110
|
id?: string;
|
115
111
|
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
116
112
|
simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
|
113
|
+
testID?: string;
|
117
114
|
// TODO(TS) - fix event types
|
118
115
|
onBegan?: (event: HandlerStateChangeEvent) => void;
|
119
116
|
onFailed?: (event: HandlerStateChangeEvent) => void;
|