react-native-gesture-handler 1.10.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,121 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.managePanProps = managePanProps;
|
7
|
+
exports.PanGestureHandler = exports.panGestureHandlerCustomNativeProps = exports.panGestureHandlerProps = void 0;
|
8
|
+
|
9
|
+
var _createHandler = _interopRequireDefault(require("./createHandler"));
|
10
|
+
|
11
|
+
var _gestureHandlerCommon = require("./gestureHandlerCommon");
|
12
|
+
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
|
15
|
+
const panGestureHandlerProps = ['activeOffsetY', 'activeOffsetX', 'failOffsetY', 'failOffsetX', 'minDist', 'minVelocity', 'minVelocityX', 'minVelocityY', 'minPointers', 'maxPointers', 'avgTouches', 'enableTrackpadTwoFingerGesture'];
|
16
|
+
exports.panGestureHandlerProps = panGestureHandlerProps;
|
17
|
+
const panGestureHandlerCustomNativeProps = ['activeOffsetYStart', 'activeOffsetYEnd', 'activeOffsetXStart', 'activeOffsetXEnd', 'failOffsetYStart', 'failOffsetYEnd', 'failOffsetXStart', 'failOffsetXEnd'];
|
18
|
+
exports.panGestureHandlerCustomNativeProps = panGestureHandlerCustomNativeProps;
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
20
|
+
const PanGestureHandler = (0, _createHandler.default)({
|
21
|
+
name: 'PanGestureHandler',
|
22
|
+
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...panGestureHandlerProps],
|
23
|
+
config: {},
|
24
|
+
transformProps: managePanProps,
|
25
|
+
customNativeProps: panGestureHandlerCustomNativeProps
|
26
|
+
});
|
27
|
+
exports.PanGestureHandler = PanGestureHandler;
|
28
|
+
|
29
|
+
function validatePanGestureHandlerProps(props) {
|
30
|
+
if (Array.isArray(props.activeOffsetX) && (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)) {
|
31
|
+
throw new Error(`First element of activeOffsetX should be negative, a the second one should be positive`);
|
32
|
+
}
|
33
|
+
|
34
|
+
if (Array.isArray(props.activeOffsetY) && (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)) {
|
35
|
+
throw new Error(`First element of activeOffsetY should be negative, a the second one should be positive`);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (Array.isArray(props.failOffsetX) && (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)) {
|
39
|
+
throw new Error(`First element of failOffsetX should be negative, a the second one should be positive`);
|
40
|
+
}
|
41
|
+
|
42
|
+
if (Array.isArray(props.failOffsetY) && (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)) {
|
43
|
+
throw new Error(`First element of failOffsetY should be negative, a the second one should be positive`);
|
44
|
+
}
|
45
|
+
|
46
|
+
if (props.minDist && (props.failOffsetX || props.failOffsetY)) {
|
47
|
+
throw new Error(`It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`);
|
48
|
+
}
|
49
|
+
|
50
|
+
if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {
|
51
|
+
throw new Error(`It is not supported to use minDist with activeOffsetX or activeOffsetY`);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
function transformPanGestureHandlerProps(props) {
|
56
|
+
const res = { ...props
|
57
|
+
};
|
58
|
+
|
59
|
+
if (props.activeOffsetX !== undefined) {
|
60
|
+
delete res.activeOffsetX;
|
61
|
+
|
62
|
+
if (Array.isArray(props.activeOffsetX)) {
|
63
|
+
res.activeOffsetXStart = props.activeOffsetX[0];
|
64
|
+
res.activeOffsetXEnd = props.activeOffsetX[1];
|
65
|
+
} else if (props.activeOffsetX < 0) {
|
66
|
+
res.activeOffsetXStart = props.activeOffsetX;
|
67
|
+
} else {
|
68
|
+
res.activeOffsetXEnd = props.activeOffsetX;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
if (props.activeOffsetY !== undefined) {
|
73
|
+
delete res.activeOffsetY;
|
74
|
+
|
75
|
+
if (Array.isArray(props.activeOffsetY)) {
|
76
|
+
res.activeOffsetYStart = props.activeOffsetY[0];
|
77
|
+
res.activeOffsetYEnd = props.activeOffsetY[1];
|
78
|
+
} else if (props.activeOffsetY < 0) {
|
79
|
+
res.activeOffsetYStart = props.activeOffsetY;
|
80
|
+
} else {
|
81
|
+
res.activeOffsetYEnd = props.activeOffsetY;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
if (props.failOffsetX !== undefined) {
|
86
|
+
delete res.failOffsetX;
|
87
|
+
|
88
|
+
if (Array.isArray(props.failOffsetX)) {
|
89
|
+
res.failOffsetXStart = props.failOffsetX[0];
|
90
|
+
res.failOffsetXEnd = props.failOffsetX[1];
|
91
|
+
} else if (props.failOffsetX < 0) {
|
92
|
+
res.failOffsetXStart = props.failOffsetX;
|
93
|
+
} else {
|
94
|
+
res.failOffsetXEnd = props.failOffsetX;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
if (props.failOffsetY !== undefined) {
|
99
|
+
delete res.failOffsetY;
|
100
|
+
|
101
|
+
if (Array.isArray(props.failOffsetY)) {
|
102
|
+
res.failOffsetYStart = props.failOffsetY[0];
|
103
|
+
res.failOffsetYEnd = props.failOffsetY[1];
|
104
|
+
} else if (props.failOffsetY < 0) {
|
105
|
+
res.failOffsetYStart = props.failOffsetY;
|
106
|
+
} else {
|
107
|
+
res.failOffsetYEnd = props.failOffsetY;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
return res;
|
112
|
+
}
|
113
|
+
|
114
|
+
function managePanProps(props) {
|
115
|
+
if (__DEV__) {
|
116
|
+
validatePanGestureHandlerProps(props);
|
117
|
+
}
|
118
|
+
|
119
|
+
return transformPanGestureHandlerProps(props);
|
120
|
+
}
|
121
|
+
//# sourceMappingURL=PanGestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["PanGestureHandler.ts"],"names":["panGestureHandlerProps","panGestureHandlerCustomNativeProps","PanGestureHandler","name","allowedProps","baseGestureHandlerProps","config","transformProps","managePanProps","customNativeProps","validatePanGestureHandlerProps","props","Array","isArray","activeOffsetX","Error","activeOffsetY","failOffsetX","failOffsetY","minDist","transformPanGestureHandlerProps","res","undefined","activeOffsetXStart","activeOffsetXEnd","activeOffsetYStart","activeOffsetYEnd","failOffsetXStart","failOffsetXEnd","failOffsetYStart","failOffsetYEnd","__DEV__"],"mappings":"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","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const panGestureHandlerProps = [\n 'activeOffsetY',\n 'activeOffsetX',\n 'failOffsetY',\n 'failOffsetX',\n 'minDist',\n 'minVelocity',\n 'minVelocityX',\n 'minVelocityY',\n 'minPointers',\n 'maxPointers',\n 'avgTouches',\n 'enableTrackpadTwoFingerGesture',\n] as const;\n\nexport const panGestureHandlerCustomNativeProps = [\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'failOffsetYStart',\n 'failOffsetYEnd',\n 'failOffsetXStart',\n 'failOffsetXEnd',\n] as const;\n\nexport type PanGestureHandlerEventPayload = {\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n x: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n y: number;\n\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the window.\n * The value is expressed in point units. It is recommended to use it instead\n * of `x` in cases when the original view can be transformed as an effect of\n * the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the window.\n * The value is expressed in point units. It is recommended to use it instead\n * of `y` in cases when the original view can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Translation of the pan gesture along X axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationX: number;\n\n /**\n * Translation of the pan gesture along Y axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationY: number;\n\n /**\n * Velocity of the pan gesture along the X axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityX: number;\n\n /**\n * Velocity of the pan gesture along the Y axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityY: number;\n};\n\ninterface CommonPanProperties {\n /**\n * Minimum distance the finger (or multiple finger) need to travel before the\n * handler activates. Expressed in points.\n */\n minDist?: number;\n\n /**\n * Android only.\n */\n avgTouches?: boolean;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * enableTrackpadTwoFingerGesture swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * A number of fingers that is required to be placed before handler can\n * activate. Should be a higher or equal to 0 integer.\n */\n minPointers?: number;\n\n /**\n * When the given number of fingers is placed on the screen and handler hasn't\n * yet activated it will fail recognizing the gesture. Should be a higher or\n * equal to 0 integer.\n */\n maxPointers?: number;\n\n minVelocity?: number;\n minVelocityX?: number;\n minVelocityY?: number;\n}\n\nexport interface PanGestureConfig extends CommonPanProperties {\n activeOffsetYStart?: number;\n activeOffsetYEnd?: number;\n activeOffsetXStart?: number;\n activeOffsetXEnd?: number;\n failOffsetYStart?: number;\n failOffsetYEnd?: number;\n failOffsetXStart?: number;\n failOffsetXEnd?: number;\n}\n\nexport interface PanGestureHandlerProps\n extends BaseGestureHandlerProps<PanGestureHandlerEventPayload>,\n CommonPanProperties {\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetY?: number | number[];\n\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetX?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along Y axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetY?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along X axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetX?: number | number[];\n}\n\nexport type PanGestureHandler = typeof PanGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PanGestureHandler = createHandler<\n PanGestureHandlerProps,\n PanGestureHandlerEventPayload\n>({\n name: 'PanGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...panGestureHandlerProps,\n ] as const,\n config: {},\n transformProps: managePanProps,\n customNativeProps: panGestureHandlerCustomNativeProps,\n});\n\nfunction validatePanGestureHandlerProps(props: PanGestureHandlerProps) {\n if (\n Array.isArray(props.activeOffsetX) &&\n (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.activeOffsetY) &&\n (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetX) &&\n (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetY) &&\n (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (props.minDist && (props.failOffsetX || props.failOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`\n );\n }\n\n if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with activeOffsetX or activeOffsetY`\n );\n }\n}\n\nfunction transformPanGestureHandlerProps(props: PanGestureHandlerProps) {\n type InternalPanGHKeys =\n | 'activeOffsetXStart'\n | 'activeOffsetXEnd'\n | 'failOffsetXStart'\n | 'failOffsetXEnd'\n | 'activeOffsetYStart'\n | 'activeOffsetYEnd'\n | 'failOffsetYStart'\n | 'failOffsetYEnd';\n type PanGestureHandlerInternalProps = PanGestureHandlerProps &\n Partial<Record<InternalPanGHKeys, number>>;\n\n const res: PanGestureHandlerInternalProps = { ...props };\n\n if (props.activeOffsetX !== undefined) {\n delete res.activeOffsetX;\n if (Array.isArray(props.activeOffsetX)) {\n res.activeOffsetXStart = props.activeOffsetX[0];\n res.activeOffsetXEnd = props.activeOffsetX[1];\n } else if (props.activeOffsetX < 0) {\n res.activeOffsetXStart = props.activeOffsetX;\n } else {\n res.activeOffsetXEnd = props.activeOffsetX;\n }\n }\n\n if (props.activeOffsetY !== undefined) {\n delete res.activeOffsetY;\n if (Array.isArray(props.activeOffsetY)) {\n res.activeOffsetYStart = props.activeOffsetY[0];\n res.activeOffsetYEnd = props.activeOffsetY[1];\n } else if (props.activeOffsetY < 0) {\n res.activeOffsetYStart = props.activeOffsetY;\n } else {\n res.activeOffsetYEnd = props.activeOffsetY;\n }\n }\n\n if (props.failOffsetX !== undefined) {\n delete res.failOffsetX;\n if (Array.isArray(props.failOffsetX)) {\n res.failOffsetXStart = props.failOffsetX[0];\n res.failOffsetXEnd = props.failOffsetX[1];\n } else if (props.failOffsetX < 0) {\n res.failOffsetXStart = props.failOffsetX;\n } else {\n res.failOffsetXEnd = props.failOffsetX;\n }\n }\n\n if (props.failOffsetY !== undefined) {\n delete res.failOffsetY;\n if (Array.isArray(props.failOffsetY)) {\n res.failOffsetYStart = props.failOffsetY[0];\n res.failOffsetYEnd = props.failOffsetY[1];\n } else if (props.failOffsetY < 0) {\n res.failOffsetYStart = props.failOffsetY;\n } else {\n res.failOffsetYEnd = props.failOffsetY;\n }\n }\n\n return res;\n}\n\nexport function managePanProps(props: PanGestureHandlerProps) {\n if (__DEV__) {\n validatePanGestureHandlerProps(props);\n }\n return transformPanGestureHandlerProps(props);\n}\n"]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.PinchGestureHandler = void 0;
|
7
|
+
|
8
|
+
var _createHandler = _interopRequireDefault(require("./createHandler"));
|
9
|
+
|
10
|
+
var _gestureHandlerCommon = require("./gestureHandlerCommon");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
15
|
+
const PinchGestureHandler = (0, _createHandler.default)({
|
16
|
+
name: 'PinchGestureHandler',
|
17
|
+
allowedProps: _gestureHandlerCommon.baseGestureHandlerProps,
|
18
|
+
config: {}
|
19
|
+
});
|
20
|
+
exports.PinchGestureHandler = PinchGestureHandler;
|
21
|
+
//# sourceMappingURL=PinchGestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["PinchGestureHandler.ts"],"names":["PinchGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAoCA;AACO,MAAMA,mBAAmB,GAAG,4BAGjC;AACAC,EAAAA,IAAI,EAAE,qBADN;AAEAC,EAAAA,YAAY,EAAEC,6CAFd;AAGAC,EAAAA,MAAM,EAAE;AAHR,CAHiC,CAA5B","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type PinchGestureHandlerEventPayload = {\n /**\n * The scale factor relative to the points of the two touches in screen\n * coordinates.\n */\n scale: number;\n\n /**\n * Position expressed in points along X axis of center anchor point of\n * gesture.\n */\n focalX: number;\n\n /**\n * Position expressed in points along Y axis of center anchor point of\n * gesture.\n */\n focalY: number;\n\n /**\n *\n * Velocity of the pan gesture the current moment. The value is expressed in\n * point units per second.\n */\n velocity: number;\n};\n\nexport interface PinchGestureHandlerProps\n extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}\n\nexport type PinchGestureHandler = typeof PinchGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PinchGestureHandler = createHandler<\n PinchGestureHandlerProps,\n PinchGestureHandlerEventPayload\n>({\n name: 'PinchGestureHandler',\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.RotationGestureHandler = void 0;
|
7
|
+
|
8
|
+
var _createHandler = _interopRequireDefault(require("./createHandler"));
|
9
|
+
|
10
|
+
var _gestureHandlerCommon = require("./gestureHandlerCommon");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
15
|
+
const RotationGestureHandler = (0, _createHandler.default)({
|
16
|
+
name: 'RotationGestureHandler',
|
17
|
+
allowedProps: _gestureHandlerCommon.baseGestureHandlerProps,
|
18
|
+
config: {}
|
19
|
+
});
|
20
|
+
exports.RotationGestureHandler = RotationGestureHandler;
|
21
|
+
//# sourceMappingURL=RotationGestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["RotationGestureHandler.ts"],"names":["RotationGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAoCA;AACO,MAAMA,sBAAsB,GAAG,4BAGpC;AACAC,EAAAA,IAAI,EAAE,wBADN;AAEAC,EAAAA,YAAY,EAAEC,6CAFd;AAGAC,EAAAA,MAAM,EAAE;AAHR,CAHoC,CAA/B","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type RotationGestureHandlerEventPayload = {\n /**\n * Amount rotated, expressed in radians, from the gesture's focal point\n * (anchor).\n */\n rotation: number;\n\n /**\n * X coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorX: number;\n\n /**\n * Y coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorY: number;\n\n /**\n *\n * Instantaneous velocity, expressed in point units per second, of the\n * gesture.\n */\n velocity: number;\n};\n\nexport interface RotationGestureHandlerProps\n extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}\n\nexport type RotationGestureHandler = typeof RotationGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const RotationGestureHandler = createHandler<\n RotationGestureHandlerProps,\n RotationGestureHandlerEventPayload\n>({\n name: 'RotationGestureHandler',\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TapGestureHandler = exports.tapGestureHandlerProps = void 0;
|
7
|
+
|
8
|
+
var _createHandler = _interopRequireDefault(require("./createHandler"));
|
9
|
+
|
10
|
+
var _gestureHandlerCommon = require("./gestureHandlerCommon");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
const tapGestureHandlerProps = ['maxDurationMs', 'maxDelayMs', 'numberOfTaps', 'maxDeltaX', 'maxDeltaY', 'maxDist', 'minPointers'];
|
15
|
+
exports.tapGestureHandlerProps = tapGestureHandlerProps;
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
17
|
+
const TapGestureHandler = (0, _createHandler.default)({
|
18
|
+
name: 'TapGestureHandler',
|
19
|
+
allowedProps: [..._gestureHandlerCommon.baseGestureHandlerProps, ...tapGestureHandlerProps],
|
20
|
+
config: {}
|
21
|
+
});
|
22
|
+
exports.TapGestureHandler = TapGestureHandler;
|
23
|
+
//# sourceMappingURL=TapGestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["TapGestureHandler.ts"],"names":["tapGestureHandlerProps","TapGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;;AAwEP;AACO,MAAMC,iBAAiB,GAAG,4BAG/B;AACAC,EAAAA,IAAI,EAAE,mBADN;AAEAC,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGJ,sBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAH+B,CAA1B","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const tapGestureHandlerProps = [\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface TapGestureConfig {\n /**\n * Minimum number of pointers (fingers) required to be placed before the\n * handler activates. Should be a positive integer.\n * The default value is 1.\n */\n minPointers?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger\n * must be released after a touch. The default value is 500.\n */\n maxDurationMs?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap\n * if many taps are required. The default value is 500.\n */\n maxDelayMs?: number;\n\n /**\n * Number of tap gestures required to activate the handler. The default value\n * is 1.\n */\n numberOfTaps?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the X axis during a tap gesture. If the finger\n * travels further than the defined distance along the X axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaX?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the Y axis during a tap gesture. If the finger\n * travels further than the defined distance along the Y axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaY?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a tap gesture. If the finger travels further than\n * the defined distance and the handler hasn't yet\n * activated, it will fail to recognize the gesture.\n */\n maxDist?: number;\n}\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,\n TapGestureConfig {}\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: 'TapGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...tapGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}
|
@@ -9,13 +9,17 @@ var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _reactNative = require("react-native");
|
11
11
|
|
12
|
-
var
|
12
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
13
13
|
|
14
14
|
var _RNGestureHandlerModule = _interopRequireDefault(require("../RNGestureHandlerModule"));
|
15
15
|
|
16
16
|
var _State = require("../State");
|
17
17
|
|
18
|
-
var
|
18
|
+
var _handlersRegistry = require("./handlersRegistry");
|
19
|
+
|
20
|
+
var _gestureHandlerCommon = require("./gestureHandlerCommon");
|
21
|
+
|
22
|
+
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
|
19
23
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
25
|
|
@@ -25,14 +29,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
25
29
|
|
26
30
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
27
31
|
|
28
|
-
|
29
|
-
if (_reactNative.Platform.OS === 'web') return node;
|
30
|
-
return (0, _reactNative.findNodeHandle)(node);
|
31
|
-
}
|
32
|
-
|
33
|
-
const {
|
34
|
-
UIManager = {}
|
35
|
-
} = _reactNative.NativeModules;
|
32
|
+
const UIManagerAny = _reactNative.UIManager;
|
36
33
|
const customGHEventsConfig = {
|
37
34
|
onGestureHandlerEvent: {
|
38
35
|
registrationName: 'onGestureHandlerEvent'
|
@@ -45,13 +42,13 @@ const customGHEventsConfig = {
|
|
45
42
|
// Once new event types are registered with react it is possible to dispatch these
|
46
43
|
// events to all kind of native views.
|
47
44
|
|
48
|
-
|
45
|
+
UIManagerAny.genericDirectEventTypes = { ...UIManagerAny.genericDirectEventTypes,
|
49
46
|
...customGHEventsConfig
|
50
47
|
}; // In newer versions of RN the `genericDirectEventTypes` is located in the object
|
51
48
|
// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
|
52
49
|
// it compatible with RN 61+
|
53
50
|
|
54
|
-
const UIManagerConstants = (
|
51
|
+
const UIManagerConstants = (_UIManagerAny$getView = (_UIManagerAny$getView2 = UIManagerAny.getViewManagerConfig) === null || _UIManagerAny$getView2 === void 0 ? void 0 : _UIManagerAny$getView2.call(UIManagerAny, 'getConstants')) !== null && _UIManagerAny$getView !== void 0 ? _UIManagerAny$getView : (_UIManagerAny$getCons = UIManagerAny.getConstants) === null || _UIManagerAny$getCons === void 0 ? void 0 : _UIManagerAny$getCons.call(UIManagerAny);
|
55
52
|
|
56
53
|
if (UIManagerConstants) {
|
57
54
|
UIManagerConstants.genericDirectEventTypes = { ...UIManagerConstants.genericDirectEventTypes,
|
@@ -65,74 +62,28 @@ const {
|
|
65
62
|
},
|
66
63
|
clearJSResponder: oldClearJSResponder = () => {//no operation
|
67
64
|
}
|
68
|
-
} =
|
65
|
+
} = UIManagerAny;
|
69
66
|
|
70
|
-
|
67
|
+
UIManagerAny.setJSResponder = (tag, blockNativeResponder) => {
|
71
68
|
_RNGestureHandlerModule.default.handleSetJSResponder(tag, blockNativeResponder);
|
72
69
|
|
73
70
|
oldSetJSResponder(tag, blockNativeResponder);
|
74
71
|
};
|
75
72
|
|
76
|
-
|
73
|
+
UIManagerAny.clearJSResponder = () => {
|
77
74
|
_RNGestureHandlerModule.default.handleClearJSResponder();
|
78
75
|
|
79
76
|
oldClearJSResponder();
|
80
77
|
};
|
81
78
|
|
82
|
-
let
|
83
|
-
const
|
84
|
-
|
85
|
-
function isConfigParam(param, name) {
|
86
|
-
// param !== Object(param) returns false if `param` is a function
|
87
|
-
// or an object and returns true if `param` is null
|
88
|
-
return param !== undefined && (param !== Object(param) || !('__isNative' in param)) && name !== 'onHandlerStateChange' && name !== 'onGestureEvent';
|
89
|
-
}
|
90
|
-
|
91
|
-
function filterConfig(props, validProps, defaults = {}) {
|
92
|
-
const res = { ...defaults
|
93
|
-
};
|
94
|
-
validProps.forEach(key => {
|
95
|
-
const value = props[key];
|
96
|
-
|
97
|
-
if (isConfigParam(value, key)) {
|
98
|
-
let value = props[key];
|
99
|
-
|
100
|
-
if (key === 'simultaneousHandlers' || key === 'waitFor') {
|
101
|
-
value = transformIntoHandlerTags(props[key]);
|
102
|
-
} else if (key === 'hitSlop') {
|
103
|
-
if (typeof value !== 'object') {
|
104
|
-
value = {
|
105
|
-
top: value,
|
106
|
-
left: value,
|
107
|
-
bottom: value,
|
108
|
-
right: value
|
109
|
-
};
|
110
|
-
}
|
111
|
-
}
|
79
|
+
let allowTouches = true;
|
80
|
+
const DEV_ON_ANDROID = __DEV__ && _reactNative.Platform.OS === 'android'; // Toggled inspector blocks touch events in order to allow inspecting on Android
|
81
|
+
// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
|
112
82
|
|
113
|
-
|
114
|
-
|
83
|
+
if (DEV_ON_ANDROID) {
|
84
|
+
_reactNative.DeviceEventEmitter.addListener('toggleElementInspector', () => {
|
85
|
+
allowTouches = !allowTouches;
|
115
86
|
});
|
116
|
-
return res;
|
117
|
-
}
|
118
|
-
|
119
|
-
function transformIntoHandlerTags(handlerIDs) {
|
120
|
-
if (!Array.isArray(handlerIDs)) {
|
121
|
-
handlerIDs = [handlerIDs];
|
122
|
-
}
|
123
|
-
|
124
|
-
if (_reactNative.Platform.OS === 'web') {
|
125
|
-
return handlerIDs.map(({
|
126
|
-
current
|
127
|
-
}) => current).filter(handle => handle);
|
128
|
-
} // converts handler string IDs into their numeric tags
|
129
|
-
|
130
|
-
|
131
|
-
return handlerIDs.map(handlerID => {
|
132
|
-
var _handlerID$current;
|
133
|
-
|
134
|
-
return handlerIDToTag[handlerID] || ((_handlerID$current = handlerID.current) === null || _handlerID$current === void 0 ? void 0 : _handlerID$current.handlerTag) || -1;
|
135
|
-
}).filter(handlerTag => handlerTag > 0);
|
136
87
|
}
|
137
88
|
|
138
89
|
function hasUnresolvedRefs(props) {
|
@@ -156,8 +107,16 @@ const stateToPropMappings = {
|
|
156
107
|
[_State.State.ACTIVE]: 'onActivated',
|
157
108
|
[_State.State.END]: 'onEnded'
|
158
109
|
};
|
110
|
+
let showedRngh2Notice = false;
|
111
|
+
|
112
|
+
function showRngh2NoticeIfNeeded() {
|
113
|
+
if (!showedRngh2Notice) {
|
114
|
+
console.warn("[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!");
|
115
|
+
showedRngh2Notice = true;
|
116
|
+
}
|
117
|
+
} // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
118
|
+
|
159
119
|
|
160
|
-
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
161
120
|
function createHandler({
|
162
121
|
name,
|
163
122
|
allowedProps = [],
|
@@ -181,6 +140,8 @@ function createHandler({
|
|
181
140
|
|
182
141
|
_defineProperty(this, "updateEnqueued", null);
|
183
142
|
|
143
|
+
_defineProperty(this, "inspectorToggleListener", void 0);
|
144
|
+
|
184
145
|
_defineProperty(this, "onGestureHandlerEvent", event => {
|
185
146
|
if (event.nativeEvent.handlerTag === this.handlerTag) {
|
186
147
|
var _this$props$onGesture, _this$props;
|
@@ -240,9 +201,9 @@ function createHandler({
|
|
240
201
|
|
241
202
|
if (_reactNative.Platform.OS === 'web') {
|
242
203
|
// typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
|
243
|
-
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, this.propsRef);
|
204
|
+
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, false, this.propsRef);
|
244
205
|
} else {
|
245
|
-
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag);
|
206
|
+
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, false);
|
246
207
|
}
|
247
208
|
});
|
248
209
|
|
@@ -252,27 +213,43 @@ function createHandler({
|
|
252
213
|
_RNGestureHandlerModule.default.updateGestureHandler(this.handlerTag, newConfig);
|
253
214
|
});
|
254
215
|
|
255
|
-
this.handlerTag =
|
216
|
+
this.handlerTag = (0, _handlersRegistry.getNextHandlerTag)();
|
256
217
|
this.config = {};
|
257
218
|
this.propsRef = /*#__PURE__*/React.createRef();
|
219
|
+
this.state = {
|
220
|
+
allowTouches
|
221
|
+
};
|
258
222
|
|
259
223
|
if (props.id) {
|
260
|
-
if (handlerIDToTag[props.id] !== undefined) {
|
261
|
-
throw new Error(
|
224
|
+
if (_handlersRegistry.handlerIDToTag[props.id] !== undefined) {
|
225
|
+
throw new Error(`Handler with ID "${props.id}" already registered`);
|
262
226
|
}
|
263
227
|
|
264
|
-
handlerIDToTag[props.id] = this.handlerTag;
|
228
|
+
_handlersRegistry.handlerIDToTag[props.id] = this.handlerTag;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (__DEV__) {
|
232
|
+
showRngh2NoticeIfNeeded();
|
265
233
|
}
|
266
234
|
}
|
267
235
|
|
268
236
|
componentDidMount() {
|
269
237
|
const props = this.props;
|
270
238
|
|
239
|
+
if (DEV_ON_ANDROID) {
|
240
|
+
this.inspectorToggleListener = _reactNative.DeviceEventEmitter.addListener('toggleElementInspector', () => {
|
241
|
+
this.setState(_ => ({
|
242
|
+
allowTouches
|
243
|
+
}));
|
244
|
+
this.update();
|
245
|
+
});
|
246
|
+
}
|
247
|
+
|
271
248
|
if (hasUnresolvedRefs(props)) {
|
272
249
|
// If there are unresolved refs (e.g. ".current" has not yet been set)
|
273
250
|
// passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
|
274
251
|
// _update method that will try to update native handler props using
|
275
|
-
// setImmediate. This makes it so
|
252
|
+
// setImmediate. This makes it so update() function gets called after all
|
276
253
|
// react components are mounted and we expect the missing ref object to
|
277
254
|
// be resolved by then.
|
278
255
|
this.updateEnqueued = setImmediate(() => {
|
@@ -281,12 +258,12 @@ function createHandler({
|
|
281
258
|
});
|
282
259
|
}
|
283
260
|
|
284
|
-
this.createGestureHandler(filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
|
285
|
-
this.attachGestureHandler(findNodeHandle(this.viewNode)); // TODO(TS) - check if this can be null
|
261
|
+
this.createGestureHandler((0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
|
262
|
+
this.attachGestureHandler((0, _gestureHandlerCommon.findNodeHandle)(this.viewNode)); // TODO(TS) - check if this can be null
|
286
263
|
}
|
287
264
|
|
288
265
|
componentDidUpdate() {
|
289
|
-
const viewTag = findNodeHandle(this.viewNode);
|
266
|
+
const viewTag = (0, _gestureHandlerCommon.findNodeHandle)(this.viewNode);
|
290
267
|
|
291
268
|
if (this.viewTag !== viewTag) {
|
292
269
|
this.attachGestureHandler(viewTag); // TODO(TS) - check interaction between _viewTag & findNodeHandle
|
@@ -296,6 +273,10 @@ function createHandler({
|
|
296
273
|
}
|
297
274
|
|
298
275
|
componentWillUnmount() {
|
276
|
+
var _this$inspectorToggle;
|
277
|
+
|
278
|
+
(_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
|
279
|
+
|
299
280
|
_RNGestureHandlerModule.default.dropGestureHandler(this.handlerTag);
|
300
281
|
|
301
282
|
if (this.updateEnqueued) {
|
@@ -307,14 +288,14 @@ function createHandler({
|
|
307
288
|
|
308
289
|
if (handlerID) {
|
309
290
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
310
|
-
delete handlerIDToTag[handlerID];
|
291
|
+
delete _handlersRegistry.handlerIDToTag[handlerID];
|
311
292
|
}
|
312
293
|
}
|
313
294
|
|
314
295
|
update() {
|
315
|
-
const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
|
296
|
+
const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
|
316
297
|
|
317
|
-
if (!(0,
|
298
|
+
if (!(0, _isEqual.default)(this.config, newConfig)) {
|
318
299
|
this.updateGestureHandler(newConfig);
|
319
300
|
}
|
320
301
|
}
|
@@ -323,7 +304,7 @@ function createHandler({
|
|
323
304
|
const mergedProps = { ...this.props,
|
324
305
|
...updates
|
325
306
|
};
|
326
|
-
const newConfig = filterConfig(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
|
307
|
+
const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
|
327
308
|
this.updateGestureHandler(newConfig);
|
328
309
|
}
|
329
310
|
|
@@ -373,8 +354,8 @@ function createHandler({
|
|
373
354
|
}
|
374
355
|
|
375
356
|
const events = {
|
376
|
-
onGestureHandlerEvent: gestureEventHandler,
|
377
|
-
onGestureHandlerStateChange: gestureStateEventHandler
|
357
|
+
onGestureHandlerEvent: this.state.allowTouches ? gestureEventHandler : undefined,
|
358
|
+
onGestureHandlerStateChange: this.state.allowTouches ? gestureStateEventHandler : undefined
|
378
359
|
};
|
379
360
|
this.propsRef.current = events;
|
380
361
|
const child = React.Children.only(this.props.children);
|