react-native-gesture-handler 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/RNGestureHandler.podspec +27 -3
- package/android/build.gradle +81 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +5 -1
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +14 -12
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +2 -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 +29 -10
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +111 -47
- 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/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 +61 -9
- 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 +60 -10
- 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 +2 -1
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
- 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 +11 -3
- 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/lib/typescript/web/constants.d.ts +0 -1
- 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 +3 -1
- package/src/handlers/NativeViewGestureHandler.ts +3 -1
- package/src/handlers/PanGestureHandler.ts +3 -1
- 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 +69 -7
- 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
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
@@ -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,
|
@@ -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
|
});
|
@@ -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
|
@@ -126,7 +151,9 @@ let showedRngh2Notice = false;
|
|
126
151
|
function showRngh2NoticeIfNeeded() {
|
127
152
|
if (!showedRngh2Notice) {
|
128
153
|
console.warn(
|
129
|
-
|
154
|
+
tagMessage(
|
155
|
+
"Seems like you're using an old API with gesture components, check out new Gestures system!"
|
156
|
+
)
|
130
157
|
);
|
131
158
|
showedRngh2Notice = true;
|
132
159
|
}
|
@@ -172,7 +199,7 @@ export default function createHandler<
|
|
172
199
|
}
|
173
200
|
handlerIDToTag[props.id] = this.handlerTag;
|
174
201
|
}
|
175
|
-
if (__DEV__) {
|
202
|
+
if (__DEV__ && !isJestEnv()) {
|
176
203
|
showRngh2NoticeIfNeeded();
|
177
204
|
}
|
178
205
|
}
|
@@ -237,7 +264,9 @@ export default function createHandler<
|
|
237
264
|
|
238
265
|
private onGestureHandlerEvent = (event: GestureEvent<U>) => {
|
239
266
|
if (event.nativeEvent.handlerTag === this.handlerTag) {
|
240
|
-
this.props.onGestureEvent
|
267
|
+
if (typeof this.props.onGestureEvent === 'function') {
|
268
|
+
this.props.onGestureEvent?.(event);
|
269
|
+
}
|
241
270
|
} else {
|
242
271
|
this.props.onGestureHandlerEvent?.(event);
|
243
272
|
}
|
@@ -248,7 +277,9 @@ export default function createHandler<
|
|
248
277
|
event: HandlerStateChangeEvent<U>
|
249
278
|
) => {
|
250
279
|
if (event.nativeEvent.handlerTag === this.handlerTag) {
|
251
|
-
this.props.onHandlerStateChange
|
280
|
+
if (typeof this.props.onHandlerStateChange === 'function') {
|
281
|
+
this.props.onHandlerStateChange?.(event);
|
282
|
+
}
|
252
283
|
|
253
284
|
const state: ValueOf<typeof State> = event.nativeEvent.state;
|
254
285
|
const stateEventName = stateToPropMappings[state];
|
@@ -296,14 +327,38 @@ export default function createHandler<
|
|
296
327
|
(RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(
|
297
328
|
this.handlerTag,
|
298
329
|
newViewTag,
|
299
|
-
|
330
|
+
ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
300
331
|
this.propsRef
|
301
332
|
);
|
302
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
|
+
|
303
358
|
RNGestureHandlerModule.attachGestureHandler(
|
304
359
|
this.handlerTag,
|
305
360
|
newViewTag,
|
306
|
-
|
361
|
+
actionType
|
307
362
|
);
|
308
363
|
}
|
309
364
|
};
|
@@ -433,6 +488,13 @@ export default function createHandler<
|
|
433
488
|
{
|
434
489
|
ref: this.refHandler,
|
435
490
|
collapsable: false,
|
491
|
+
...(isJestEnv()
|
492
|
+
? {
|
493
|
+
handlerType: name,
|
494
|
+
handlerTag: this.handlerTag,
|
495
|
+
}
|
496
|
+
: {}),
|
497
|
+
testID: this.props.testID,
|
436
498
|
...events,
|
437
499
|
},
|
438
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;
|
@@ -32,6 +32,13 @@ import { tapGestureHandlerProps } from '../TapGestureHandler';
|
|
32
32
|
import { State } from '../../State';
|
33
33
|
import { EventType } from '../../EventType';
|
34
34
|
import { ComposedGesture } from './gestureComposition';
|
35
|
+
import { ActionType } from '../../ActionType';
|
36
|
+
import { isFabric, tagMessage } from '../../utils';
|
37
|
+
import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
|
38
|
+
|
39
|
+
declare global {
|
40
|
+
function isFormsStackingContext(node: unknown): boolean | null; // JSI function
|
41
|
+
}
|
35
42
|
|
36
43
|
const ALLOWED_PROPS = [
|
37
44
|
...baseGestureHandlerWithMonitorProps,
|
@@ -50,7 +57,7 @@ export type GestureConfigReference = {
|
|
50
57
|
HandlerCallbacks<Record<string, unknown>>[] | null
|
51
58
|
> | null;
|
52
59
|
firstExecution: boolean;
|
53
|
-
|
60
|
+
useReanimatedHook: boolean;
|
54
61
|
};
|
55
62
|
|
56
63
|
function convertToHandlerTag(ref: GestureRef): number {
|
@@ -75,7 +82,28 @@ function dropHandlers(preparedGesture: GestureConfigReference) {
|
|
75
82
|
for (const handler of preparedGesture.config) {
|
76
83
|
RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
|
77
84
|
|
78
|
-
unregisterHandler(handler.handlerTag);
|
85
|
+
unregisterHandler(handler.handlerTag, handler.config.testId);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
90
|
+
// if a gesture is explicitly marked to run on the JS thread there is no need to check
|
91
|
+
// if callbacks are worklets as the user is aware they will be ran on the JS thread
|
92
|
+
if (gesture.config.runOnJS) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
|
97
|
+
const areSomeWorklets = gesture.handlers.isWorklet.includes(true);
|
98
|
+
|
99
|
+
// if some of the callbacks are worklets and some are not, and the gesture is not
|
100
|
+
// explicitly marked with `.runOnJS(true)` show an error
|
101
|
+
if (areSomeNotWorklets && areSomeWorklets) {
|
102
|
+
console.error(
|
103
|
+
tagMessage(
|
104
|
+
`Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`
|
105
|
+
)
|
106
|
+
);
|
79
107
|
}
|
80
108
|
}
|
81
109
|
|
@@ -84,7 +112,6 @@ interface AttachHandlersConfig {
|
|
84
112
|
gestureConfig: ComposedGesture | GestureType | undefined;
|
85
113
|
gesture: GestureType[];
|
86
114
|
viewTag: number;
|
87
|
-
useAnimated: boolean;
|
88
115
|
}
|
89
116
|
|
90
117
|
function attachHandlers({
|
@@ -92,7 +119,6 @@ function attachHandlers({
|
|
92
119
|
gestureConfig,
|
93
120
|
gesture,
|
94
121
|
viewTag,
|
95
|
-
useAnimated,
|
96
122
|
}: AttachHandlersConfig) {
|
97
123
|
if (!preparedGesture.firstExecution) {
|
98
124
|
gestureConfig?.initialize();
|
@@ -107,13 +133,15 @@ function attachHandlers({
|
|
107
133
|
});
|
108
134
|
|
109
135
|
for (const handler of gesture) {
|
136
|
+
checkGestureCallbacksForWorklets(handler);
|
137
|
+
|
110
138
|
RNGestureHandlerModule.createGestureHandler(
|
111
139
|
handler.handlerName,
|
112
140
|
handler.handlerTag,
|
113
141
|
filterConfig(handler.config, ALLOWED_PROPS)
|
114
142
|
);
|
115
143
|
|
116
|
-
registerHandler(handler.handlerTag, handler);
|
144
|
+
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
117
145
|
|
118
146
|
// use setImmediate to extract handlerTags, because all refs should be initialized
|
119
147
|
// when it's ran
|
@@ -142,17 +170,25 @@ function attachHandlers({
|
|
142
170
|
preparedGesture.config = gesture;
|
143
171
|
|
144
172
|
for (const gesture of preparedGesture.config) {
|
173
|
+
const actionType = gesture.shouldUseReanimated
|
174
|
+
? ActionType.REANIMATED_WORKLET
|
175
|
+
: ActionType.JS_FUNCTION_NEW_API;
|
176
|
+
|
145
177
|
RNGestureHandlerModule.attachGestureHandler(
|
146
178
|
gesture.handlerTag,
|
147
179
|
viewTag,
|
148
|
-
|
180
|
+
actionType
|
149
181
|
);
|
150
182
|
}
|
151
183
|
|
152
184
|
if (preparedGesture.animatedHandlers) {
|
153
|
-
|
154
|
-
|
155
|
-
|
185
|
+
const isAnimatedGesture = (g: GestureType) => g.shouldUseReanimated;
|
186
|
+
|
187
|
+
preparedGesture.animatedHandlers.value = (gesture
|
188
|
+
.filter(isAnimatedGesture)
|
189
|
+
.map((g) => g.handlers) as unknown) as HandlerCallbacks<
|
190
|
+
Record<string, unknown>
|
191
|
+
>[];
|
156
192
|
}
|
157
193
|
}
|
158
194
|
|
@@ -165,9 +201,14 @@ function updateHandlers(
|
|
165
201
|
|
166
202
|
for (let i = 0; i < gesture.length; i++) {
|
167
203
|
const handler = preparedGesture.config[i];
|
204
|
+
checkGestureCallbacksForWorklets(handler);
|
168
205
|
|
169
|
-
|
170
|
-
gesture
|
206
|
+
// only update handlerTag when it's actually different, it may be the same
|
207
|
+
// if gesture config object is wrapped with useMemo
|
208
|
+
if (gesture[i].handlerTag !== handler.handlerTag) {
|
209
|
+
gesture[i].handlerTag = handler.handlerTag;
|
210
|
+
gesture[i].handlers.handlerTag = handler.handlerTag;
|
211
|
+
}
|
171
212
|
}
|
172
213
|
|
173
214
|
// use setImmediate to extract handlerTags, because when it's ran, all refs should be updated
|
@@ -179,7 +220,6 @@ function updateHandlers(
|
|
179
220
|
|
180
221
|
handler.config = gesture[i].config;
|
181
222
|
handler.handlers = gesture[i].handlers;
|
182
|
-
handler.handlers.handlerTag = handler.handlerTag;
|
183
223
|
|
184
224
|
const requireToFail = extractValidHandlerTags(
|
185
225
|
handler.config.requireToFail
|
@@ -197,13 +237,15 @@ function updateHandlers(
|
|
197
237
|
})
|
198
238
|
);
|
199
239
|
|
200
|
-
registerHandler(handler.handlerTag, handler);
|
240
|
+
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
201
241
|
}
|
202
242
|
|
203
243
|
if (preparedGesture.animatedHandlers) {
|
204
|
-
preparedGesture.animatedHandlers.value = (preparedGesture.config
|
205
|
-
(g) => g.
|
206
|
-
|
244
|
+
preparedGesture.animatedHandlers.value = (preparedGesture.config
|
245
|
+
.filter((g) => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
|
246
|
+
.map((g) => g.handlers) as unknown) as HandlerCallbacks<
|
247
|
+
Record<string, unknown>
|
248
|
+
>[];
|
207
249
|
}
|
208
250
|
});
|
209
251
|
}
|
@@ -216,7 +258,11 @@ function needsToReattach(
|
|
216
258
|
return true;
|
217
259
|
}
|
218
260
|
for (let i = 0; i < gesture.length; i++) {
|
219
|
-
if (
|
261
|
+
if (
|
262
|
+
gesture[i].handlerName !== preparedGesture.config[i].handlerName ||
|
263
|
+
gesture[i].shouldUseReanimated !==
|
264
|
+
preparedGesture.config[i].shouldUseReanimated
|
265
|
+
) {
|
220
266
|
return true;
|
221
267
|
}
|
222
268
|
}
|
@@ -224,7 +270,10 @@ function needsToReattach(
|
|
224
270
|
return false;
|
225
271
|
}
|
226
272
|
|
227
|
-
function useAnimatedGesture(
|
273
|
+
function useAnimatedGesture(
|
274
|
+
preparedGesture: GestureConfigReference,
|
275
|
+
needsRebuild: boolean
|
276
|
+
) {
|
228
277
|
if (!Reanimated) {
|
229
278
|
return;
|
230
279
|
}
|
@@ -301,7 +350,7 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
301
350
|
// correct handler.
|
302
351
|
handler?.(event, ...args);
|
303
352
|
} else if (handler) {
|
304
|
-
console.warn('Animated gesture callback must be a worklet');
|
353
|
+
console.warn(tagMessage('Animated gesture callback must be a worklet'));
|
305
354
|
}
|
306
355
|
}
|
307
356
|
|
@@ -401,7 +450,7 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
401
450
|
const event = Reanimated.useEvent(
|
402
451
|
callback,
|
403
452
|
['onGestureHandlerStateChange', 'onGestureHandlerEvent'],
|
404
|
-
|
453
|
+
needsRebuild
|
405
454
|
);
|
406
455
|
|
407
456
|
preparedGesture.animatedEventHandler = event;
|
@@ -416,10 +465,7 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
416
465
|
) => {
|
417
466
|
const gestureConfig = props.gesture;
|
418
467
|
const gesture = gestureConfig?.toGestureArray?.() ?? [];
|
419
|
-
const
|
420
|
-
gesture.find((gesture) =>
|
421
|
-
gesture.handlers.isWorklet.reduce((prev, current) => prev || current)
|
422
|
-
) != null;
|
468
|
+
const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);
|
423
469
|
const viewRef = useRef(null);
|
424
470
|
const firstRenderRef = useRef(true);
|
425
471
|
|
@@ -428,24 +474,30 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
428
474
|
animatedEventHandler: null,
|
429
475
|
animatedHandlers: null,
|
430
476
|
firstExecution: true,
|
431
|
-
|
477
|
+
useReanimatedHook: useReanimatedHook,
|
432
478
|
}).current;
|
433
479
|
|
434
|
-
if (
|
480
|
+
if (useReanimatedHook !== preparedGesture.useReanimatedHook) {
|
435
481
|
throw new Error(
|
436
|
-
|
482
|
+
tagMessage(
|
483
|
+
'You cannot change the thread the callbacks are ran on while the app is running'
|
484
|
+
)
|
437
485
|
);
|
438
486
|
}
|
439
487
|
|
488
|
+
// Reanimated event should be rebuilt only when gestures are reattached, otherwise
|
489
|
+
// config update will be enough as all necessary items are stored in shared values anyway
|
490
|
+
const needsToRebuildReanimatedEvent =
|
491
|
+
preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture);
|
492
|
+
|
440
493
|
if (preparedGesture.firstExecution) {
|
441
494
|
gestureConfig?.initialize?.();
|
442
495
|
}
|
443
496
|
|
444
|
-
if (
|
445
|
-
// Whether animatedGesture or gesture is used shouldn't change
|
446
|
-
// during while an app is running
|
497
|
+
if (useReanimatedHook) {
|
498
|
+
// Whether animatedGesture or gesture is used shouldn't change while the app is running
|
447
499
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
448
|
-
useAnimatedGesture(preparedGesture);
|
500
|
+
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
|
449
501
|
}
|
450
502
|
|
451
503
|
useEffect(() => {
|
@@ -456,7 +508,6 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
456
508
|
gestureConfig,
|
457
509
|
gesture,
|
458
510
|
viewTag,
|
459
|
-
useAnimated,
|
460
511
|
});
|
461
512
|
|
462
513
|
return () => {
|
@@ -475,7 +526,6 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
475
526
|
gestureConfig,
|
476
527
|
gesture,
|
477
528
|
viewTag,
|
478
|
-
useAnimated,
|
479
529
|
});
|
480
530
|
} else {
|
481
531
|
updateHandlers(preparedGesture, gestureConfig, gesture);
|
@@ -485,16 +535,40 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
485
535
|
}
|
486
536
|
}, [props]);
|
487
537
|
|
488
|
-
|
538
|
+
const refFunction = (ref: unknown) => {
|
539
|
+
if (ref !== null) {
|
540
|
+
//@ts-ignore Just setting the ref
|
541
|
+
viewRef.current = ref;
|
542
|
+
|
543
|
+
if (isFabric()) {
|
544
|
+
const node = getShadowNodeFromRef(ref);
|
545
|
+
if (global.isFormsStackingContext(node) === false) {
|
546
|
+
setImmediate(() => {
|
547
|
+
// For some weird reason, console.error on iOS delays
|
548
|
+
// the execution of RNGestureHandlerModule.attachGestureHandler,
|
549
|
+
// so that's why we use setImmediate here.
|
550
|
+
console.error(
|
551
|
+
tagMessage(
|
552
|
+
'GestureDetector has received a child that may get view-flattened. ' +
|
553
|
+
'\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'
|
554
|
+
)
|
555
|
+
);
|
556
|
+
});
|
557
|
+
}
|
558
|
+
}
|
559
|
+
}
|
560
|
+
};
|
561
|
+
|
562
|
+
if (useReanimatedHook) {
|
489
563
|
return (
|
490
564
|
<AnimatedWrap
|
491
|
-
ref={
|
565
|
+
ref={refFunction}
|
492
566
|
onGestureHandlerEvent={preparedGesture.animatedEventHandler}>
|
493
567
|
{props.children}
|
494
568
|
</AnimatedWrap>
|
495
569
|
);
|
496
570
|
} else {
|
497
|
-
return <Wrap ref={
|
571
|
+
return <Wrap ref={refFunction}>{props.children}</Wrap>;
|
498
572
|
}
|
499
573
|
};
|
500
574
|
|
@@ -506,7 +580,6 @@ class Wrap extends React.Component<{ onGestureHandlerEvent?: unknown }> {
|
|
506
580
|
// correct viewTag to attach to.
|
507
581
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
508
582
|
const child: any = React.Children.only(this.props.children);
|
509
|
-
|
510
583
|
return React.cloneElement(
|
511
584
|
child,
|
512
585
|
{ collapsable: false },
|