react-native-gesture-handler 1.10.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/android/build.gradle +49 -1
- package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- package/android/gradle.properties +19 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +744 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +596 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +292 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +90 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +81 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
- package/ios/Handlers/RNFlingHandler.m +78 -5
- package/ios/Handlers/RNForceTouchHandler.m +29 -4
- package/ios/Handlers/RNLongPressHandler.m +105 -3
- package/ios/Handlers/RNManualHandler.h +4 -0
- package/ios/Handlers/RNManualHandler.m +73 -0
- package/ios/Handlers/RNNativeViewHandler.m +30 -2
- package/ios/Handlers/RNPanHandler.m +64 -4
- package/ios/Handlers/RNPinchHandler.m +61 -2
- package/ios/Handlers/RNRotationHandler.m +60 -1
- package/ios/Handlers/RNTapHandler.m +55 -8
- package/ios/RNGestureHandler.h +18 -4
- package/ios/RNGestureHandler.m +123 -13
- 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/RNGestureHandlerEvents.h +9 -0
- package/ios/RNGestureHandlerEvents.m +34 -0
- package/ios/RNGestureHandlerManager.h +7 -0
- package/ios/RNGestureHandlerManager.m +62 -34
- package/ios/RNGestureHandlerModule.m +39 -3
- package/ios/RNGestureHandlerPointerTracker.h +25 -0
- package/ios/RNGestureHandlerPointerTracker.m +237 -0
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/RNManualActivationRecognizer.h +10 -0
- package/ios/RNManualActivationRecognizer.m +80 -0
- package/ios/RNRootViewGestureRecognizer.m +1 -1
- package/ios/RNTouchEventType.h +9 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +11 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +41 -37
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +31 -12
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +10 -6
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +65 -84
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +193 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +31 -0
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
- package/lib/commonjs/index.js +40 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +31 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/Errors.js +1 -1
- package/lib/commonjs/web/Errors.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -6
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/NodeManager.js +8 -2
- package/lib/commonjs/web/NodeManager.js.map +1 -1
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +2 -14
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -1
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -1
- package/lib/module/RNGestureHandlerModule.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 +43 -40
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js +29 -11
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/Swipeable.js +9 -6
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -1
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/gestureHandlerRootHOC.js +1 -1
- package/lib/module/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js +10 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js +10 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +106 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -0
- package/lib/module/handlers/PinchGestureHandler.js +9 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/module/handlers/RotationGestureHandler.js +9 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/module/handlers/TapGestureHandler.js +10 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +55 -77
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +402 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +120 -0
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/module/handlers/gestures/flingGesture.js +24 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +175 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +79 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/module/handlers/gestures/longPressGesture.js +24 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/module/handlers/gestures/manualGesture.js +22 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/module/handlers/gestures/nativeGesture.js +24 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/handlers/gestures/panGesture.js +135 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +36 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/module/handlers/gestures/rotationGesture.js +36 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/module/handlers/gestures/tapGesture.js +49 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +16 -0
- package/lib/module/handlers/handlersRegistry.js.map +1 -0
- package/lib/module/index.js +11 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +31 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/Errors.js +1 -1
- package/lib/module/web/Errors.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -6
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/module/web/NodeManager.js +8 -2
- package/lib/module/web/NodeManager.js.map +1 -1
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +50 -1
- package/lib/typescript/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +8 -35
- package/lib/typescript/components/Swipeable.d.ts +73 -6
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
- package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
- package/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
- package/lib/typescript/index.d.ts +29 -2
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +21 -2
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
- package/package.json +8 -5
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/RNGestureHandlerModule.ts +5 -1
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +114 -41
- package/src/components/GestureButtons.tsx +45 -5
- package/src/components/GestureComponents.tsx +47 -41
- package/src/components/Swipeable.tsx +108 -21
- package/src/components/touchables/GenericTouchable.tsx +2 -1
- package/src/components/touchables/TouchableOpacity.tsx +1 -1
- package/src/handlers/FlingGestureHandler.ts +57 -0
- package/src/handlers/ForceTouchGestureHandler.ts +83 -0
- package/src/handlers/LongPressGestureHandler.ts +84 -0
- package/src/handlers/NativeViewGestureHandler.ts +31 -7
- package/src/handlers/PanGestureHandler.ts +321 -0
- package/src/handlers/PinchGestureHandler.ts +46 -0
- package/src/handlers/RotationGestureHandler.ts +46 -0
- package/src/handlers/TapGestureHandler.ts +90 -0
- package/src/handlers/createHandler.ts +67 -79
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +519 -0
- package/src/handlers/gestures/eventReceiver.ts +151 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +74 -0
- package/src/handlers/gestures/gesture.ts +292 -0
- package/src/handlers/gestures/gestureComposition.ts +109 -0
- package/src/handlers/gestures/gestureObjects.ts +79 -0
- package/src/handlers/gestures/gestureStateManager.ts +60 -0
- package/src/handlers/gestures/longPressGesture.ts +27 -0
- package/src/handlers/gestures/manualGesture.ts +31 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +147 -0
- package/src/handlers/gestures/pinchGesture.ts +51 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +51 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +57 -17
- package/src/init.ts +5 -0
- package/src/mocks.ts +42 -2
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +1 -2
- package/src/web/NodeManager.ts +5 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
- package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
- package/lib/commonjs/handlers/gestureHandlers.js +0 -236
- package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
- package/lib/module/handlers/gestureHandlers.js +0 -216
- package/lib/module/handlers/gestureHandlers.js.map +0 -1
- package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
- package/src/handlers/gestureHandlers.ts +0 -511
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import createHandler from './createHandler';
|
|
2
|
+
import {
|
|
3
|
+
BaseGestureHandlerProps,
|
|
4
|
+
baseGestureHandlerProps,
|
|
5
|
+
} from './gestureHandlerCommon';
|
|
6
|
+
|
|
7
|
+
export type RotationGestureHandlerEventPayload = {
|
|
8
|
+
/**
|
|
9
|
+
* Amount rotated, expressed in radians, from the gesture's focal point
|
|
10
|
+
* (anchor).
|
|
11
|
+
*/
|
|
12
|
+
rotation: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* X coordinate, expressed in points, of the gesture's central focal point
|
|
16
|
+
* (anchor).
|
|
17
|
+
*/
|
|
18
|
+
anchorX: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Y coordinate, expressed in points, of the gesture's central focal point
|
|
22
|
+
* (anchor).
|
|
23
|
+
*/
|
|
24
|
+
anchorY: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Instantaneous velocity, expressed in point units per second, of the
|
|
29
|
+
* gesture.
|
|
30
|
+
*/
|
|
31
|
+
velocity: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export interface RotationGestureHandlerProps
|
|
35
|
+
extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}
|
|
36
|
+
|
|
37
|
+
export type RotationGestureHandler = typeof RotationGestureHandler;
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
|
39
|
+
export const RotationGestureHandler = createHandler<
|
|
40
|
+
RotationGestureHandlerProps,
|
|
41
|
+
RotationGestureHandlerEventPayload
|
|
42
|
+
>({
|
|
43
|
+
name: 'RotationGestureHandler',
|
|
44
|
+
allowedProps: baseGestureHandlerProps,
|
|
45
|
+
config: {},
|
|
46
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import createHandler from './createHandler';
|
|
2
|
+
import {
|
|
3
|
+
BaseGestureHandlerProps,
|
|
4
|
+
baseGestureHandlerProps,
|
|
5
|
+
} from './gestureHandlerCommon';
|
|
6
|
+
|
|
7
|
+
export const tapGestureHandlerProps = [
|
|
8
|
+
'maxDurationMs',
|
|
9
|
+
'maxDelayMs',
|
|
10
|
+
'numberOfTaps',
|
|
11
|
+
'maxDeltaX',
|
|
12
|
+
'maxDeltaY',
|
|
13
|
+
'maxDist',
|
|
14
|
+
'minPointers',
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
export type TapGestureHandlerEventPayload = {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
absoluteX: number;
|
|
21
|
+
absoluteY: number;
|
|
22
|
+
};
|
|
23
|
+
export interface TapGestureConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Minimum number of pointers (fingers) required to be placed before the
|
|
26
|
+
* handler activates. Should be a positive integer.
|
|
27
|
+
* The default value is 1.
|
|
28
|
+
*/
|
|
29
|
+
minPointers?: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Maximum time, expressed in milliseconds, that defines how fast a finger
|
|
33
|
+
* must be released after a touch. The default value is 500.
|
|
34
|
+
*/
|
|
35
|
+
maxDurationMs?: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Maximum time, expressed in milliseconds, that can pass before the next tap
|
|
39
|
+
* if many taps are required. The default value is 500.
|
|
40
|
+
*/
|
|
41
|
+
maxDelayMs?: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Number of tap gestures required to activate the handler. The default value
|
|
45
|
+
* is 1.
|
|
46
|
+
*/
|
|
47
|
+
numberOfTaps?: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Maximum distance, expressed in points, that defines how far the finger is
|
|
51
|
+
* allowed to travel along the X axis during a tap gesture. If the finger
|
|
52
|
+
* travels further than the defined distance along the X axis and the handler
|
|
53
|
+
* hasn't yet activated, it will fail to recognize the gesture.
|
|
54
|
+
*/
|
|
55
|
+
maxDeltaX?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Maximum distance, expressed in points, that defines how far the finger is
|
|
59
|
+
* allowed to travel along the Y axis during a tap gesture. If the finger
|
|
60
|
+
* travels further than the defined distance along the Y axis and the handler
|
|
61
|
+
* hasn't yet activated, it will fail to recognize the gesture.
|
|
62
|
+
*/
|
|
63
|
+
maxDeltaY?: number;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Maximum distance, expressed in points, that defines how far the finger is
|
|
67
|
+
* allowed to travel during a tap gesture. If the finger travels further than
|
|
68
|
+
* the defined distance and the handler hasn't yet
|
|
69
|
+
* activated, it will fail to recognize the gesture.
|
|
70
|
+
*/
|
|
71
|
+
maxDist?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface TapGestureHandlerProps
|
|
75
|
+
extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,
|
|
76
|
+
TapGestureConfig {}
|
|
77
|
+
|
|
78
|
+
export type TapGestureHandler = typeof TapGestureHandler;
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
|
80
|
+
export const TapGestureHandler = createHandler<
|
|
81
|
+
TapGestureHandlerProps,
|
|
82
|
+
TapGestureHandlerEventPayload
|
|
83
|
+
>({
|
|
84
|
+
name: 'TapGestureHandler',
|
|
85
|
+
allowedProps: [
|
|
86
|
+
...baseGestureHandlerProps,
|
|
87
|
+
...tapGestureHandlerProps,
|
|
88
|
+
] as const,
|
|
89
|
+
config: {},
|
|
90
|
+
});
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {
|
|
3
|
-
findNodeHandle as findNodeHandleRN,
|
|
4
|
-
NativeModules,
|
|
5
3
|
Platform,
|
|
6
4
|
Touchable,
|
|
5
|
+
UIManager,
|
|
6
|
+
DeviceEventEmitter,
|
|
7
|
+
EmitterSubscription,
|
|
7
8
|
} from 'react-native';
|
|
8
9
|
// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
|
|
9
|
-
import deepEqual from '
|
|
10
|
+
import deepEqual from 'lodash/isEqual';
|
|
10
11
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
|
11
12
|
import type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';
|
|
12
13
|
import { State } from '../State';
|
|
14
|
+
import { handlerIDToTag, getNextHandlerTag } from './handlersRegistry';
|
|
13
15
|
|
|
14
16
|
import {
|
|
15
17
|
BaseGestureHandlerProps,
|
|
18
|
+
filterConfig,
|
|
16
19
|
GestureEvent,
|
|
17
20
|
HandlerStateChangeEvent,
|
|
18
|
-
|
|
21
|
+
findNodeHandle,
|
|
22
|
+
} from './gestureHandlerCommon';
|
|
19
23
|
import { ValueOf } from '../typeUtils';
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
node: null | number | React.Component<any, any> | React.ComponentClass<any>
|
|
23
|
-
): null | number | React.Component<any, any> | React.ComponentClass<any> {
|
|
24
|
-
if (Platform.OS === 'web') return node;
|
|
25
|
-
return findNodeHandleRN(node);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const { UIManager = {} } = NativeModules;
|
|
25
|
+
const UIManagerAny = UIManager as any;
|
|
29
26
|
|
|
30
27
|
const customGHEventsConfig = {
|
|
31
28
|
onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
|
|
@@ -38,16 +35,16 @@ const customGHEventsConfig = {
|
|
|
38
35
|
// native module.
|
|
39
36
|
// Once new event types are registered with react it is possible to dispatch these
|
|
40
37
|
// events to all kind of native views.
|
|
41
|
-
|
|
42
|
-
...
|
|
38
|
+
UIManagerAny.genericDirectEventTypes = {
|
|
39
|
+
...UIManagerAny.genericDirectEventTypes,
|
|
43
40
|
...customGHEventsConfig,
|
|
44
41
|
};
|
|
45
42
|
// In newer versions of RN the `genericDirectEventTypes` is located in the object
|
|
46
43
|
// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
|
|
47
44
|
// it compatible with RN 61+
|
|
48
45
|
const UIManagerConstants =
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
UIManagerAny.getViewManagerConfig?.('getConstants') ??
|
|
47
|
+
UIManagerAny.getConstants?.();
|
|
51
48
|
|
|
52
49
|
if (UIManagerConstants) {
|
|
53
50
|
UIManagerConstants.genericDirectEventTypes = {
|
|
@@ -64,71 +61,24 @@ const {
|
|
|
64
61
|
clearJSResponder: oldClearJSResponder = () => {
|
|
65
62
|
//no operation
|
|
66
63
|
},
|
|
67
|
-
} =
|
|
68
|
-
|
|
64
|
+
} = UIManagerAny;
|
|
65
|
+
UIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {
|
|
69
66
|
RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);
|
|
70
67
|
oldSetJSResponder(tag, blockNativeResponder);
|
|
71
68
|
};
|
|
72
|
-
|
|
69
|
+
UIManagerAny.clearJSResponder = () => {
|
|
73
70
|
RNGestureHandlerModule.handleClearJSResponder();
|
|
74
71
|
oldClearJSResponder();
|
|
75
72
|
};
|
|
76
73
|
|
|
77
|
-
let
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
param !== undefined &&
|
|
85
|
-
(param !== Object(param) ||
|
|
86
|
-
!('__isNative' in (param as Record<string, unknown>))) &&
|
|
87
|
-
name !== 'onHandlerStateChange' &&
|
|
88
|
-
name !== 'onGestureEvent'
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function filterConfig(
|
|
93
|
-
props: Record<string, unknown>,
|
|
94
|
-
validProps: string[],
|
|
95
|
-
defaults: Record<string, unknown> = {}
|
|
96
|
-
) {
|
|
97
|
-
const res = { ...defaults };
|
|
98
|
-
validProps.forEach((key) => {
|
|
99
|
-
const value = props[key];
|
|
100
|
-
if (isConfigParam(value, key)) {
|
|
101
|
-
let value = props[key];
|
|
102
|
-
if (key === 'simultaneousHandlers' || key === 'waitFor') {
|
|
103
|
-
value = transformIntoHandlerTags(props[key]);
|
|
104
|
-
} else if (key === 'hitSlop') {
|
|
105
|
-
if (typeof value !== 'object') {
|
|
106
|
-
value = { top: value, left: value, bottom: value, right: value };
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
res[key] = value;
|
|
110
|
-
}
|
|
74
|
+
let allowTouches = true;
|
|
75
|
+
const DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';
|
|
76
|
+
// Toggled inspector blocks touch events in order to allow inspecting on Android
|
|
77
|
+
// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
|
|
78
|
+
if (DEV_ON_ANDROID) {
|
|
79
|
+
DeviceEventEmitter.addListener('toggleElementInspector', () => {
|
|
80
|
+
allowTouches = !allowTouches;
|
|
111
81
|
});
|
|
112
|
-
return res;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function transformIntoHandlerTags(handlerIDs: any) {
|
|
116
|
-
if (!Array.isArray(handlerIDs)) {
|
|
117
|
-
handlerIDs = [handlerIDs];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (Platform.OS === 'web') {
|
|
121
|
-
return handlerIDs
|
|
122
|
-
.map(({ current }: { current: any }) => current)
|
|
123
|
-
.filter((handle: any) => handle);
|
|
124
|
-
}
|
|
125
|
-
// converts handler string IDs into their numeric tags
|
|
126
|
-
return handlerIDs
|
|
127
|
-
.map(
|
|
128
|
-
(handlerID: any) =>
|
|
129
|
-
handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1
|
|
130
|
-
)
|
|
131
|
-
.filter((handlerTag: number) => handlerTag > 0);
|
|
132
82
|
}
|
|
133
83
|
|
|
134
84
|
type HandlerProps<T extends Record<string, unknown>> = Readonly<
|
|
@@ -172,6 +122,16 @@ type InternalEventHandlers = {
|
|
|
172
122
|
onGestureHandlerStateChange?: (event: any) => void;
|
|
173
123
|
};
|
|
174
124
|
|
|
125
|
+
let showedRngh2Notice = false;
|
|
126
|
+
function showRngh2NoticeIfNeeded() {
|
|
127
|
+
if (!showedRngh2Notice) {
|
|
128
|
+
console.warn(
|
|
129
|
+
"[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!"
|
|
130
|
+
);
|
|
131
|
+
showedRngh2Notice = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
175
135
|
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
|
176
136
|
export default function createHandler<
|
|
177
137
|
T extends BaseGestureHandlerProps<U>,
|
|
@@ -183,7 +143,13 @@ export default function createHandler<
|
|
|
183
143
|
transformProps,
|
|
184
144
|
customNativeProps = [],
|
|
185
145
|
}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {
|
|
186
|
-
|
|
146
|
+
interface HandlerState {
|
|
147
|
+
allowTouches: boolean;
|
|
148
|
+
}
|
|
149
|
+
class Handler extends React.Component<
|
|
150
|
+
T & InternalEventHandlers,
|
|
151
|
+
HandlerState
|
|
152
|
+
> {
|
|
187
153
|
static displayName = name;
|
|
188
154
|
|
|
189
155
|
private handlerTag: number;
|
|
@@ -192,27 +158,42 @@ export default function createHandler<
|
|
|
192
158
|
private viewNode: any;
|
|
193
159
|
private viewTag?: number;
|
|
194
160
|
private updateEnqueued: ReturnType<typeof setImmediate> | null = null;
|
|
161
|
+
private inspectorToggleListener?: EmitterSubscription;
|
|
195
162
|
|
|
196
163
|
constructor(props: T & InternalEventHandlers) {
|
|
197
164
|
super(props);
|
|
198
|
-
this.handlerTag =
|
|
165
|
+
this.handlerTag = getNextHandlerTag();
|
|
199
166
|
this.config = {};
|
|
200
167
|
this.propsRef = React.createRef();
|
|
168
|
+
this.state = { allowTouches };
|
|
201
169
|
if (props.id) {
|
|
202
170
|
if (handlerIDToTag[props.id] !== undefined) {
|
|
203
171
|
throw new Error(`Handler with ID "${props.id}" already registered`);
|
|
204
172
|
}
|
|
205
173
|
handlerIDToTag[props.id] = this.handlerTag;
|
|
206
174
|
}
|
|
175
|
+
if (__DEV__) {
|
|
176
|
+
showRngh2NoticeIfNeeded();
|
|
177
|
+
}
|
|
207
178
|
}
|
|
208
179
|
|
|
209
180
|
componentDidMount() {
|
|
210
181
|
const props: HandlerProps<U> = this.props;
|
|
182
|
+
|
|
183
|
+
if (DEV_ON_ANDROID) {
|
|
184
|
+
this.inspectorToggleListener = DeviceEventEmitter.addListener(
|
|
185
|
+
'toggleElementInspector',
|
|
186
|
+
() => {
|
|
187
|
+
this.setState((_) => ({ allowTouches }));
|
|
188
|
+
this.update();
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}
|
|
211
192
|
if (hasUnresolvedRefs(props)) {
|
|
212
193
|
// If there are unresolved refs (e.g. ".current" has not yet been set)
|
|
213
194
|
// passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
|
|
214
195
|
// _update method that will try to update native handler props using
|
|
215
|
-
// setImmediate. This makes it so
|
|
196
|
+
// setImmediate. This makes it so update() function gets called after all
|
|
216
197
|
// react components are mounted and we expect the missing ref object to
|
|
217
198
|
// be resolved by then.
|
|
218
199
|
this.updateEnqueued = setImmediate(() => {
|
|
@@ -241,6 +222,7 @@ export default function createHandler<
|
|
|
241
222
|
}
|
|
242
223
|
|
|
243
224
|
componentWillUnmount() {
|
|
225
|
+
this.inspectorToggleListener?.remove();
|
|
244
226
|
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
|
|
245
227
|
if (this.updateEnqueued) {
|
|
246
228
|
clearImmediate(this.updateEnqueued);
|
|
@@ -314,12 +296,14 @@ export default function createHandler<
|
|
|
314
296
|
(RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(
|
|
315
297
|
this.handlerTag,
|
|
316
298
|
newViewTag,
|
|
299
|
+
false,
|
|
317
300
|
this.propsRef
|
|
318
301
|
);
|
|
319
302
|
} else {
|
|
320
303
|
RNGestureHandlerModule.attachGestureHandler(
|
|
321
304
|
this.handlerTag,
|
|
322
|
-
newViewTag
|
|
305
|
+
newViewTag,
|
|
306
|
+
false
|
|
323
307
|
);
|
|
324
308
|
}
|
|
325
309
|
};
|
|
@@ -416,8 +400,12 @@ export default function createHandler<
|
|
|
416
400
|
}
|
|
417
401
|
}
|
|
418
402
|
const events = {
|
|
419
|
-
onGestureHandlerEvent:
|
|
420
|
-
|
|
403
|
+
onGestureHandlerEvent: this.state.allowTouches
|
|
404
|
+
? gestureEventHandler
|
|
405
|
+
: undefined,
|
|
406
|
+
onGestureHandlerStateChange: this.state.allowTouches
|
|
407
|
+
? gestureStateEventHandler
|
|
408
|
+
: undefined,
|
|
421
409
|
};
|
|
422
410
|
|
|
423
411
|
this.propsRef.current = events;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.
|
|
2
|
+
// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof
|
|
3
|
+
// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
|
|
4
|
+
// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
|
|
7
|
+
|
|
8
|
+
import { State } from '../State';
|
|
9
|
+
import { EventType } from '../EventType';
|
|
10
|
+
import { ValueOf } from '../typeUtils';
|
|
11
|
+
import { handlerIDToTag } from './handlersRegistry';
|
|
12
|
+
import { toArray } from '../utils';
|
|
13
|
+
|
|
14
|
+
const commonProps = [
|
|
15
|
+
'id',
|
|
16
|
+
'enabled',
|
|
17
|
+
'shouldCancelWhenOutside',
|
|
18
|
+
'hitSlop',
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
21
|
+
const componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;
|
|
22
|
+
|
|
23
|
+
export const baseGestureHandlerProps = [
|
|
24
|
+
...commonProps,
|
|
25
|
+
...componentInteractionProps,
|
|
26
|
+
'onBegan',
|
|
27
|
+
'onFailed',
|
|
28
|
+
'onCancelled',
|
|
29
|
+
'onActivated',
|
|
30
|
+
'onEnded',
|
|
31
|
+
'onGestureEvent',
|
|
32
|
+
'onHandlerStateChange',
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
export const baseGestureHandlerWithMonitorProps = [
|
|
36
|
+
...commonProps,
|
|
37
|
+
'needsPointerData',
|
|
38
|
+
'manualActivation',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export interface GestureEventPayload {
|
|
42
|
+
handlerTag: number;
|
|
43
|
+
numberOfPointers: number;
|
|
44
|
+
state: ValueOf<typeof State>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface HandlerStateChangeEventPayload {
|
|
48
|
+
handlerTag: number;
|
|
49
|
+
numberOfPointers: number;
|
|
50
|
+
state: ValueOf<typeof State>;
|
|
51
|
+
oldState: ValueOf<typeof State>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type HitSlop =
|
|
55
|
+
| number
|
|
56
|
+
| Partial<
|
|
57
|
+
Record<
|
|
58
|
+
'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',
|
|
59
|
+
number
|
|
60
|
+
>
|
|
61
|
+
>
|
|
62
|
+
| Record<'width' | 'left', number>
|
|
63
|
+
| Record<'width' | 'right', number>
|
|
64
|
+
| Record<'height' | 'top', number>
|
|
65
|
+
| Record<'height' | 'bottom', number>;
|
|
66
|
+
|
|
67
|
+
//TODO(TS) events in handlers
|
|
68
|
+
|
|
69
|
+
export interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {
|
|
70
|
+
nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;
|
|
71
|
+
}
|
|
72
|
+
export interface HandlerStateChangeEvent<
|
|
73
|
+
ExtraEventPayloadT = Record<string, unknown>
|
|
74
|
+
> {
|
|
75
|
+
nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type TouchData = {
|
|
79
|
+
id: number;
|
|
80
|
+
x: number;
|
|
81
|
+
y: number;
|
|
82
|
+
absoluteX: number;
|
|
83
|
+
absoluteY: number;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type GestureTouchEvent = {
|
|
87
|
+
handlerTag: number;
|
|
88
|
+
numberOfTouches: number;
|
|
89
|
+
state: ValueOf<typeof State>;
|
|
90
|
+
eventType: EventType;
|
|
91
|
+
allTouches: TouchData[];
|
|
92
|
+
changedTouches: TouchData[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type GestureUpdateEvent<
|
|
96
|
+
GestureEventPayloadT = Record<string, unknown>
|
|
97
|
+
> = GestureEventPayload & GestureEventPayloadT;
|
|
98
|
+
|
|
99
|
+
export type GestureStateChangeEvent<
|
|
100
|
+
GestureStateChangeEventPayloadT = Record<string, unknown>
|
|
101
|
+
> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;
|
|
102
|
+
|
|
103
|
+
export type CommonGestureConfig = {
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
shouldCancelWhenOutside?: boolean;
|
|
106
|
+
hitSlop?: HitSlop;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Events payloads are types instead of interfaces due to TS limitation.
|
|
110
|
+
// See https://github.com/microsoft/TypeScript/issues/15300 for more info.
|
|
111
|
+
export type BaseGestureHandlerProps<
|
|
112
|
+
ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>
|
|
113
|
+
> = CommonGestureConfig & {
|
|
114
|
+
id?: string;
|
|
115
|
+
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
|
116
|
+
simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
|
|
117
|
+
// TODO(TS) - fix event types
|
|
118
|
+
onBegan?: (event: HandlerStateChangeEvent) => void;
|
|
119
|
+
onFailed?: (event: HandlerStateChangeEvent) => void;
|
|
120
|
+
onCancelled?: (event: HandlerStateChangeEvent) => void;
|
|
121
|
+
onActivated?: (event: HandlerStateChangeEvent) => void;
|
|
122
|
+
onEnded?: (event: HandlerStateChangeEvent) => void;
|
|
123
|
+
|
|
124
|
+
//TODO(TS) consider using NativeSyntheticEvent
|
|
125
|
+
onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;
|
|
126
|
+
onHandlerStateChange?: (
|
|
127
|
+
event: HandlerStateChangeEvent<ExtraEventPayloadT>
|
|
128
|
+
) => void;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
function isConfigParam(param: unknown, name: string) {
|
|
132
|
+
// param !== Object(param) returns false if `param` is a function
|
|
133
|
+
// or an object and returns true if `param` is null
|
|
134
|
+
return (
|
|
135
|
+
param !== undefined &&
|
|
136
|
+
(param !== Object(param) ||
|
|
137
|
+
!('__isNative' in (param as Record<string, unknown>))) &&
|
|
138
|
+
name !== 'onHandlerStateChange' &&
|
|
139
|
+
name !== 'onGestureEvent'
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function filterConfig(
|
|
144
|
+
props: Record<string, unknown>,
|
|
145
|
+
validProps: string[],
|
|
146
|
+
defaults: Record<string, unknown> = {}
|
|
147
|
+
) {
|
|
148
|
+
const filteredConfig = { ...defaults };
|
|
149
|
+
for (const key of validProps) {
|
|
150
|
+
let value = props[key];
|
|
151
|
+
if (isConfigParam(value, key)) {
|
|
152
|
+
if (key === 'simultaneousHandlers' || key === 'waitFor') {
|
|
153
|
+
value = transformIntoHandlerTags(props[key]);
|
|
154
|
+
} else if (key === 'hitSlop' && typeof value !== 'object') {
|
|
155
|
+
value = { top: value, left: value, bottom: value, right: value };
|
|
156
|
+
}
|
|
157
|
+
filteredConfig[key] = value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return filteredConfig;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function transformIntoHandlerTags(handlerIDs: any) {
|
|
164
|
+
handlerIDs = toArray(handlerIDs);
|
|
165
|
+
|
|
166
|
+
if (Platform.OS === 'web') {
|
|
167
|
+
return handlerIDs
|
|
168
|
+
.map(({ current }: { current: any }) => current)
|
|
169
|
+
.filter((handle: any) => handle);
|
|
170
|
+
}
|
|
171
|
+
// converts handler string IDs into their numeric tags
|
|
172
|
+
return handlerIDs
|
|
173
|
+
.map(
|
|
174
|
+
(handlerID: any) =>
|
|
175
|
+
handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1
|
|
176
|
+
)
|
|
177
|
+
.filter((handlerTag: number) => handlerTag > 0);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function findNodeHandle(
|
|
181
|
+
node: null | number | React.Component<any, any> | React.ComponentClass<any>
|
|
182
|
+
): null | number | React.Component<any, any> | React.ComponentClass<any> {
|
|
183
|
+
if (Platform.OS === 'web') return node;
|
|
184
|
+
return findNodeHandleRN(node);
|
|
185
|
+
}
|
|
@@ -5,25 +5,39 @@ import {
|
|
|
5
5
|
RectButtonProps,
|
|
6
6
|
} from '../components/GestureButtons';
|
|
7
7
|
import {
|
|
8
|
-
FlingGestureHandlerEventPayload,
|
|
9
|
-
FlingGestureHandlerProps,
|
|
10
|
-
ForceTouchGestureHandlerEventPayload,
|
|
11
|
-
ForceTouchGestureHandlerProps,
|
|
12
8
|
GestureEvent,
|
|
13
9
|
GestureEventPayload,
|
|
14
10
|
HandlerStateChangeEvent,
|
|
15
11
|
HandlerStateChangeEventPayload,
|
|
12
|
+
} from './gestureHandlerCommon';
|
|
13
|
+
import {
|
|
14
|
+
FlingGestureHandlerEventPayload,
|
|
15
|
+
FlingGestureHandlerProps,
|
|
16
|
+
} from './FlingGestureHandler';
|
|
17
|
+
import {
|
|
18
|
+
ForceTouchGestureHandlerEventPayload,
|
|
19
|
+
ForceTouchGestureHandlerProps,
|
|
20
|
+
} from './ForceTouchGestureHandler';
|
|
21
|
+
import {
|
|
16
22
|
LongPressGestureHandlerEventPayload,
|
|
17
23
|
LongPressGestureHandlerProps,
|
|
24
|
+
} from './LongPressGestureHandler';
|
|
25
|
+
import {
|
|
18
26
|
PanGestureHandlerEventPayload,
|
|
19
27
|
PanGestureHandlerProps,
|
|
28
|
+
} from './PanGestureHandler';
|
|
29
|
+
import {
|
|
20
30
|
PinchGestureHandlerEventPayload,
|
|
21
31
|
PinchGestureHandlerProps,
|
|
32
|
+
} from './PinchGestureHandler';
|
|
33
|
+
import {
|
|
22
34
|
RotationGestureHandlerEventPayload,
|
|
23
35
|
RotationGestureHandlerProps,
|
|
36
|
+
} from './RotationGestureHandler';
|
|
37
|
+
import {
|
|
24
38
|
TapGestureHandlerEventPayload,
|
|
25
39
|
TapGestureHandlerProps,
|
|
26
|
-
} from './
|
|
40
|
+
} from './TapGestureHandler';
|
|
27
41
|
import {
|
|
28
42
|
NativeViewGestureHandlerPayload,
|
|
29
43
|
NativeViewGestureHandlerProps,
|