react-native-gesture-handler 1.10.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/DrawerLayout/package.json +3 -3
- package/README.md +7 -6
- package/Swipeable/package.json +3 -3
- package/android/build.gradle +48 -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 +713 -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 +562 -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 +289 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +88 -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 +79 -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/jestSetup.js +7 -1
- package/lib/commonjs/Directions.js +15 -0
- package/lib/commonjs/Directions.js.map +1 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +24 -0
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.js +20 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/PlatformConstants.js +15 -0
- package/lib/commonjs/PlatformConstants.js.map +1 -0
- package/lib/commonjs/PlatformConstants.web.js +14 -0
- package/lib/commonjs/PlatformConstants.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +22 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js +80 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/commonjs/State.js +18 -0
- package/lib/commonjs/State.js.map +1 -0
- package/lib/commonjs/components/DrawerLayout.js +535 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js +207 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +76 -0
- package/lib/commonjs/components/GestureComponents.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.web.js +46 -0
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -0
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +365 -0
- package/lib/commonjs/components/Swipeable.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +278 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js +109 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +100 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +12 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js +75 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +26 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/index.js +40 -0
- package/lib/commonjs/components/touchables/index.js.map +1 -0
- package/lib/commonjs/gestureHandlerRootHOC.js +39 -0
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -0
- 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 +25 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- 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 +373 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -0
- package/lib/commonjs/handlers/createNativeWrapper.js +70 -0
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +426 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +124 -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 +39 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +185 -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 +19 -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 +116 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +19 -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 +19 -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 +338 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +64 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/typeUtils.js +2 -0
- package/lib/commonjs/typeUtils.js.map +1 -0
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js +105 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/DraggingGestureHandler.js +53 -0
- package/lib/commonjs/web/DraggingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/Errors.js +16 -0
- package/lib/commonjs/web/Errors.js.map +1 -0
- package/lib/commonjs/web/FlingGestureHandler.js +170 -0
- package/lib/commonjs/web/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/GestureHandler.js +533 -0
- package/lib/commonjs/web/GestureHandler.js.map +1 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js +54 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/LongPressGestureHandler.js +71 -0
- package/lib/commonjs/web/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js +62 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NodeManager.js +43 -0
- package/lib/commonjs/web/NodeManager.js.map +1 -0
- package/lib/commonjs/web/PanGestureHandler.js +189 -0
- package/lib/commonjs/web/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PinchGestureHandler.js +40 -0
- package/lib/commonjs/web/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PressGestureHandler.js +188 -0
- package/lib/commonjs/web/PressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/RotationGestureHandler.js +44 -0
- package/lib/commonjs/web/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/web/TapGestureHandler.js +192 -0
- package/lib/commonjs/web/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/web/constants.js +64 -0
- package/lib/commonjs/web/constants.js.map +1 -0
- package/lib/commonjs/web/utils.js +42 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/module/Directions.js +7 -0
- package/lib/module/Directions.js.map +1 -0
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +10 -0
- package/lib/module/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/GestureHandlerRootView.js +7 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -0
- package/lib/module/PlatformConstants.js +5 -0
- package/lib/module/PlatformConstants.js.map +1 -0
- package/lib/module/PlatformConstants.web.js +7 -0
- package/lib/module/PlatformConstants.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +13 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.web.js +56 -0
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/module/State.js +10 -0
- package/lib/module/State.js.map +1 -0
- package/lib/module/components/DrawerLayout.js +520 -0
- package/lib/module/components/DrawerLayout.js.map +1 -0
- package/lib/module/components/GestureButtons.js +172 -0
- package/lib/module/components/GestureButtons.js.map +1 -0
- package/lib/module/components/GestureComponents.js +53 -0
- package/lib/module/components/GestureComponents.js.map +1 -0
- package/lib/module/components/GestureComponents.web.js +25 -0
- package/lib/module/components/GestureComponents.web.js.map +1 -0
- package/{dist/src → lib/module}/components/GestureHandlerButton.js +1 -0
- package/lib/module/components/GestureHandlerButton.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.web.js +9 -0
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +347 -0
- package/lib/module/components/Swipeable.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js +262 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js +95 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +84 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/TouchableNativeFeedback.js +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js +61 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/index.js +1 -0
- package/lib/module/components/touchables/index.js.map +1 -0
- package/lib/module/gestureHandlerRootHOC.js +21 -0
- package/lib/module/gestureHandlerRootHOC.js.map +1 -0
- 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 +11 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- 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 +348 -0
- package/lib/module/handlers/createHandler.js.map +1 -0
- package/lib/module/handlers/createNativeWrapper.js +58 -0
- package/lib/module/handlers/createNativeWrapper.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +389 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +109 -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 +29 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +167 -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 +9 -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 +106 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +9 -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 +9 -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 +34 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +54 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/typeUtils.js +2 -0
- package/lib/module/typeUtils.js.map +1 -0
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/DiscreteGestureHandler.js +94 -0
- package/lib/module/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/DraggingGestureHandler.js +40 -0
- package/lib/module/web/DraggingGestureHandler.js.map +1 -0
- package/lib/module/web/Errors.js +7 -0
- package/lib/module/web/Errors.js.map +1 -0
- package/lib/module/web/FlingGestureHandler.js +156 -0
- package/lib/module/web/FlingGestureHandler.js.map +1 -0
- package/lib/module/web/GestureHandler.js +518 -0
- package/lib/module/web/GestureHandler.js.map +1 -0
- package/lib/module/web/IndiscreteGestureHandler.js +44 -0
- package/lib/module/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/LongPressGestureHandler.js +58 -0
- package/lib/module/web/LongPressGestureHandler.js.map +1 -0
- package/lib/module/web/NativeViewGestureHandler.js +45 -0
- package/lib/module/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web/NodeManager.js +30 -0
- package/lib/module/web/NodeManager.js.map +1 -0
- package/lib/module/web/PanGestureHandler.js +175 -0
- package/lib/module/web/PanGestureHandler.js.map +1 -0
- package/lib/module/web/PinchGestureHandler.js +29 -0
- package/lib/module/web/PinchGestureHandler.js.map +1 -0
- package/lib/module/web/PressGestureHandler.js +174 -0
- package/lib/module/web/PressGestureHandler.js.map +1 -0
- package/lib/module/web/RotationGestureHandler.js +32 -0
- package/lib/module/web/RotationGestureHandler.js.map +1 -0
- package/lib/module/web/TapGestureHandler.js +180 -0
- package/lib/module/web/TapGestureHandler.js.map +1 -0
- package/lib/module/web/constants.js +43 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/utils.js +19 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/typescript/Directions.d.ts +7 -0
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -0
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -0
- package/{dist/src → lib/typescript}/PlatformConstants.d.ts +0 -0
- package/{dist/src → lib/typescript}/PlatformConstants.web.d.ts +0 -0
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.d.ts +1 -8
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.web.d.ts +1 -1
- package/{dist/src → lib/typescript}/State.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/DrawerLayout.d.ts +50 -1
- package/{dist/src → lib/typescript}/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +18 -0
- package/{dist/src → lib/typescript}/components/GestureComponents.web.d.ts +4 -4
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.web.d.ts +0 -0
- package/lib/typescript/components/Swipeable.d.ts +150 -0
- package/{dist/src → lib/typescript}/components/touchables/GenericTouchable.d.ts +3 -3
- package/{dist/src → lib/typescript}/components/touchables/TouchableHighlight.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.android.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableOpacity.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableWithoutFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/index.d.ts +0 -0
- package/{dist/src → lib/typescript}/gestureHandlerRootHOC.d.ts +0 -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 +27 -0
- 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/{dist/src → lib/typescript}/handlers/createHandler.d.ts +1 -1
- package/{dist/src → lib/typescript}/handlers/createNativeWrapper.d.ts +0 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/{dist/src → 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 +10 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +93 -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 +5 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +19 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -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 +44 -0
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +43 -0
- package/{dist/src → lib/typescript}/typeUtils.d.ts +0 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/{dist/src → lib/typescript}/web/DiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/DraggingGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/Errors.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/FlingGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/GestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/IndiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/LongPressGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NativeViewGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NodeManager.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/PanGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PinchGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PressGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/RotationGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/TapGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/constants.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/utils.d.ts +0 -0
- package/package.json +38 -15
- package/src/Directions.ts +8 -2
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/PlatformConstants.ts +3 -2
- package/src/RNGestureHandlerModule.ts +15 -9
- 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 +3 -2
- 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 +60 -81
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +498 -0
- package/src/handlers/gestures/eventReceiver.ts +135 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +32 -0
- package/src/handlers/gestures/gesture.ts +279 -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 +11 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +105 -0
- package/src/handlers/gestures/pinchGesture.ts +12 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +12 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +156 -0
- package/src/init.ts +5 -0
- package/src/mocks.ts +65 -0
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +2 -3
- package/src/web/NativeViewGestureHandler.ts +1 -3
- 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/dist/index.d.ts +0 -13
- package/dist/index.js +0 -16
- package/dist/src/Directions.d.ts +0 -7
- package/dist/src/Directions.js +0 -2
- package/dist/src/GestureHandlerRootView.android.d.ts +0 -4
- package/dist/src/GestureHandlerRootView.android.expo.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.android.expo.js +0 -2
- package/dist/src/GestureHandlerRootView.android.js +0 -21
- package/dist/src/GestureHandlerRootView.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.js +0 -2
- package/dist/src/PlatformConstants.js +0 -2
- package/dist/src/PlatformConstants.web.js +0 -5
- package/dist/src/RNGestureHandlerModule.js +0 -3
- package/dist/src/RNGestureHandlerModule.web.js +0 -47
- package/dist/src/State.js +0 -9
- package/dist/src/__mocks__/RNGestureHandlerModule.d.ts +0 -23
- package/dist/src/__mocks__/RNGestureHandlerModule.js +0 -25
- package/dist/src/components/DrawerLayout.js +0 -391
- package/dist/src/components/GestureButtons.js +0 -113
- package/dist/src/components/GestureComponents.d.ts +0 -45
- package/dist/src/components/GestureComponents.js +0 -18
- package/dist/src/components/GestureComponents.web.js +0 -18
- package/dist/src/components/GestureHandlerButton.web.js +0 -3
- package/dist/src/components/Swipeable.d.ts +0 -83
- package/dist/src/components/Swipeable.js +0 -249
- package/dist/src/components/touchables/GenericTouchable.js +0 -210
- package/dist/src/components/touchables/TouchableHighlight.js +0 -73
- package/dist/src/components/touchables/TouchableNativeFeedback.android.js +0 -63
- package/dist/src/components/touchables/TouchableOpacity.js +0 -50
- package/dist/src/components/touchables/TouchableWithoutFeedback.js +0 -5
- package/dist/src/gestureHandlerRootHOC.js +0 -17
- package/dist/src/handlers/NativeViewGestureHandler.d.ts +0 -12
- package/dist/src/handlers/NativeViewGestureHandler.js +0 -13
- package/dist/src/handlers/createHandler.js +0 -292
- package/dist/src/handlers/createNativeWrapper.js +0 -51
- package/dist/src/handlers/gestureHandlerTypesCompat.js +0 -1
- package/dist/src/handlers/gestureHandlers.d.ts +0 -158
- package/dist/src/handlers/gestureHandlers.js +0 -247
- package/dist/src/typeUtils.js +0 -1
- package/dist/src/web/DiscreteGestureHandler.js +0 -48
- package/dist/src/web/DraggingGestureHandler.js +0 -25
- package/dist/src/web/Errors.js +0 -5
- package/dist/src/web/FlingGestureHandler.js +0 -119
- package/dist/src/web/GestureHandler.js +0 -413
- package/dist/src/web/IndiscreteGestureHandler.js +0 -26
- package/dist/src/web/LongPressGestureHandler.js +0 -46
- package/dist/src/web/NativeViewGestureHandler.js +0 -39
- package/dist/src/web/NodeManager.js +0 -22
- package/dist/src/web/PanGestureHandler.js +0 -145
- package/dist/src/web/PinchGestureHandler.js +0 -19
- package/dist/src/web/PressGestureHandler.js +0 -135
- package/dist/src/web/RotationGestureHandler.js +0 -20
- package/dist/src/web/TapGestureHandler.js +0 -143
- package/dist/src/web/constants.js +0 -42
- package/dist/src/web/utils.js +0 -15
- package/index.ts +0 -117
- package/src/GestureHandlerRootView.android.expo.tsx +0 -3
- package/src/__mocks__/RNGestureHandlerModule.ts +0 -27
- package/src/handlers/gestureHandlers.ts +0 -511
@@ -1,413 +0,0 @@
|
|
1
|
-
/* eslint-disable eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import Hammer from '@egjs/hammerjs';
|
4
|
-
import { findNodeHandle } from 'react-native';
|
5
|
-
import { State } from '../State';
|
6
|
-
import { EventMap } from './constants';
|
7
|
-
import * as NodeManager from './NodeManager';
|
8
|
-
let gestureInstances = 0;
|
9
|
-
class GestureHandler {
|
10
|
-
constructor() {
|
11
|
-
this.isGestureRunning = false;
|
12
|
-
this.view = null;
|
13
|
-
this.hasGestureFailed = false;
|
14
|
-
this.hammer = null;
|
15
|
-
this.initialRotation = null;
|
16
|
-
this.config = {};
|
17
|
-
this.previousState = State.UNDETERMINED;
|
18
|
-
this.pendingGestures = {};
|
19
|
-
this.oldState = State.UNDETERMINED;
|
20
|
-
this.lastSentState = null;
|
21
|
-
this.clearSelfAsPending = () => {
|
22
|
-
if (Array.isArray(this.config.waitFor)) {
|
23
|
-
for (const gesture of this.config.waitFor) {
|
24
|
-
gesture.removePendingGesture(this.id);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
};
|
28
|
-
this.destroy = () => {
|
29
|
-
this.clearSelfAsPending();
|
30
|
-
if (this.hammer) {
|
31
|
-
this.hammer.stop(false);
|
32
|
-
this.hammer.destroy();
|
33
|
-
}
|
34
|
-
this.hammer = null;
|
35
|
-
};
|
36
|
-
this.isPointInView = ({ x, y }) => {
|
37
|
-
// @ts-ignore FIXME(TS)
|
38
|
-
const rect = this.view.getBoundingClientRect();
|
39
|
-
const pointerInside = x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
40
|
-
return pointerInside;
|
41
|
-
};
|
42
|
-
this.sendEvent = (nativeEvent) => {
|
43
|
-
const { onGestureHandlerEvent, onGestureHandlerStateChange, } = this.propsRef.current;
|
44
|
-
const event = this.transformEventData(nativeEvent);
|
45
|
-
invokeNullableMethod(onGestureHandlerEvent, event);
|
46
|
-
if (this.lastSentState !== event.nativeEvent.state) {
|
47
|
-
this.lastSentState = event.nativeEvent.state;
|
48
|
-
invokeNullableMethod(onGestureHandlerStateChange, event);
|
49
|
-
}
|
50
|
-
};
|
51
|
-
this.sync = () => {
|
52
|
-
const gesture = this.hammer.get(this.name);
|
53
|
-
if (!gesture)
|
54
|
-
return;
|
55
|
-
const enable = (recognizer, inputData) => {
|
56
|
-
if (!this.config.enabled) {
|
57
|
-
this.isGestureRunning = false;
|
58
|
-
this.hasGestureFailed = false;
|
59
|
-
return false;
|
60
|
-
}
|
61
|
-
// Prevent events before the system is ready.
|
62
|
-
if (!inputData ||
|
63
|
-
!recognizer.options ||
|
64
|
-
typeof inputData.maxPointers === 'undefined') {
|
65
|
-
return this.shouldEnableGestureOnSetup;
|
66
|
-
}
|
67
|
-
if (this.hasGestureFailed) {
|
68
|
-
return false;
|
69
|
-
}
|
70
|
-
if (!this.isDiscrete) {
|
71
|
-
if (this.isGestureRunning) {
|
72
|
-
return true;
|
73
|
-
}
|
74
|
-
// The built-in hammer.js "waitFor" doesn't work across multiple views.
|
75
|
-
// Only process if there are views to wait for.
|
76
|
-
this._stillWaiting = this._getPendingGestures();
|
77
|
-
// This gesture should continue waiting.
|
78
|
-
if (this._stillWaiting.length) {
|
79
|
-
// Check to see if one of the gestures you're waiting for has started.
|
80
|
-
// If it has then the gesture should fail.
|
81
|
-
for (const gesture of this._stillWaiting) {
|
82
|
-
// When the target gesture has started, this gesture must force fail.
|
83
|
-
if (!gesture.isDiscrete && gesture.isGestureRunning) {
|
84
|
-
this.hasGestureFailed = true;
|
85
|
-
this.isGestureRunning = false;
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
// This gesture shouldn't start until the others have finished.
|
90
|
-
return false;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
// Use default behaviour
|
94
|
-
if (!this.hasCustomActivationCriteria) {
|
95
|
-
return true;
|
96
|
-
}
|
97
|
-
const deltaRotation = this.initialRotation == null
|
98
|
-
? 0
|
99
|
-
: inputData.rotation - this.initialRotation;
|
100
|
-
// @ts-ignore FIXME(TS)
|
101
|
-
const { success, failed } = this.isGestureEnabledForEvent(this.getConfig(), recognizer, {
|
102
|
-
...inputData,
|
103
|
-
deltaRotation,
|
104
|
-
});
|
105
|
-
if (failed) {
|
106
|
-
this.simulateCancelEvent(inputData);
|
107
|
-
this.hasGestureFailed = true;
|
108
|
-
}
|
109
|
-
return success;
|
110
|
-
};
|
111
|
-
const params = this.getHammerConfig();
|
112
|
-
// @ts-ignore FIXME(TS)
|
113
|
-
gesture.set({ ...params, enable });
|
114
|
-
};
|
115
|
-
this.gestureInstance = gestureInstances++;
|
116
|
-
this.hasCustomActivationCriteria = false;
|
117
|
-
}
|
118
|
-
get id() {
|
119
|
-
return `${this.name}${this.gestureInstance}`;
|
120
|
-
}
|
121
|
-
get isDiscrete() {
|
122
|
-
return false;
|
123
|
-
}
|
124
|
-
get shouldEnableGestureOnSetup() {
|
125
|
-
throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');
|
126
|
-
}
|
127
|
-
getConfig() {
|
128
|
-
return this.config;
|
129
|
-
}
|
130
|
-
onWaitingEnded(_gesture) { }
|
131
|
-
removePendingGesture(id) {
|
132
|
-
delete this.pendingGestures[id];
|
133
|
-
}
|
134
|
-
addPendingGesture(gesture) {
|
135
|
-
this.pendingGestures[gesture.id] = gesture;
|
136
|
-
}
|
137
|
-
isGestureEnabledForEvent(_config, _recognizer, _event) {
|
138
|
-
return { success: true };
|
139
|
-
}
|
140
|
-
get NativeGestureClass() {
|
141
|
-
throw new Error('Must override GestureHandler.NativeGestureClass');
|
142
|
-
}
|
143
|
-
updateHasCustomActivationCriteria(_config) {
|
144
|
-
return true;
|
145
|
-
}
|
146
|
-
updateGestureConfig({ enabled = true, ...props }) {
|
147
|
-
this.clearSelfAsPending();
|
148
|
-
this.config = ensureConfig({ enabled, ...props });
|
149
|
-
this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(this.config);
|
150
|
-
if (Array.isArray(this.config.waitFor)) {
|
151
|
-
for (const gesture of this.config.waitFor) {
|
152
|
-
gesture.addPendingGesture(this);
|
153
|
-
}
|
154
|
-
}
|
155
|
-
if (this.hammer) {
|
156
|
-
this.sync();
|
157
|
-
}
|
158
|
-
return this.config;
|
159
|
-
}
|
160
|
-
getState(type) {
|
161
|
-
// @ts-ignore TODO(TS) check if this is needed
|
162
|
-
if (type == 0) {
|
163
|
-
return 0;
|
164
|
-
}
|
165
|
-
return EventMap[type];
|
166
|
-
}
|
167
|
-
transformEventData(event) {
|
168
|
-
const { eventType, maxPointers: numberOfPointers } = event;
|
169
|
-
// const direction = DirectionMap[ev.direction];
|
170
|
-
const changedTouch = event.changedPointers[0];
|
171
|
-
const pointerInside = this.isPointInView({
|
172
|
-
x: changedTouch.clientX,
|
173
|
-
y: changedTouch.clientY,
|
174
|
-
});
|
175
|
-
// TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.
|
176
|
-
const state = this.getState(eventType);
|
177
|
-
if (state !== this.previousState) {
|
178
|
-
this.oldState = this.previousState;
|
179
|
-
this.previousState = state;
|
180
|
-
}
|
181
|
-
return {
|
182
|
-
nativeEvent: {
|
183
|
-
numberOfPointers,
|
184
|
-
state,
|
185
|
-
pointerInside,
|
186
|
-
...this.transformNativeEvent(event),
|
187
|
-
// onHandlerStateChange only
|
188
|
-
handlerTag: this.handlerTag,
|
189
|
-
target: this.ref,
|
190
|
-
oldState: this.oldState,
|
191
|
-
},
|
192
|
-
timeStamp: Date.now(),
|
193
|
-
};
|
194
|
-
}
|
195
|
-
transformNativeEvent(_event) {
|
196
|
-
return {};
|
197
|
-
}
|
198
|
-
cancelPendingGestures(event) {
|
199
|
-
for (const gesture of Object.values(this.pendingGestures)) {
|
200
|
-
if (gesture && gesture.isGestureRunning) {
|
201
|
-
gesture.hasGestureFailed = true;
|
202
|
-
gesture.cancelEvent(event);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}
|
206
|
-
notifyPendingGestures() {
|
207
|
-
for (const gesture of Object.values(this.pendingGestures)) {
|
208
|
-
if (gesture) {
|
209
|
-
gesture.onWaitingEnded(this);
|
210
|
-
}
|
211
|
-
}
|
212
|
-
}
|
213
|
-
// FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input
|
214
|
-
onGestureEnded(event) {
|
215
|
-
this.isGestureRunning = false;
|
216
|
-
this.cancelPendingGestures(event);
|
217
|
-
}
|
218
|
-
forceInvalidate(event) {
|
219
|
-
if (this.isGestureRunning) {
|
220
|
-
this.hasGestureFailed = true;
|
221
|
-
this.cancelEvent(event);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
cancelEvent(event) {
|
225
|
-
this.notifyPendingGestures();
|
226
|
-
this.sendEvent({
|
227
|
-
...event,
|
228
|
-
eventType: Hammer.INPUT_CANCEL,
|
229
|
-
isFinal: true,
|
230
|
-
});
|
231
|
-
this.onGestureEnded(event);
|
232
|
-
}
|
233
|
-
onRawEvent({ isFirst }) {
|
234
|
-
if (isFirst) {
|
235
|
-
this.hasGestureFailed = false;
|
236
|
-
}
|
237
|
-
}
|
238
|
-
setView(ref, propsRef) {
|
239
|
-
if (ref == null) {
|
240
|
-
this.destroy();
|
241
|
-
this.view = null;
|
242
|
-
return;
|
243
|
-
}
|
244
|
-
this.propsRef = propsRef;
|
245
|
-
this.ref = ref;
|
246
|
-
this.view = findNodeHandle(ref);
|
247
|
-
this.hammer = new Hammer.Manager(this.view);
|
248
|
-
this.oldState = State.UNDETERMINED;
|
249
|
-
this.previousState = State.UNDETERMINED;
|
250
|
-
this.lastSentState = null;
|
251
|
-
const { NativeGestureClass } = this;
|
252
|
-
// @ts-ignore TODO(TS)
|
253
|
-
const gesture = new NativeGestureClass(this.getHammerConfig());
|
254
|
-
this.hammer.add(gesture);
|
255
|
-
this.hammer.on('hammer.input', (ev) => {
|
256
|
-
if (!this.config.enabled) {
|
257
|
-
this.hasGestureFailed = false;
|
258
|
-
this.isGestureRunning = false;
|
259
|
-
return;
|
260
|
-
}
|
261
|
-
this.onRawEvent(ev);
|
262
|
-
// TODO: Bacon: Check against something other than null
|
263
|
-
// The isFirst value is not called when the first rotation is calculated.
|
264
|
-
if (this.initialRotation === null && ev.rotation !== 0) {
|
265
|
-
this.initialRotation = ev.rotation;
|
266
|
-
}
|
267
|
-
if (ev.isFinal) {
|
268
|
-
// in favor of a willFail otherwise the last frame of the gesture will be captured.
|
269
|
-
setTimeout(() => {
|
270
|
-
this.initialRotation = null;
|
271
|
-
this.hasGestureFailed = false;
|
272
|
-
});
|
273
|
-
}
|
274
|
-
});
|
275
|
-
this.setupEvents();
|
276
|
-
this.sync();
|
277
|
-
}
|
278
|
-
setupEvents() {
|
279
|
-
// TODO(TS) Hammer types aren't exactly that what we get in runtime
|
280
|
-
if (!this.isDiscrete) {
|
281
|
-
this.hammer.on(`${this.name}start`, (event) => this.onStart(event));
|
282
|
-
this.hammer.on(`${this.name}end ${this.name}cancel`, (event) => {
|
283
|
-
this.onGestureEnded(event);
|
284
|
-
});
|
285
|
-
}
|
286
|
-
this.hammer.on(this.name, (ev) => this.onGestureActivated(ev)); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged
|
287
|
-
}
|
288
|
-
onStart({ deltaX, deltaY, rotation }) {
|
289
|
-
// Reset the state for the next gesture
|
290
|
-
this.oldState = State.UNDETERMINED;
|
291
|
-
this.previousState = State.UNDETERMINED;
|
292
|
-
this.lastSentState = null;
|
293
|
-
this.isGestureRunning = true;
|
294
|
-
this.__initialX = deltaX;
|
295
|
-
this.__initialY = deltaY;
|
296
|
-
this.initialRotation = rotation;
|
297
|
-
}
|
298
|
-
onGestureActivated(ev) {
|
299
|
-
this.sendEvent(ev);
|
300
|
-
}
|
301
|
-
onSuccess() { }
|
302
|
-
_getPendingGestures() {
|
303
|
-
if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {
|
304
|
-
// Get the list of gestures that this gesture is still waiting for.
|
305
|
-
// Use `=== false` in case a ref that isn't a gesture handler is used.
|
306
|
-
const stillWaiting = this.config.waitFor.filter(({ hasGestureFailed }) => hasGestureFailed === false);
|
307
|
-
return stillWaiting;
|
308
|
-
}
|
309
|
-
return [];
|
310
|
-
}
|
311
|
-
getHammerConfig() {
|
312
|
-
const pointers = this.config.minPointers === this.config.maxPointers
|
313
|
-
? this.config.minPointers
|
314
|
-
: 0;
|
315
|
-
return {
|
316
|
-
pointers,
|
317
|
-
};
|
318
|
-
}
|
319
|
-
simulateCancelEvent(_inputData) { }
|
320
|
-
}
|
321
|
-
// TODO(TS) investigate this method
|
322
|
-
// Used for sending data to a callback or AnimatedEvent
|
323
|
-
function invokeNullableMethod(method, event) {
|
324
|
-
if (method) {
|
325
|
-
if (typeof method === 'function') {
|
326
|
-
method(event);
|
327
|
-
}
|
328
|
-
else {
|
329
|
-
// For use with reanimated's AnimatedEvent
|
330
|
-
if ('__getHandler' in method &&
|
331
|
-
typeof method.__getHandler === 'function') {
|
332
|
-
const handler = method.__getHandler();
|
333
|
-
invokeNullableMethod(handler, event);
|
334
|
-
}
|
335
|
-
else {
|
336
|
-
if ('__nodeConfig' in method) {
|
337
|
-
const { argMapping } = method.__nodeConfig;
|
338
|
-
if (Array.isArray(argMapping)) {
|
339
|
-
for (const index in argMapping) {
|
340
|
-
const [key, value] = argMapping[index];
|
341
|
-
if (key in event.nativeEvent) {
|
342
|
-
// @ts-ignore fix method type
|
343
|
-
const nativeValue = event.nativeEvent[key];
|
344
|
-
if (value && value.setValue) {
|
345
|
-
// Reanimated API
|
346
|
-
value.setValue(nativeValue);
|
347
|
-
}
|
348
|
-
else {
|
349
|
-
// RN Animated API
|
350
|
-
method.__nodeConfig.argMapping[index] = [key, nativeValue];
|
351
|
-
}
|
352
|
-
}
|
353
|
-
}
|
354
|
-
}
|
355
|
-
}
|
356
|
-
}
|
357
|
-
}
|
358
|
-
}
|
359
|
-
}
|
360
|
-
// Validate the props
|
361
|
-
function ensureConfig(config) {
|
362
|
-
const props = { ...config };
|
363
|
-
// TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)
|
364
|
-
if ('minDist' in config) {
|
365
|
-
props.minDist = config.minDist;
|
366
|
-
props.minDistSq = props.minDist * props.minDist;
|
367
|
-
}
|
368
|
-
if ('minVelocity' in config) {
|
369
|
-
props.minVelocity = config.minVelocity;
|
370
|
-
props.minVelocitySq = props.minVelocity * props.minVelocity;
|
371
|
-
}
|
372
|
-
if ('maxDist' in config) {
|
373
|
-
props.maxDist = config.maxDist;
|
374
|
-
props.maxDistSq = config.maxDist * config.maxDist;
|
375
|
-
}
|
376
|
-
if ('waitFor' in config) {
|
377
|
-
props.waitFor = asArray(config.waitFor)
|
378
|
-
.map(({ handlerTag }) => NodeManager.getHandler(handlerTag))
|
379
|
-
.filter(v => v);
|
380
|
-
}
|
381
|
-
else {
|
382
|
-
props.waitFor = null;
|
383
|
-
}
|
384
|
-
const configProps = [
|
385
|
-
'minPointers',
|
386
|
-
'maxPointers',
|
387
|
-
'minDist',
|
388
|
-
'maxDist',
|
389
|
-
'maxDistSq',
|
390
|
-
'minVelocitySq',
|
391
|
-
'minDistSq',
|
392
|
-
'minVelocity',
|
393
|
-
'failOffsetXStart',
|
394
|
-
'failOffsetYStart',
|
395
|
-
'failOffsetXEnd',
|
396
|
-
'failOffsetYEnd',
|
397
|
-
'activeOffsetXStart',
|
398
|
-
'activeOffsetXEnd',
|
399
|
-
'activeOffsetYStart',
|
400
|
-
'activeOffsetYEnd',
|
401
|
-
];
|
402
|
-
configProps.forEach((prop) => {
|
403
|
-
if (typeof props[prop] === 'undefined') {
|
404
|
-
props[prop] = Number.NaN;
|
405
|
-
}
|
406
|
-
});
|
407
|
-
return props; // TODO(TS) how to convince TS that props are filled?
|
408
|
-
}
|
409
|
-
function asArray(value) {
|
410
|
-
// TODO(TS) use config.waitFor type
|
411
|
-
return value == null ? [] : Array.isArray(value) ? value : [value];
|
412
|
-
}
|
413
|
-
export default GestureHandler;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import GestureHandler from './GestureHandler';
|
2
|
-
/**
|
3
|
-
* The base class for **Rotation** and **Pinch** gesture handlers.
|
4
|
-
*/
|
5
|
-
class IndiscreteGestureHandler extends GestureHandler {
|
6
|
-
get shouldEnableGestureOnSetup() {
|
7
|
-
return false;
|
8
|
-
}
|
9
|
-
updateGestureConfig({ minPointers = 2, maxPointers = 2, ...props }) {
|
10
|
-
return super.updateGestureConfig({
|
11
|
-
minPointers,
|
12
|
-
maxPointers,
|
13
|
-
...props,
|
14
|
-
});
|
15
|
-
}
|
16
|
-
isGestureEnabledForEvent({ minPointers, maxPointers }, _recognizer, { maxPointers: pointerLength }) {
|
17
|
-
if (pointerLength > maxPointers) {
|
18
|
-
return { failed: true };
|
19
|
-
}
|
20
|
-
const validPointerCount = pointerLength >= minPointers;
|
21
|
-
return {
|
22
|
-
success: validPointerCount,
|
23
|
-
};
|
24
|
-
}
|
25
|
-
}
|
26
|
-
export default IndiscreteGestureHandler;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/* eslint-disable eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import Hammer from '@egjs/hammerjs';
|
4
|
-
import { State } from '../State';
|
5
|
-
import PressGestureHandler from './PressGestureHandler';
|
6
|
-
import { isnan, isValidNumber } from './utils';
|
7
|
-
class LongPressGestureHandler extends PressGestureHandler {
|
8
|
-
get minDurationMs() {
|
9
|
-
// @ts-ignore FIXNE(TS)
|
10
|
-
return isnan(this.config.minDurationMs) ? 251 : this.config.minDurationMs;
|
11
|
-
}
|
12
|
-
get maxDist() {
|
13
|
-
// @ts-ignore FIXNE(TS)
|
14
|
-
return isnan(this.config.maxDist) ? 9 : this.config.maxDist;
|
15
|
-
}
|
16
|
-
updateHasCustomActivationCriteria({ maxDistSq }) {
|
17
|
-
return !isValidNumber(maxDistSq);
|
18
|
-
}
|
19
|
-
getConfig() {
|
20
|
-
if (!this.hasCustomActivationCriteria) {
|
21
|
-
// Default config
|
22
|
-
// If no params have been defined then this config should emulate the native gesture as closely as possible.
|
23
|
-
return {
|
24
|
-
shouldCancelWhenOutside: true,
|
25
|
-
maxDistSq: 10,
|
26
|
-
};
|
27
|
-
}
|
28
|
-
return this.config;
|
29
|
-
}
|
30
|
-
getHammerConfig() {
|
31
|
-
return {
|
32
|
-
...super.getHammerConfig(),
|
33
|
-
// threshold: this.maxDist,
|
34
|
-
time: this.minDurationMs,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
getState(type) {
|
38
|
-
return {
|
39
|
-
[Hammer.INPUT_START]: State.ACTIVE,
|
40
|
-
[Hammer.INPUT_MOVE]: State.ACTIVE,
|
41
|
-
[Hammer.INPUT_END]: State.END,
|
42
|
-
[Hammer.INPUT_CANCEL]: State.FAILED,
|
43
|
-
}[type];
|
44
|
-
}
|
45
|
-
}
|
46
|
-
export default LongPressGestureHandler;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
/* eslint-disable eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import DiscreteGestureHandler from './DiscreteGestureHandler';
|
4
|
-
import * as NodeManager from './NodeManager';
|
5
|
-
import PressGestureHandler from './PressGestureHandler';
|
6
|
-
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
7
|
-
class NativeViewGestureHandler extends PressGestureHandler {
|
8
|
-
onRawEvent(ev) {
|
9
|
-
super.onRawEvent(ev);
|
10
|
-
if (!ev.isFinal) {
|
11
|
-
// if (this.ref instanceof ScrollView) {
|
12
|
-
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
|
13
|
-
// @ts-ignore FIXME(TS) config type
|
14
|
-
if (this.config.disallowInterruption) {
|
15
|
-
const gestures = Object.values(NodeManager.getNodes()).filter(gesture => {
|
16
|
-
const { handlerTag, view, isGestureRunning } = gesture;
|
17
|
-
return (
|
18
|
-
// Check if this gesture isn't self
|
19
|
-
handlerTag !== this.handlerTag &&
|
20
|
-
// Ensure the gesture needs to be cancelled
|
21
|
-
isGestureRunning &&
|
22
|
-
// ScrollView can cancel discrete gestures like taps and presses
|
23
|
-
gesture instanceof DiscreteGestureHandler &&
|
24
|
-
// Ensure a view exists and is a child of the current view
|
25
|
-
view &&
|
26
|
-
// @ts-ignore FIXME(TS) view type
|
27
|
-
this.view.contains(view));
|
28
|
-
});
|
29
|
-
// Cancel all of the gestures that passed the filter
|
30
|
-
for (const gesture of gestures) {
|
31
|
-
// TODO: Bacon: Send some cached event.
|
32
|
-
gesture.forceInvalidate(ev);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
export default NativeViewGestureHandler;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
const gestures = {};
|
2
|
-
export function getHandler(tag) {
|
3
|
-
if (tag in gestures)
|
4
|
-
return gestures[tag];
|
5
|
-
throw new Error(`No handler for tag ${tag}`);
|
6
|
-
}
|
7
|
-
export function createGestureHandler(handlerTag, handler) {
|
8
|
-
if (handlerTag in gestures) {
|
9
|
-
throw new Error(`Handler with tag ${handlerTag} already exists`);
|
10
|
-
}
|
11
|
-
gestures[handlerTag] = handler;
|
12
|
-
// @ts-ignore no types for web handlers yet
|
13
|
-
gestures[handlerTag].handlerTag = handlerTag;
|
14
|
-
}
|
15
|
-
export function dropGestureHandler(handlerTag) {
|
16
|
-
getHandler(handlerTag).destroy();
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
18
|
-
delete gestures[handlerTag];
|
19
|
-
}
|
20
|
-
export function getNodes() {
|
21
|
-
return { ...gestures };
|
22
|
-
}
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import Hammer from '@egjs/hammerjs';
|
2
|
-
import { MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD, MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD, } from './constants';
|
3
|
-
import DraggingGestureHandler from './DraggingGestureHandler';
|
4
|
-
import { isValidNumber, isnan, TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
5
|
-
import { State } from '../State';
|
6
|
-
class PanGestureHandler extends DraggingGestureHandler {
|
7
|
-
get name() {
|
8
|
-
return 'pan';
|
9
|
-
}
|
10
|
-
get NativeGestureClass() {
|
11
|
-
return Hammer.Pan;
|
12
|
-
}
|
13
|
-
getHammerConfig() {
|
14
|
-
return {
|
15
|
-
...super.getHammerConfig(),
|
16
|
-
direction: this.getDirection(),
|
17
|
-
};
|
18
|
-
}
|
19
|
-
getState(type) {
|
20
|
-
const nextState = super.getState(type);
|
21
|
-
// Ensure that the first state sent is `BEGAN` and not `ACTIVE`
|
22
|
-
if (this.previousState === State.UNDETERMINED &&
|
23
|
-
nextState === State.ACTIVE) {
|
24
|
-
return State.BEGAN;
|
25
|
-
}
|
26
|
-
return nextState;
|
27
|
-
}
|
28
|
-
getDirection() {
|
29
|
-
const config = this.getConfig();
|
30
|
-
const { activeOffsetXStart, activeOffsetXEnd, activeOffsetYStart, activeOffsetYEnd, minDist, } = config;
|
31
|
-
let directions = [];
|
32
|
-
let horizontalDirections = [];
|
33
|
-
if (!isnan(minDist)) {
|
34
|
-
return Hammer.DIRECTION_ALL;
|
35
|
-
}
|
36
|
-
if (!isnan(activeOffsetXStart))
|
37
|
-
horizontalDirections.push(Hammer.DIRECTION_LEFT);
|
38
|
-
if (!isnan(activeOffsetXEnd))
|
39
|
-
horizontalDirections.push(Hammer.DIRECTION_RIGHT);
|
40
|
-
if (horizontalDirections.length === 2)
|
41
|
-
horizontalDirections = [Hammer.DIRECTION_HORIZONTAL];
|
42
|
-
directions = directions.concat(horizontalDirections);
|
43
|
-
let verticalDirections = [];
|
44
|
-
if (!isnan(activeOffsetYStart))
|
45
|
-
verticalDirections.push(Hammer.DIRECTION_UP);
|
46
|
-
if (!isnan(activeOffsetYEnd))
|
47
|
-
verticalDirections.push(Hammer.DIRECTION_DOWN);
|
48
|
-
if (verticalDirections.length === 2)
|
49
|
-
verticalDirections = [Hammer.DIRECTION_VERTICAL];
|
50
|
-
directions = directions.concat(verticalDirections);
|
51
|
-
if (!directions.length) {
|
52
|
-
return Hammer.DIRECTION_NONE;
|
53
|
-
}
|
54
|
-
if (directions[0] === Hammer.DIRECTION_HORIZONTAL &&
|
55
|
-
directions[1] === Hammer.DIRECTION_VERTICAL) {
|
56
|
-
return Hammer.DIRECTION_ALL;
|
57
|
-
}
|
58
|
-
if (horizontalDirections.length && verticalDirections.length) {
|
59
|
-
return Hammer.DIRECTION_ALL;
|
60
|
-
}
|
61
|
-
return directions[0];
|
62
|
-
}
|
63
|
-
getConfig() {
|
64
|
-
if (!this.hasCustomActivationCriteria) {
|
65
|
-
// Default config
|
66
|
-
// If no params have been defined then this config should emulate the native gesture as closely as possible.
|
67
|
-
return {
|
68
|
-
minDistSq: 10,
|
69
|
-
};
|
70
|
-
}
|
71
|
-
return this.config;
|
72
|
-
}
|
73
|
-
shouldFailUnderCustomCriteria({ deltaX, deltaY }, criteria) {
|
74
|
-
return ((!isnan(criteria.failOffsetXStart) &&
|
75
|
-
deltaX < criteria.failOffsetXStart) ||
|
76
|
-
(!isnan(criteria.failOffsetXEnd) && deltaX > criteria.failOffsetXEnd) ||
|
77
|
-
(!isnan(criteria.failOffsetYStart) &&
|
78
|
-
deltaY < criteria.failOffsetYStart) ||
|
79
|
-
(!isnan(criteria.failOffsetYEnd) && deltaY > criteria.failOffsetYEnd));
|
80
|
-
}
|
81
|
-
shouldActivateUnderCustomCriteria({ deltaX, deltaY, velocity }, criteria) {
|
82
|
-
return ((!isnan(criteria.activeOffsetXStart) &&
|
83
|
-
deltaX < criteria.activeOffsetXStart) ||
|
84
|
-
(!isnan(criteria.activeOffsetXEnd) &&
|
85
|
-
deltaX > criteria.activeOffsetXEnd) ||
|
86
|
-
(!isnan(criteria.activeOffsetYStart) &&
|
87
|
-
deltaY < criteria.activeOffsetYStart) ||
|
88
|
-
(!isnan(criteria.activeOffsetYEnd) &&
|
89
|
-
deltaY > criteria.activeOffsetYEnd) ||
|
90
|
-
TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: deltaX, y: deltaY }), criteria.minDistSq) ||
|
91
|
-
TEST_MIN_IF_NOT_NAN(velocity.x, criteria.minVelocityX) ||
|
92
|
-
TEST_MIN_IF_NOT_NAN(velocity.y, criteria.minVelocityY) ||
|
93
|
-
TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ(velocity), criteria.minVelocitySq));
|
94
|
-
}
|
95
|
-
shouldMultiFingerPanFail({ pointerLength, scale, deltaRotation, }) {
|
96
|
-
if (pointerLength <= 1) {
|
97
|
-
return false;
|
98
|
-
}
|
99
|
-
// Test if the pan had too much pinching or rotating.
|
100
|
-
const deltaScale = Math.abs(scale - 1);
|
101
|
-
const absDeltaRotation = Math.abs(deltaRotation);
|
102
|
-
if (deltaScale > MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD) {
|
103
|
-
// > If the threshold doesn't seem right.
|
104
|
-
// You can log the value which it failed at here:
|
105
|
-
return true;
|
106
|
-
}
|
107
|
-
if (absDeltaRotation > MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD) {
|
108
|
-
// > If the threshold doesn't seem right.
|
109
|
-
// You can log the value which it failed at here:
|
110
|
-
return true;
|
111
|
-
}
|
112
|
-
return false;
|
113
|
-
}
|
114
|
-
updateHasCustomActivationCriteria(criteria) {
|
115
|
-
return (isValidNumber(criteria.minDistSq) ||
|
116
|
-
isValidNumber(criteria.minVelocityX) ||
|
117
|
-
isValidNumber(criteria.minVelocityY) ||
|
118
|
-
isValidNumber(criteria.minVelocitySq) ||
|
119
|
-
isValidNumber(criteria.activeOffsetXStart) ||
|
120
|
-
isValidNumber(criteria.activeOffsetXEnd) ||
|
121
|
-
isValidNumber(criteria.activeOffsetYStart) ||
|
122
|
-
isValidNumber(criteria.activeOffsetYEnd));
|
123
|
-
}
|
124
|
-
isGestureEnabledForEvent(props, _recognizer, inputData) {
|
125
|
-
if (this.shouldFailUnderCustomCriteria(inputData, props)) {
|
126
|
-
return { failed: true };
|
127
|
-
}
|
128
|
-
const velocity = { x: inputData.velocityX, y: inputData.velocityY };
|
129
|
-
if (this.hasCustomActivationCriteria &&
|
130
|
-
this.shouldActivateUnderCustomCriteria({ deltaX: inputData.deltaX, deltaY: inputData.deltaY, velocity }, props)) {
|
131
|
-
if (this.shouldMultiFingerPanFail({
|
132
|
-
pointerLength: inputData.maxPointers,
|
133
|
-
scale: inputData.scale,
|
134
|
-
deltaRotation: inputData.deltaRotation,
|
135
|
-
})) {
|
136
|
-
return {
|
137
|
-
failed: true,
|
138
|
-
};
|
139
|
-
}
|
140
|
-
return { success: true };
|
141
|
-
}
|
142
|
-
return { success: false };
|
143
|
-
}
|
144
|
-
}
|
145
|
-
export default PanGestureHandler;
|