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
@@ -0,0 +1,518 @@
|
|
1
|
+
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; }
|
2
|
+
|
3
|
+
/* eslint-disable eslint-comments/no-unlimited-disable */
|
4
|
+
|
5
|
+
/* eslint-disable */
|
6
|
+
import Hammer from '@egjs/hammerjs';
|
7
|
+
import { findNodeHandle } from 'react-native';
|
8
|
+
import { State } from '../State';
|
9
|
+
import { EventMap } from './constants';
|
10
|
+
import * as NodeManager from './NodeManager'; // TODO(TS) Replace with HammerInput if https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438/files is merged
|
11
|
+
|
12
|
+
let gestureInstances = 0;
|
13
|
+
|
14
|
+
class GestureHandler {
|
15
|
+
get id() {
|
16
|
+
return `${this.name}${this.gestureInstance}`;
|
17
|
+
}
|
18
|
+
|
19
|
+
get isDiscrete() {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
get shouldEnableGestureOnSetup() {
|
24
|
+
throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');
|
25
|
+
}
|
26
|
+
|
27
|
+
constructor() {
|
28
|
+
_defineProperty(this, "handlerTag", void 0);
|
29
|
+
|
30
|
+
_defineProperty(this, "isGestureRunning", false);
|
31
|
+
|
32
|
+
_defineProperty(this, "view", null);
|
33
|
+
|
34
|
+
_defineProperty(this, "hasCustomActivationCriteria", void 0);
|
35
|
+
|
36
|
+
_defineProperty(this, "hasGestureFailed", false);
|
37
|
+
|
38
|
+
_defineProperty(this, "hammer", null);
|
39
|
+
|
40
|
+
_defineProperty(this, "initialRotation", null);
|
41
|
+
|
42
|
+
_defineProperty(this, "__initialX", void 0);
|
43
|
+
|
44
|
+
_defineProperty(this, "__initialY", void 0);
|
45
|
+
|
46
|
+
_defineProperty(this, "config", {});
|
47
|
+
|
48
|
+
_defineProperty(this, "previousState", State.UNDETERMINED);
|
49
|
+
|
50
|
+
_defineProperty(this, "pendingGestures", {});
|
51
|
+
|
52
|
+
_defineProperty(this, "oldState", State.UNDETERMINED);
|
53
|
+
|
54
|
+
_defineProperty(this, "lastSentState", null);
|
55
|
+
|
56
|
+
_defineProperty(this, "gestureInstance", void 0);
|
57
|
+
|
58
|
+
_defineProperty(this, "_stillWaiting", void 0);
|
59
|
+
|
60
|
+
_defineProperty(this, "propsRef", void 0);
|
61
|
+
|
62
|
+
_defineProperty(this, "ref", void 0);
|
63
|
+
|
64
|
+
_defineProperty(this, "clearSelfAsPending", () => {
|
65
|
+
if (Array.isArray(this.config.waitFor)) {
|
66
|
+
for (const gesture of this.config.waitFor) {
|
67
|
+
gesture.removePendingGesture(this.id);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
_defineProperty(this, "destroy", () => {
|
73
|
+
this.clearSelfAsPending();
|
74
|
+
|
75
|
+
if (this.hammer) {
|
76
|
+
this.hammer.stop(false);
|
77
|
+
this.hammer.destroy();
|
78
|
+
}
|
79
|
+
|
80
|
+
this.hammer = null;
|
81
|
+
});
|
82
|
+
|
83
|
+
_defineProperty(this, "isPointInView", ({
|
84
|
+
x,
|
85
|
+
y
|
86
|
+
}) => {
|
87
|
+
// @ts-ignore FIXME(TS)
|
88
|
+
const rect = this.view.getBoundingClientRect();
|
89
|
+
const pointerInside = x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
90
|
+
return pointerInside;
|
91
|
+
});
|
92
|
+
|
93
|
+
_defineProperty(this, "sendEvent", nativeEvent => {
|
94
|
+
const {
|
95
|
+
onGestureHandlerEvent,
|
96
|
+
onGestureHandlerStateChange
|
97
|
+
} = this.propsRef.current;
|
98
|
+
const event = this.transformEventData(nativeEvent);
|
99
|
+
invokeNullableMethod(onGestureHandlerEvent, event);
|
100
|
+
|
101
|
+
if (this.lastSentState !== event.nativeEvent.state) {
|
102
|
+
this.lastSentState = event.nativeEvent.state;
|
103
|
+
invokeNullableMethod(onGestureHandlerStateChange, event);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
_defineProperty(this, "sync", () => {
|
108
|
+
const gesture = this.hammer.get(this.name);
|
109
|
+
if (!gesture) return;
|
110
|
+
|
111
|
+
const enable = (recognizer, inputData) => {
|
112
|
+
if (!this.config.enabled) {
|
113
|
+
this.isGestureRunning = false;
|
114
|
+
this.hasGestureFailed = false;
|
115
|
+
return false;
|
116
|
+
} // Prevent events before the system is ready.
|
117
|
+
|
118
|
+
|
119
|
+
if (!inputData || !recognizer.options || typeof inputData.maxPointers === 'undefined') {
|
120
|
+
return this.shouldEnableGestureOnSetup;
|
121
|
+
}
|
122
|
+
|
123
|
+
if (this.hasGestureFailed) {
|
124
|
+
return false;
|
125
|
+
}
|
126
|
+
|
127
|
+
if (!this.isDiscrete) {
|
128
|
+
if (this.isGestureRunning) {
|
129
|
+
return true;
|
130
|
+
} // The built-in hammer.js "waitFor" doesn't work across multiple views.
|
131
|
+
// Only process if there are views to wait for.
|
132
|
+
|
133
|
+
|
134
|
+
this._stillWaiting = this._getPendingGestures(); // This gesture should continue waiting.
|
135
|
+
|
136
|
+
if (this._stillWaiting.length) {
|
137
|
+
// Check to see if one of the gestures you're waiting for has started.
|
138
|
+
// If it has then the gesture should fail.
|
139
|
+
for (const gesture of this._stillWaiting) {
|
140
|
+
// When the target gesture has started, this gesture must force fail.
|
141
|
+
if (!gesture.isDiscrete && gesture.isGestureRunning) {
|
142
|
+
this.hasGestureFailed = true;
|
143
|
+
this.isGestureRunning = false;
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
} // This gesture shouldn't start until the others have finished.
|
147
|
+
|
148
|
+
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
} // Use default behaviour
|
152
|
+
|
153
|
+
|
154
|
+
if (!this.hasCustomActivationCriteria) {
|
155
|
+
return true;
|
156
|
+
}
|
157
|
+
|
158
|
+
const deltaRotation = this.initialRotation == null ? 0 : inputData.rotation - this.initialRotation; // @ts-ignore FIXME(TS)
|
159
|
+
|
160
|
+
const {
|
161
|
+
success,
|
162
|
+
failed
|
163
|
+
} = this.isGestureEnabledForEvent(this.getConfig(), recognizer, { ...inputData,
|
164
|
+
deltaRotation
|
165
|
+
});
|
166
|
+
|
167
|
+
if (failed) {
|
168
|
+
this.simulateCancelEvent(inputData);
|
169
|
+
this.hasGestureFailed = true;
|
170
|
+
}
|
171
|
+
|
172
|
+
return success;
|
173
|
+
};
|
174
|
+
|
175
|
+
const params = this.getHammerConfig(); // @ts-ignore FIXME(TS)
|
176
|
+
|
177
|
+
gesture.set({ ...params,
|
178
|
+
enable
|
179
|
+
});
|
180
|
+
});
|
181
|
+
|
182
|
+
this.gestureInstance = gestureInstances++;
|
183
|
+
this.hasCustomActivationCriteria = false;
|
184
|
+
}
|
185
|
+
|
186
|
+
getConfig() {
|
187
|
+
return this.config;
|
188
|
+
}
|
189
|
+
|
190
|
+
onWaitingEnded(_gesture) {}
|
191
|
+
|
192
|
+
removePendingGesture(id) {
|
193
|
+
delete this.pendingGestures[id];
|
194
|
+
}
|
195
|
+
|
196
|
+
addPendingGesture(gesture) {
|
197
|
+
this.pendingGestures[gesture.id] = gesture;
|
198
|
+
}
|
199
|
+
|
200
|
+
isGestureEnabledForEvent(_config, _recognizer, _event) {
|
201
|
+
return {
|
202
|
+
success: true
|
203
|
+
};
|
204
|
+
}
|
205
|
+
|
206
|
+
get NativeGestureClass() {
|
207
|
+
throw new Error('Must override GestureHandler.NativeGestureClass');
|
208
|
+
}
|
209
|
+
|
210
|
+
updateHasCustomActivationCriteria(_config) {
|
211
|
+
return true;
|
212
|
+
}
|
213
|
+
|
214
|
+
updateGestureConfig({
|
215
|
+
enabled = true,
|
216
|
+
...props
|
217
|
+
}) {
|
218
|
+
this.clearSelfAsPending();
|
219
|
+
this.config = ensureConfig({
|
220
|
+
enabled,
|
221
|
+
...props
|
222
|
+
});
|
223
|
+
this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(this.config);
|
224
|
+
|
225
|
+
if (Array.isArray(this.config.waitFor)) {
|
226
|
+
for (const gesture of this.config.waitFor) {
|
227
|
+
gesture.addPendingGesture(this);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
if (this.hammer) {
|
232
|
+
this.sync();
|
233
|
+
}
|
234
|
+
|
235
|
+
return this.config;
|
236
|
+
}
|
237
|
+
|
238
|
+
getState(type) {
|
239
|
+
// @ts-ignore TODO(TS) check if this is needed
|
240
|
+
if (type == 0) {
|
241
|
+
return 0;
|
242
|
+
}
|
243
|
+
|
244
|
+
return EventMap[type];
|
245
|
+
}
|
246
|
+
|
247
|
+
transformEventData(event) {
|
248
|
+
const {
|
249
|
+
eventType,
|
250
|
+
maxPointers: numberOfPointers
|
251
|
+
} = event; // const direction = DirectionMap[ev.direction];
|
252
|
+
|
253
|
+
const changedTouch = event.changedPointers[0];
|
254
|
+
const pointerInside = this.isPointInView({
|
255
|
+
x: changedTouch.clientX,
|
256
|
+
y: changedTouch.clientY
|
257
|
+
}); // TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.
|
258
|
+
|
259
|
+
const state = this.getState(eventType);
|
260
|
+
|
261
|
+
if (state !== this.previousState) {
|
262
|
+
this.oldState = this.previousState;
|
263
|
+
this.previousState = state;
|
264
|
+
}
|
265
|
+
|
266
|
+
return {
|
267
|
+
nativeEvent: {
|
268
|
+
numberOfPointers,
|
269
|
+
state,
|
270
|
+
pointerInside,
|
271
|
+
...this.transformNativeEvent(event),
|
272
|
+
// onHandlerStateChange only
|
273
|
+
handlerTag: this.handlerTag,
|
274
|
+
target: this.ref,
|
275
|
+
oldState: this.oldState
|
276
|
+
},
|
277
|
+
timeStamp: Date.now()
|
278
|
+
};
|
279
|
+
}
|
280
|
+
|
281
|
+
transformNativeEvent(_event) {
|
282
|
+
return {};
|
283
|
+
}
|
284
|
+
|
285
|
+
cancelPendingGestures(event) {
|
286
|
+
for (const gesture of Object.values(this.pendingGestures)) {
|
287
|
+
if (gesture && gesture.isGestureRunning) {
|
288
|
+
gesture.hasGestureFailed = true;
|
289
|
+
gesture.cancelEvent(event);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
notifyPendingGestures() {
|
295
|
+
for (const gesture of Object.values(this.pendingGestures)) {
|
296
|
+
if (gesture) {
|
297
|
+
gesture.onWaitingEnded(this);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
} // FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input
|
301
|
+
|
302
|
+
|
303
|
+
onGestureEnded(event) {
|
304
|
+
this.isGestureRunning = false;
|
305
|
+
this.cancelPendingGestures(event);
|
306
|
+
}
|
307
|
+
|
308
|
+
forceInvalidate(event) {
|
309
|
+
if (this.isGestureRunning) {
|
310
|
+
this.hasGestureFailed = true;
|
311
|
+
this.cancelEvent(event);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
cancelEvent(event) {
|
316
|
+
this.notifyPendingGestures();
|
317
|
+
this.sendEvent({ ...event,
|
318
|
+
eventType: Hammer.INPUT_CANCEL,
|
319
|
+
isFinal: true
|
320
|
+
});
|
321
|
+
this.onGestureEnded(event);
|
322
|
+
}
|
323
|
+
|
324
|
+
onRawEvent({
|
325
|
+
isFirst
|
326
|
+
}) {
|
327
|
+
if (isFirst) {
|
328
|
+
this.hasGestureFailed = false;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
setView(ref, propsRef) {
|
333
|
+
if (ref == null) {
|
334
|
+
this.destroy();
|
335
|
+
this.view = null;
|
336
|
+
return;
|
337
|
+
}
|
338
|
+
|
339
|
+
this.propsRef = propsRef;
|
340
|
+
this.ref = ref;
|
341
|
+
this.view = findNodeHandle(ref);
|
342
|
+
this.hammer = new Hammer.Manager(this.view);
|
343
|
+
this.oldState = State.UNDETERMINED;
|
344
|
+
this.previousState = State.UNDETERMINED;
|
345
|
+
this.lastSentState = null;
|
346
|
+
const {
|
347
|
+
NativeGestureClass
|
348
|
+
} = this; // @ts-ignore TODO(TS)
|
349
|
+
|
350
|
+
const gesture = new NativeGestureClass(this.getHammerConfig());
|
351
|
+
this.hammer.add(gesture);
|
352
|
+
this.hammer.on('hammer.input', ev => {
|
353
|
+
if (!this.config.enabled) {
|
354
|
+
this.hasGestureFailed = false;
|
355
|
+
this.isGestureRunning = false;
|
356
|
+
return;
|
357
|
+
}
|
358
|
+
|
359
|
+
this.onRawEvent(ev); // TODO: Bacon: Check against something other than null
|
360
|
+
// The isFirst value is not called when the first rotation is calculated.
|
361
|
+
|
362
|
+
if (this.initialRotation === null && ev.rotation !== 0) {
|
363
|
+
this.initialRotation = ev.rotation;
|
364
|
+
}
|
365
|
+
|
366
|
+
if (ev.isFinal) {
|
367
|
+
// in favor of a willFail otherwise the last frame of the gesture will be captured.
|
368
|
+
setTimeout(() => {
|
369
|
+
this.initialRotation = null;
|
370
|
+
this.hasGestureFailed = false;
|
371
|
+
});
|
372
|
+
}
|
373
|
+
});
|
374
|
+
this.setupEvents();
|
375
|
+
this.sync();
|
376
|
+
}
|
377
|
+
|
378
|
+
setupEvents() {
|
379
|
+
// TODO(TS) Hammer types aren't exactly that what we get in runtime
|
380
|
+
if (!this.isDiscrete) {
|
381
|
+
this.hammer.on(`${this.name}start`, event => this.onStart(event));
|
382
|
+
this.hammer.on(`${this.name}end ${this.name}cancel`, event => {
|
383
|
+
this.onGestureEnded(event);
|
384
|
+
});
|
385
|
+
}
|
386
|
+
|
387
|
+
this.hammer.on(this.name, ev => this.onGestureActivated(ev)); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged
|
388
|
+
}
|
389
|
+
|
390
|
+
onStart({
|
391
|
+
deltaX,
|
392
|
+
deltaY,
|
393
|
+
rotation
|
394
|
+
}) {
|
395
|
+
// Reset the state for the next gesture
|
396
|
+
this.oldState = State.UNDETERMINED;
|
397
|
+
this.previousState = State.UNDETERMINED;
|
398
|
+
this.lastSentState = null;
|
399
|
+
this.isGestureRunning = true;
|
400
|
+
this.__initialX = deltaX;
|
401
|
+
this.__initialY = deltaY;
|
402
|
+
this.initialRotation = rotation;
|
403
|
+
}
|
404
|
+
|
405
|
+
onGestureActivated(ev) {
|
406
|
+
this.sendEvent(ev);
|
407
|
+
}
|
408
|
+
|
409
|
+
onSuccess() {}
|
410
|
+
|
411
|
+
_getPendingGestures() {
|
412
|
+
if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {
|
413
|
+
// Get the list of gestures that this gesture is still waiting for.
|
414
|
+
// Use `=== false` in case a ref that isn't a gesture handler is used.
|
415
|
+
const stillWaiting = this.config.waitFor.filter(({
|
416
|
+
hasGestureFailed
|
417
|
+
}) => hasGestureFailed === false);
|
418
|
+
return stillWaiting;
|
419
|
+
}
|
420
|
+
|
421
|
+
return [];
|
422
|
+
}
|
423
|
+
|
424
|
+
getHammerConfig() {
|
425
|
+
const pointers = this.config.minPointers === this.config.maxPointers ? this.config.minPointers : 0;
|
426
|
+
return {
|
427
|
+
pointers
|
428
|
+
};
|
429
|
+
}
|
430
|
+
|
431
|
+
simulateCancelEvent(_inputData) {}
|
432
|
+
|
433
|
+
} // TODO(TS) investigate this method
|
434
|
+
// Used for sending data to a callback or AnimatedEvent
|
435
|
+
|
436
|
+
|
437
|
+
function invokeNullableMethod(method, event) {
|
438
|
+
if (method) {
|
439
|
+
if (typeof method === 'function') {
|
440
|
+
method(event);
|
441
|
+
} else {
|
442
|
+
// For use with reanimated's AnimatedEvent
|
443
|
+
if ('__getHandler' in method && typeof method.__getHandler === 'function') {
|
444
|
+
const handler = method.__getHandler();
|
445
|
+
|
446
|
+
invokeNullableMethod(handler, event);
|
447
|
+
} else {
|
448
|
+
if ('__nodeConfig' in method) {
|
449
|
+
const {
|
450
|
+
argMapping
|
451
|
+
} = method.__nodeConfig;
|
452
|
+
|
453
|
+
if (Array.isArray(argMapping)) {
|
454
|
+
for (const [index, [key, value]] of argMapping.entries()) {
|
455
|
+
if (key in event.nativeEvent) {
|
456
|
+
// @ts-ignore fix method type
|
457
|
+
const nativeValue = event.nativeEvent[key];
|
458
|
+
|
459
|
+
if (value && value.setValue) {
|
460
|
+
// Reanimated API
|
461
|
+
value.setValue(nativeValue);
|
462
|
+
} else {
|
463
|
+
// RN Animated API
|
464
|
+
method.__nodeConfig.argMapping[index] = [key, nativeValue];
|
465
|
+
}
|
466
|
+
}
|
467
|
+
}
|
468
|
+
}
|
469
|
+
}
|
470
|
+
}
|
471
|
+
}
|
472
|
+
}
|
473
|
+
} // Validate the props
|
474
|
+
|
475
|
+
|
476
|
+
function ensureConfig(config) {
|
477
|
+
const props = { ...config
|
478
|
+
}; // TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)
|
479
|
+
|
480
|
+
if ('minDist' in config) {
|
481
|
+
props.minDist = config.minDist;
|
482
|
+
props.minDistSq = props.minDist * props.minDist;
|
483
|
+
}
|
484
|
+
|
485
|
+
if ('minVelocity' in config) {
|
486
|
+
props.minVelocity = config.minVelocity;
|
487
|
+
props.minVelocitySq = props.minVelocity * props.minVelocity;
|
488
|
+
}
|
489
|
+
|
490
|
+
if ('maxDist' in config) {
|
491
|
+
props.maxDist = config.maxDist;
|
492
|
+
props.maxDistSq = config.maxDist * config.maxDist;
|
493
|
+
}
|
494
|
+
|
495
|
+
if ('waitFor' in config) {
|
496
|
+
props.waitFor = asArray(config.waitFor).map(({
|
497
|
+
handlerTag
|
498
|
+
}) => NodeManager.getHandler(handlerTag)).filter(v => v);
|
499
|
+
} else {
|
500
|
+
props.waitFor = null;
|
501
|
+
}
|
502
|
+
|
503
|
+
const configProps = ['minPointers', 'maxPointers', 'minDist', 'maxDist', 'maxDistSq', 'minVelocitySq', 'minDistSq', 'minVelocity', 'failOffsetXStart', 'failOffsetYStart', 'failOffsetXEnd', 'failOffsetYEnd', 'activeOffsetXStart', 'activeOffsetXEnd', 'activeOffsetYStart', 'activeOffsetYEnd'];
|
504
|
+
configProps.forEach(prop => {
|
505
|
+
if (typeof props[prop] === 'undefined') {
|
506
|
+
props[prop] = Number.NaN;
|
507
|
+
}
|
508
|
+
});
|
509
|
+
return props; // TODO(TS) how to convince TS that props are filled?
|
510
|
+
}
|
511
|
+
|
512
|
+
function asArray(value) {
|
513
|
+
// TODO(TS) use config.waitFor type
|
514
|
+
return value == null ? [] : Array.isArray(value) ? value : [value];
|
515
|
+
}
|
516
|
+
|
517
|
+
export default GestureHandler;
|
518
|
+
//# sourceMappingURL=GestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["GestureHandler.ts"],"names":["Hammer","findNodeHandle","State","EventMap","NodeManager","gestureInstances","GestureHandler","id","name","gestureInstance","isDiscrete","shouldEnableGestureOnSetup","Error","constructor","UNDETERMINED","Array","isArray","config","waitFor","gesture","removePendingGesture","clearSelfAsPending","hammer","stop","destroy","x","y","rect","view","getBoundingClientRect","pointerInside","left","right","top","bottom","nativeEvent","onGestureHandlerEvent","onGestureHandlerStateChange","propsRef","current","event","transformEventData","invokeNullableMethod","lastSentState","state","get","enable","recognizer","inputData","enabled","isGestureRunning","hasGestureFailed","options","maxPointers","_stillWaiting","_getPendingGestures","length","hasCustomActivationCriteria","deltaRotation","initialRotation","rotation","success","failed","isGestureEnabledForEvent","getConfig","simulateCancelEvent","params","getHammerConfig","set","onWaitingEnded","_gesture","pendingGestures","addPendingGesture","_config","_recognizer","_event","NativeGestureClass","updateHasCustomActivationCriteria","updateGestureConfig","props","ensureConfig","sync","getState","type","eventType","numberOfPointers","changedTouch","changedPointers","isPointInView","clientX","clientY","previousState","oldState","transformNativeEvent","handlerTag","target","ref","timeStamp","Date","now","cancelPendingGestures","Object","values","cancelEvent","notifyPendingGestures","onGestureEnded","forceInvalidate","sendEvent","INPUT_CANCEL","isFinal","onRawEvent","isFirst","setView","Manager","add","on","ev","setTimeout","setupEvents","onStart","onGestureActivated","deltaX","deltaY","__initialX","__initialY","onSuccess","stillWaiting","filter","pointers","minPointers","_inputData","method","__getHandler","handler","argMapping","__nodeConfig","index","key","value","entries","nativeValue","setValue","minDist","minDistSq","minVelocity","minVelocitySq","maxDist","maxDistSq","asArray","map","getHandler","v","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AR,CAAP,CACbmI,GADa,CACT,CAAC;AAAEvD,MAAAA;AAAF,KAAD,KACH1F,WAAW,CAACkJ,UAAZ,CAAuBxD,UAAvB,CAFY,EAIbiC,MAJa,CAILwB,CAAD,IAAOA,CAJD,CAAhB;AAKD,GAND,MAMO;AACLxE,IAAAA,KAAK,CAAC7D,OAAN,GAAgB,IAAhB;AACD;;AAED,QAAMsI,WAAW,GAAG,CAClB,aADkB,EAElB,aAFkB,EAGlB,SAHkB,EAIlB,SAJkB,EAKlB,WALkB,EAMlB,eANkB,EAOlB,WAPkB,EAQlB,aARkB,EASlB,kBATkB,EAUlB,kBAVkB,EAWlB,gBAXkB,EAYlB,gBAZkB,EAalB,oBAbkB,EAclB,kBAdkB,EAelB,oBAfkB,EAgBlB,kBAhBkB,CAApB;AAkBAA,EAAAA,WAAW,CAACC,OAAZ,CAAqBC,IAAD,IAAsC;AACxD,QAAI,OAAO3E,KAAK,CAAC2E,IAAD,CAAZ,KAAuB,WAA3B,EAAwC;AACtC3E,MAAAA,KAAK,CAAC2E,IAAD,CAAL,GAAcC,MAAM,CAACC,GAArB;AACD;AACF,GAJD;AAKA,SAAO7E,KAAP,CAjDsD,CAiDpB;AACnC;;AAED,SAASqE,OAAT,CAAoBV,KAApB,EAAoC;AAClC;AACA,SAAOA,KAAK,IAAI,IAAT,GAAgB,EAAhB,GAAqB3H,KAAK,CAACC,OAAN,CAAc0H,KAAd,IAAuBA,KAAvB,GAA+B,CAACA,KAAD,CAA3D;AACD;;AAED,eAAepI,cAAf","sourcesContent":["/* eslint-disable eslint-comments/no-unlimited-disable */\n/* eslint-disable */\nimport Hammer from '@egjs/hammerjs';\nimport { findNodeHandle } from 'react-native';\n\nimport { State } from '../State';\nimport { EventMap } from './constants';\nimport * as NodeManager from './NodeManager';\n\n// TODO(TS) Replace with HammerInput if https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438/files is merged\nexport type HammerInputExt = Omit<HammerInput, 'destroy' | 'handler' | 'init'>;\n\nexport type Config = Partial<{\n enabled: boolean;\n minPointers: number;\n maxPointers: number;\n minDist: number;\n minDistSq: number;\n minVelocity: number;\n minVelocitySq: number;\n maxDist: number;\n maxDistSq: number;\n failOffsetXStart: number;\n failOffsetYStart: number;\n failOffsetXEnd: number;\n failOffsetYEnd: number;\n activeOffsetXStart: number;\n activeOffsetXEnd: number;\n activeOffsetYStart: number;\n activeOffsetYEnd: number;\n waitFor: any[] | null;\n}>;\n\ntype NativeEvent = ReturnType<GestureHandler['transformEventData']>;\n\nlet gestureInstances = 0;\n\nabstract class GestureHandler {\n public handlerTag: any;\n public isGestureRunning = false;\n public view: number | null = null;\n protected hasCustomActivationCriteria: boolean;\n protected hasGestureFailed = false;\n protected hammer: HammerManager | null = null;\n protected initialRotation: number | null = null;\n protected __initialX: any;\n protected __initialY: any;\n protected config: Config = {};\n protected previousState: State = State.UNDETERMINED;\n private pendingGestures: Record<string, this> = {};\n private oldState: State = State.UNDETERMINED;\n private lastSentState: State | null = null;\n private gestureInstance: number;\n private _stillWaiting: any;\n private propsRef: any;\n private ref: any;\n\n abstract get name(): string;\n\n get id() {\n return `${this.name}${this.gestureInstance}`;\n }\n\n get isDiscrete() {\n return false;\n }\n\n get shouldEnableGestureOnSetup(): boolean {\n throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');\n }\n\n constructor() {\n this.gestureInstance = gestureInstances++;\n this.hasCustomActivationCriteria = false;\n }\n\n getConfig() {\n return this.config;\n }\n\n onWaitingEnded(_gesture: this) {}\n\n removePendingGesture(id: string) {\n delete this.pendingGestures[id];\n }\n\n addPendingGesture(gesture: this) {\n this.pendingGestures[gesture.id] = gesture;\n }\n\n isGestureEnabledForEvent(\n _config: any,\n _recognizer: any,\n _event: any\n ): { failed?: boolean; success?: boolean } {\n return { success: true };\n }\n\n get NativeGestureClass(): RecognizerStatic {\n throw new Error('Must override GestureHandler.NativeGestureClass');\n }\n\n updateHasCustomActivationCriteria(_config: Config) {\n return true;\n }\n\n clearSelfAsPending = () => {\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.removePendingGesture(this.id);\n }\n }\n };\n\n updateGestureConfig({ enabled = true, ...props }) {\n this.clearSelfAsPending();\n\n this.config = ensureConfig({ enabled, ...props });\n this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(\n this.config\n );\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.addPendingGesture(this);\n }\n }\n\n if (this.hammer) {\n this.sync();\n }\n return this.config;\n }\n\n destroy = () => {\n this.clearSelfAsPending();\n\n if (this.hammer) {\n this.hammer.stop(false);\n this.hammer.destroy();\n }\n this.hammer = null;\n };\n\n isPointInView = ({ x, y }: { x: number; y: number }) => {\n // @ts-ignore FIXME(TS)\n const rect = this.view!.getBoundingClientRect();\n const pointerInside =\n x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n return pointerInside;\n };\n\n getState(type: keyof typeof EventMap): State {\n // @ts-ignore TODO(TS) check if this is needed\n if (type == 0) {\n return 0;\n }\n return EventMap[type];\n }\n\n transformEventData(event: HammerInputExt) {\n const { eventType, maxPointers: numberOfPointers } = event;\n // const direction = DirectionMap[ev.direction];\n const changedTouch = event.changedPointers[0];\n const pointerInside = this.isPointInView({\n x: changedTouch.clientX,\n y: changedTouch.clientY,\n });\n\n // TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.\n const state = this.getState(eventType as 1 | 2 | 4 | 8);\n if (state !== this.previousState) {\n this.oldState = this.previousState;\n this.previousState = state;\n }\n\n return {\n nativeEvent: {\n numberOfPointers,\n state,\n pointerInside,\n ...this.transformNativeEvent(event),\n // onHandlerStateChange only\n handlerTag: this.handlerTag,\n target: this.ref,\n oldState: this.oldState,\n },\n timeStamp: Date.now(),\n };\n }\n\n transformNativeEvent(_event: HammerInputExt) {\n return {};\n }\n\n sendEvent = (nativeEvent: HammerInputExt) => {\n const {\n onGestureHandlerEvent,\n onGestureHandlerStateChange,\n } = this.propsRef.current;\n\n const event = this.transformEventData(nativeEvent);\n\n invokeNullableMethod(onGestureHandlerEvent, event);\n if (this.lastSentState !== event.nativeEvent.state) {\n this.lastSentState = event.nativeEvent.state as State;\n invokeNullableMethod(onGestureHandlerStateChange, event);\n }\n };\n\n cancelPendingGestures(event: HammerInputExt) {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture && gesture.isGestureRunning) {\n gesture.hasGestureFailed = true;\n gesture.cancelEvent(event);\n }\n }\n }\n\n notifyPendingGestures() {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture) {\n gesture.onWaitingEnded(this);\n }\n }\n }\n\n // FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input\n onGestureEnded(event: HammerInputExt) {\n this.isGestureRunning = false;\n this.cancelPendingGestures(event);\n }\n\n forceInvalidate(event: HammerInputExt) {\n if (this.isGestureRunning) {\n this.hasGestureFailed = true;\n this.cancelEvent(event);\n }\n }\n\n cancelEvent(event: HammerInputExt) {\n this.notifyPendingGestures();\n this.sendEvent({\n ...event,\n eventType: Hammer.INPUT_CANCEL,\n isFinal: true,\n });\n this.onGestureEnded(event);\n }\n\n onRawEvent({ isFirst }: HammerInputExt) {\n if (isFirst) {\n this.hasGestureFailed = false;\n }\n }\n\n setView(ref: Parameters<typeof findNodeHandle>['0'], propsRef: any) {\n if (ref == null) {\n this.destroy();\n this.view = null;\n return;\n }\n\n this.propsRef = propsRef;\n this.ref = ref;\n\n this.view = findNodeHandle(ref);\n this.hammer = new Hammer.Manager(this.view as any);\n\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n const { NativeGestureClass } = this;\n // @ts-ignore TODO(TS)\n const gesture = new NativeGestureClass(this.getHammerConfig());\n this.hammer.add(gesture);\n\n this.hammer.on('hammer.input', (ev: HammerInput) => {\n if (!this.config.enabled) {\n this.hasGestureFailed = false;\n this.isGestureRunning = false;\n return;\n }\n\n this.onRawEvent((ev as unknown) as HammerInputExt);\n\n // TODO: Bacon: Check against something other than null\n // The isFirst value is not called when the first rotation is calculated.\n if (this.initialRotation === null && ev.rotation !== 0) {\n this.initialRotation = ev.rotation;\n }\n if (ev.isFinal) {\n // in favor of a willFail otherwise the last frame of the gesture will be captured.\n setTimeout(() => {\n this.initialRotation = null;\n this.hasGestureFailed = false;\n });\n }\n });\n\n this.setupEvents();\n this.sync();\n }\n\n setupEvents() {\n // TODO(TS) Hammer types aren't exactly that what we get in runtime\n if (!this.isDiscrete) {\n this.hammer!.on(`${this.name}start`, (event: HammerInput) =>\n this.onStart((event as unknown) as HammerInputExt)\n );\n this.hammer!.on(\n `${this.name}end ${this.name}cancel`,\n (event: HammerInput) => {\n this.onGestureEnded((event as unknown) as HammerInputExt);\n }\n );\n }\n this.hammer!.on(this.name, (ev: HammerInput) =>\n this.onGestureActivated((ev as unknown) as HammerInputExt)\n ); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged\n }\n\n onStart({ deltaX, deltaY, rotation }: HammerInputExt) {\n // Reset the state for the next gesture\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n this.isGestureRunning = true;\n this.__initialX = deltaX;\n this.__initialY = deltaY;\n this.initialRotation = rotation;\n }\n\n onGestureActivated(ev: HammerInputExt) {\n this.sendEvent(ev);\n }\n\n onSuccess() {}\n\n _getPendingGestures() {\n if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {\n // Get the list of gestures that this gesture is still waiting for.\n // Use `=== false` in case a ref that isn't a gesture handler is used.\n const stillWaiting = this.config.waitFor.filter(\n ({ hasGestureFailed }) => hasGestureFailed === false\n );\n return stillWaiting;\n }\n return [];\n }\n\n getHammerConfig() {\n const pointers =\n this.config.minPointers === this.config.maxPointers\n ? this.config.minPointers\n : 0;\n return {\n pointers,\n };\n }\n\n sync = () => {\n const gesture = this.hammer!.get(this.name);\n if (!gesture) return;\n\n const enable = (recognizer: any, inputData: any) => {\n if (!this.config.enabled) {\n this.isGestureRunning = false;\n this.hasGestureFailed = false;\n return false;\n }\n\n // Prevent events before the system is ready.\n if (\n !inputData ||\n !recognizer.options ||\n typeof inputData.maxPointers === 'undefined'\n ) {\n return this.shouldEnableGestureOnSetup;\n }\n\n if (this.hasGestureFailed) {\n return false;\n }\n\n if (!this.isDiscrete) {\n if (this.isGestureRunning) {\n return true;\n }\n // The built-in hammer.js \"waitFor\" doesn't work across multiple views.\n // Only process if there are views to wait for.\n this._stillWaiting = this._getPendingGestures();\n // This gesture should continue waiting.\n if (this._stillWaiting.length) {\n // Check to see if one of the gestures you're waiting for has started.\n // If it has then the gesture should fail.\n for (const gesture of this._stillWaiting) {\n // When the target gesture has started, this gesture must force fail.\n if (!gesture.isDiscrete && gesture.isGestureRunning) {\n this.hasGestureFailed = true;\n this.isGestureRunning = false;\n return false;\n }\n }\n // This gesture shouldn't start until the others have finished.\n return false;\n }\n }\n\n // Use default behaviour\n if (!this.hasCustomActivationCriteria) {\n return true;\n }\n\n const deltaRotation =\n this.initialRotation == null\n ? 0\n : inputData.rotation - this.initialRotation;\n // @ts-ignore FIXME(TS)\n const { success, failed } = this.isGestureEnabledForEvent(\n this.getConfig(),\n recognizer,\n {\n ...inputData,\n deltaRotation,\n }\n );\n\n if (failed) {\n this.simulateCancelEvent(inputData);\n this.hasGestureFailed = true;\n }\n return success;\n };\n\n const params = this.getHammerConfig();\n // @ts-ignore FIXME(TS)\n gesture.set({ ...params, enable });\n };\n\n simulateCancelEvent(_inputData: any) {}\n}\n\n// TODO(TS) investigate this method\n// Used for sending data to a callback or AnimatedEvent\nfunction invokeNullableMethod(\n method:\n | ((event: NativeEvent) => void)\n | { __getHandler: () => (event: NativeEvent) => void }\n | { __nodeConfig: { argMapping: any } },\n event: NativeEvent\n) {\n if (method) {\n if (typeof method === 'function') {\n method(event);\n } else {\n // For use with reanimated's AnimatedEvent\n if (\n '__getHandler' in method &&\n typeof method.__getHandler === 'function'\n ) {\n const handler = method.__getHandler();\n invokeNullableMethod(handler, event);\n } else {\n if ('__nodeConfig' in method) {\n const { argMapping } = method.__nodeConfig;\n if (Array.isArray(argMapping)) {\n for (const [index, [key, value]] of argMapping.entries()) {\n if (key in event.nativeEvent) {\n // @ts-ignore fix method type\n const nativeValue = event.nativeEvent[key];\n if (value && value.setValue) {\n // Reanimated API\n value.setValue(nativeValue);\n } else {\n // RN Animated API\n method.__nodeConfig.argMapping[index] = [key, nativeValue];\n }\n }\n }\n }\n }\n }\n }\n }\n}\n\n// Validate the props\nfunction ensureConfig(config: Config): Required<Config> {\n const props = { ...config };\n\n // TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)\n if ('minDist' in config) {\n props.minDist = config.minDist;\n props.minDistSq = props.minDist! * props.minDist!;\n }\n if ('minVelocity' in config) {\n props.minVelocity = config.minVelocity;\n props.minVelocitySq = props.minVelocity! * props.minVelocity!;\n }\n if ('maxDist' in config) {\n props.maxDist = config.maxDist;\n props.maxDistSq = config.maxDist! * config.maxDist!;\n }\n if ('waitFor' in config) {\n props.waitFor = asArray(config.waitFor)\n .map(({ handlerTag }: { handlerTag: number }) =>\n NodeManager.getHandler(handlerTag)\n )\n .filter((v) => v);\n } else {\n props.waitFor = null;\n }\n\n const configProps = [\n 'minPointers',\n 'maxPointers',\n 'minDist',\n 'maxDist',\n 'maxDistSq',\n 'minVelocitySq',\n 'minDistSq',\n 'minVelocity',\n 'failOffsetXStart',\n 'failOffsetYStart',\n 'failOffsetXEnd',\n 'failOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n ] as const;\n configProps.forEach((prop: typeof configProps[number]) => {\n if (typeof props[prop] === 'undefined') {\n props[prop] = Number.NaN;\n }\n });\n return props as Required<Config>; // TODO(TS) how to convince TS that props are filled?\n}\n\nfunction asArray<T>(value: T | T[]) {\n // TODO(TS) use config.waitFor type\n return value == null ? [] : Array.isArray(value) ? value : [value];\n}\n\nexport default GestureHandler;\n"]}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import GestureHandler from './GestureHandler';
|
2
|
+
/**
|
3
|
+
* The base class for **Rotation** and **Pinch** gesture handlers.
|
4
|
+
*/
|
5
|
+
|
6
|
+
class IndiscreteGestureHandler extends GestureHandler {
|
7
|
+
get shouldEnableGestureOnSetup() {
|
8
|
+
return false;
|
9
|
+
}
|
10
|
+
|
11
|
+
updateGestureConfig({
|
12
|
+
minPointers = 2,
|
13
|
+
maxPointers = 2,
|
14
|
+
...props
|
15
|
+
}) {
|
16
|
+
return super.updateGestureConfig({
|
17
|
+
minPointers,
|
18
|
+
maxPointers,
|
19
|
+
...props
|
20
|
+
});
|
21
|
+
}
|
22
|
+
|
23
|
+
isGestureEnabledForEvent({
|
24
|
+
minPointers,
|
25
|
+
maxPointers
|
26
|
+
}, _recognizer, {
|
27
|
+
maxPointers: pointerLength
|
28
|
+
}) {
|
29
|
+
if (pointerLength > maxPointers) {
|
30
|
+
return {
|
31
|
+
failed: true
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
const validPointerCount = pointerLength >= minPointers;
|
36
|
+
return {
|
37
|
+
success: validPointerCount
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
export default IndiscreteGestureHandler;
|
44
|
+
//# sourceMappingURL=IndiscreteGestureHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["IndiscreteGestureHandler.ts"],"names":["GestureHandler","IndiscreteGestureHandler","shouldEnableGestureOnSetup","updateGestureConfig","minPointers","maxPointers","props","isGestureEnabledForEvent","_recognizer","pointerLength","failed","validPointerCount","success"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,kBAA3B;AAEA;AACA;AACA;;AACA,MAAeC,wBAAf,SAAgDD,cAAhD,CAA+D;AAC/B,MAA1BE,0BAA0B,GAAG;AAC/B,WAAO,KAAP;AACD;;AAEDC,EAAAA,mBAAmB,CAAC;AAAEC,IAAAA,WAAW,GAAG,CAAhB;AAAmBC,IAAAA,WAAW,GAAG,CAAjC;AAAoC,OAAGC;AAAvC,GAAD,EAAiD;AAClE,WAAO,MAAMH,mBAAN,CAA0B;AAC/BC,MAAAA,WAD+B;AAE/BC,MAAAA,WAF+B;AAG/B,SAAGC;AAH4B,KAA1B,CAAP;AAKD;;AAEDC,EAAAA,wBAAwB,CACtB;AAAEH,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GADsB,EAEtBG,WAFsB,EAGtB;AAAEH,IAAAA,WAAW,EAAEI;AAAf,GAHsB,EAItB;AACA,QAAIA,aAAa,GAAGJ,WAApB,EAAiC;AAC/B,aAAO;AAAEK,QAAAA,MAAM,EAAE;AAAV,OAAP;AACD;;AACD,UAAMC,iBAAiB,GAAGF,aAAa,IAAIL,WAA3C;AACA,WAAO;AACLQ,MAAAA,OAAO,EAAED;AADJ,KAAP;AAGD;;AAzB4D;;AA2B/D,eAAeV,wBAAf","sourcesContent":["import GestureHandler from './GestureHandler';\n\n/**\n * The base class for **Rotation** and **Pinch** gesture handlers.\n */\nabstract class IndiscreteGestureHandler extends GestureHandler {\n get shouldEnableGestureOnSetup() {\n return false;\n }\n\n updateGestureConfig({ minPointers = 2, maxPointers = 2, ...props }) {\n return super.updateGestureConfig({\n minPointers,\n maxPointers,\n ...props,\n });\n }\n\n isGestureEnabledForEvent(\n { minPointers, maxPointers }: any,\n _recognizer: any,\n { maxPointers: pointerLength }: any\n ) {\n if (pointerLength > maxPointers) {\n return { failed: true };\n }\n const validPointerCount = pointerLength >= minPointers;\n return {\n success: validPointerCount,\n };\n }\n}\nexport default IndiscreteGestureHandler;\n"]}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/* eslint-disable eslint-comments/no-unlimited-disable */
|
2
|
+
|
3
|
+
/* eslint-disable */
|
4
|
+
import Hammer from '@egjs/hammerjs';
|
5
|
+
import { State } from '../State';
|
6
|
+
import PressGestureHandler from './PressGestureHandler';
|
7
|
+
import { isnan, isValidNumber } from './utils';
|
8
|
+
|
9
|
+
class LongPressGestureHandler extends PressGestureHandler {
|
10
|
+
get minDurationMs() {
|
11
|
+
// @ts-ignore FIXNE(TS)
|
12
|
+
return isnan(this.config.minDurationMs) ? 251 : this.config.minDurationMs;
|
13
|
+
}
|
14
|
+
|
15
|
+
get maxDist() {
|
16
|
+
// @ts-ignore FIXNE(TS)
|
17
|
+
return isnan(this.config.maxDist) ? 9 : this.config.maxDist;
|
18
|
+
}
|
19
|
+
|
20
|
+
updateHasCustomActivationCriteria({
|
21
|
+
maxDistSq
|
22
|
+
}) {
|
23
|
+
return !isValidNumber(maxDistSq);
|
24
|
+
}
|
25
|
+
|
26
|
+
getConfig() {
|
27
|
+
if (!this.hasCustomActivationCriteria) {
|
28
|
+
// Default config
|
29
|
+
// If no params have been defined then this config should emulate the native gesture as closely as possible.
|
30
|
+
return {
|
31
|
+
shouldCancelWhenOutside: true,
|
32
|
+
maxDistSq: 10
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
return this.config;
|
37
|
+
}
|
38
|
+
|
39
|
+
getHammerConfig() {
|
40
|
+
return { ...super.getHammerConfig(),
|
41
|
+
// threshold: this.maxDist,
|
42
|
+
time: this.minDurationMs
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
getState(type) {
|
47
|
+
return {
|
48
|
+
[Hammer.INPUT_START]: State.ACTIVE,
|
49
|
+
[Hammer.INPUT_MOVE]: State.ACTIVE,
|
50
|
+
[Hammer.INPUT_END]: State.END,
|
51
|
+
[Hammer.INPUT_CANCEL]: State.FAILED
|
52
|
+
}[type];
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
export default LongPressGestureHandler;
|
58
|
+
//# sourceMappingURL=LongPressGestureHandler.js.map
|