react-native-gesture-handler 1.10.3 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/android/build.gradle +49 -1
- package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- package/android/gradle.properties +19 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +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/RNGestureHandlerEvents.h +9 -0
- package/ios/RNGestureHandlerEvents.m +34 -0
- package/ios/RNGestureHandlerManager.h +7 -0
- package/ios/RNGestureHandlerManager.m +62 -34
- package/ios/RNGestureHandlerModule.m +39 -3
- package/ios/RNGestureHandlerPointerTracker.h +25 -0
- package/ios/RNGestureHandlerPointerTracker.m +237 -0
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/RNManualActivationRecognizer.h +10 -0
- package/ios/RNManualActivationRecognizer.m +80 -0
- package/ios/RNRootViewGestureRecognizer.m +1 -1
- package/ios/RNTouchEventType.h +9 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +11 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +41 -37
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +31 -12
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +10 -6
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +52 -83
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +193 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +31 -0
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
- package/lib/commonjs/index.js +146 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +31 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/Errors.js +1 -1
- package/lib/commonjs/web/Errors.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -6
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/NodeManager.js +8 -2
- package/lib/commonjs/web/NodeManager.js.map +1 -1
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +2 -14
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -1
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -1
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +2 -2
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +43 -40
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js +29 -11
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/Swipeable.js +9 -6
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -1
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/gestureHandlerRootHOC.js +1 -1
- package/lib/module/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js +10 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js +10 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +106 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -0
- package/lib/module/handlers/PinchGestureHandler.js +9 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/module/handlers/RotationGestureHandler.js +9 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/module/handlers/TapGestureHandler.js +10 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +41 -76
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +402 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +120 -0
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/module/handlers/gestures/flingGesture.js +24 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +175 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +79 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/module/handlers/gestures/longPressGesture.js +24 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/module/handlers/gestures/manualGesture.js +22 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/module/handlers/gestures/nativeGesture.js +24 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/handlers/gestures/panGesture.js +135 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +36 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/module/handlers/gestures/rotationGesture.js +36 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/module/handlers/gestures/tapGesture.js +49 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +16 -0
- package/lib/module/handlers/handlersRegistry.js.map +1 -0
- package/lib/module/index.js +22 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +31 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/Errors.js +1 -1
- package/lib/module/web/Errors.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -6
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/module/web/NodeManager.js +8 -2
- package/lib/module/web/NodeManager.js.map +1 -1
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +50 -1
- package/lib/typescript/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +8 -35
- package/lib/typescript/components/Swipeable.d.ts +73 -6
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
- package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
- package/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
- package/lib/typescript/index.d.ts +29 -2
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +21 -2
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
- package/package.json +8 -5
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/RNGestureHandlerModule.ts +5 -1
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +114 -41
- package/src/components/GestureButtons.tsx +45 -5
- package/src/components/GestureComponents.tsx +47 -41
- package/src/components/Swipeable.tsx +108 -21
- package/src/components/touchables/GenericTouchable.tsx +2 -1
- package/src/components/touchables/TouchableOpacity.tsx +1 -1
- package/src/handlers/FlingGestureHandler.ts +57 -0
- package/src/handlers/ForceTouchGestureHandler.ts +83 -0
- package/src/handlers/LongPressGestureHandler.ts +84 -0
- package/src/handlers/NativeViewGestureHandler.ts +31 -7
- package/src/handlers/PanGestureHandler.ts +321 -0
- package/src/handlers/PinchGestureHandler.ts +46 -0
- package/src/handlers/RotationGestureHandler.ts +46 -0
- package/src/handlers/TapGestureHandler.ts +90 -0
- package/src/handlers/createHandler.ts +54 -79
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +519 -0
- package/src/handlers/gestures/eventReceiver.ts +151 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +74 -0
- package/src/handlers/gestures/gesture.ts +292 -0
- package/src/handlers/gestures/gestureComposition.ts +109 -0
- package/src/handlers/gestures/gestureObjects.ts +79 -0
- package/src/handlers/gestures/gestureStateManager.ts +60 -0
- package/src/handlers/gestures/longPressGesture.ts +27 -0
- package/src/handlers/gestures/manualGesture.ts +31 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +147 -0
- package/src/handlers/gestures/pinchGesture.ts +51 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +51 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +57 -17
- package/src/init.ts +5 -0
- package/src/mocks.ts +42 -2
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +1 -2
- package/src/web/NodeManager.ts +5 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
- package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
- package/lib/commonjs/handlers/gestureHandlers.js +0 -236
- package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
- package/lib/module/handlers/gestureHandlers.js +0 -216
- package/lib/module/handlers/gestureHandlers.js.map +0 -1
- package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
- package/src/handlers/gestureHandlers.ts +0 -511
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
package com.swmansion.gesturehandler.react;
|
|
2
|
-
|
|
3
|
-
import android.annotation.SuppressLint;
|
|
4
|
-
import android.annotation.TargetApi;
|
|
5
|
-
import android.content.Context;
|
|
6
|
-
import android.content.res.ColorStateList;
|
|
7
|
-
import android.graphics.Color;
|
|
8
|
-
import android.graphics.drawable.Drawable;
|
|
9
|
-
import android.graphics.drawable.LayerDrawable;
|
|
10
|
-
import android.graphics.drawable.PaintDrawable;
|
|
11
|
-
import android.graphics.drawable.RippleDrawable;
|
|
12
|
-
import android.os.Build;
|
|
13
|
-
import android.util.TypedValue;
|
|
14
|
-
import android.view.MotionEvent;
|
|
15
|
-
import android.view.View;
|
|
16
|
-
import android.view.ViewGroup;
|
|
17
|
-
|
|
18
|
-
import com.facebook.react.bridge.SoftAssertions;
|
|
19
|
-
import com.facebook.react.uimanager.PixelUtil;
|
|
20
|
-
import com.facebook.react.uimanager.ThemedReactContext;
|
|
21
|
-
import com.facebook.react.uimanager.ViewGroupManager;
|
|
22
|
-
import com.facebook.react.uimanager.ViewProps;
|
|
23
|
-
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
24
|
-
|
|
25
|
-
public class RNGestureHandlerButtonViewManager extends
|
|
26
|
-
ViewGroupManager<RNGestureHandlerButtonViewManager.ButtonViewGroup> {
|
|
27
|
-
|
|
28
|
-
static class ButtonViewGroup extends ViewGroup {
|
|
29
|
-
|
|
30
|
-
static TypedValue sResolveOutValue = new TypedValue();
|
|
31
|
-
static ButtonViewGroup sResponder;
|
|
32
|
-
static OnClickListener sDummyClickListener = new OnClickListener() {
|
|
33
|
-
@Override
|
|
34
|
-
public void onClick(View v) { }
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
int mBackgroundColor = Color.TRANSPARENT;
|
|
38
|
-
// Using object because of handling null representing no value set.
|
|
39
|
-
Integer mRippleColor;
|
|
40
|
-
Integer mRippleRadius;
|
|
41
|
-
boolean mUseForeground = false;
|
|
42
|
-
boolean mUseBorderless = false;
|
|
43
|
-
float mBorderRadius = 0;
|
|
44
|
-
boolean mNeedBackgroundUpdate = false;
|
|
45
|
-
long mLastEventTime = 0;
|
|
46
|
-
public static final String SELECTABLE_ITEM_BACKGROUND = "selectableItemBackground";
|
|
47
|
-
public static final String SELECTABLE_ITEM_BACKGROUND_BORDERLESS = "selectableItemBackgroundBorderless";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
public ButtonViewGroup(Context context) {
|
|
51
|
-
super(context);
|
|
52
|
-
|
|
53
|
-
// we attach empty click listener to trigger tap sounds (see View#performClick())
|
|
54
|
-
setOnClickListener(sDummyClickListener);
|
|
55
|
-
setClickable(true);
|
|
56
|
-
setFocusable(true);
|
|
57
|
-
|
|
58
|
-
mNeedBackgroundUpdate = true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@Override
|
|
62
|
-
public void setBackgroundColor(int color) {
|
|
63
|
-
mBackgroundColor = color;
|
|
64
|
-
mNeedBackgroundUpdate = true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public void setRippleColor(Integer color) {
|
|
68
|
-
mRippleColor = color;
|
|
69
|
-
mNeedBackgroundUpdate = true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public void setRippleRadius(Integer radius) {
|
|
73
|
-
mRippleRadius = radius;
|
|
74
|
-
mNeedBackgroundUpdate = true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public void setBorderRadius(float borderRadius) {
|
|
78
|
-
mBorderRadius = borderRadius * getResources().getDisplayMetrics().density;
|
|
79
|
-
mNeedBackgroundUpdate = true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private Drawable applyRippleEffectWhenNeeded(Drawable selectable) {
|
|
83
|
-
if (mRippleColor != null
|
|
84
|
-
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
|
85
|
-
&& selectable instanceof RippleDrawable) {
|
|
86
|
-
int[][] states = new int[][]{ new int[]{ android.R.attr.state_enabled } };
|
|
87
|
-
int[] colors = new int[]{ mRippleColor };
|
|
88
|
-
ColorStateList colorStateList = new ColorStateList(states, colors);
|
|
89
|
-
((RippleDrawable) selectable).setColor(colorStateList);
|
|
90
|
-
}
|
|
91
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
|
92
|
-
&& mRippleRadius != null
|
|
93
|
-
&& selectable instanceof RippleDrawable) {
|
|
94
|
-
RippleDrawable rippleDrawable = (RippleDrawable) selectable;
|
|
95
|
-
rippleDrawable.setRadius((int) PixelUtil.toPixelFromDIP(mRippleRadius));
|
|
96
|
-
}
|
|
97
|
-
return selectable;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@Override
|
|
101
|
-
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
102
|
-
if (super.onInterceptTouchEvent(ev)) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
// We call `onTouchEvent` and wait until button changes state to `pressed`, if it's pressed
|
|
106
|
-
// we return true so that the gesture handler can activate.
|
|
107
|
-
onTouchEvent(ev);
|
|
108
|
-
return isPressed();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Buttons in RN are wrapped in NativeViewGestureHandler which manages
|
|
113
|
-
* calling onTouchEvent after activation of the handler. Problem is, in order to verify that
|
|
114
|
-
* underlying button implementation is interested in receiving touches we have to call onTouchEvent
|
|
115
|
-
* and check if button is pressed.
|
|
116
|
-
*
|
|
117
|
-
* This leads to invoking onTouchEvent twice which isn't idempotent in View - it calls OnClickListener
|
|
118
|
-
* and plays sound effect if OnClickListener was set.
|
|
119
|
-
*
|
|
120
|
-
* To mitigate this behavior we use mLastEventTime variable to check that we already handled
|
|
121
|
-
* the event in {@link #onInterceptTouchEvent(MotionEvent)}. We assume here that different events
|
|
122
|
-
* will have different event times.
|
|
123
|
-
*
|
|
124
|
-
* Reference:
|
|
125
|
-
* {@link com.swmansion.gesturehandler.NativeViewGestureHandler#onHandle(MotionEvent)} */
|
|
126
|
-
@SuppressLint("ClickableViewAccessibility")
|
|
127
|
-
@Override
|
|
128
|
-
public boolean onTouchEvent(MotionEvent event) {
|
|
129
|
-
long eventTime = event.getEventTime();
|
|
130
|
-
if (mLastEventTime != eventTime || mLastEventTime == 0) {
|
|
131
|
-
mLastEventTime = eventTime;
|
|
132
|
-
return super.onTouchEvent(event);
|
|
133
|
-
}
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private void updateBackground() {
|
|
138
|
-
if (!mNeedBackgroundUpdate) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
mNeedBackgroundUpdate = false;
|
|
142
|
-
if (mBackgroundColor == Color.TRANSPARENT) {
|
|
143
|
-
// reset background
|
|
144
|
-
setBackground(null);
|
|
145
|
-
}
|
|
146
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
147
|
-
// reset foreground
|
|
148
|
-
setForeground(null);
|
|
149
|
-
}
|
|
150
|
-
if (mUseForeground && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
151
|
-
setForeground(applyRippleEffectWhenNeeded(createSelectableDrawable()));
|
|
152
|
-
if (mBackgroundColor != Color.TRANSPARENT) {
|
|
153
|
-
setBackgroundColor(mBackgroundColor);
|
|
154
|
-
}
|
|
155
|
-
} else if (mBackgroundColor == Color.TRANSPARENT && mRippleColor == null) {
|
|
156
|
-
setBackground(createSelectableDrawable());
|
|
157
|
-
} else {
|
|
158
|
-
PaintDrawable colorDrawable = new PaintDrawable(mBackgroundColor);
|
|
159
|
-
Drawable selectable = createSelectableDrawable();
|
|
160
|
-
if (mBorderRadius != 0) {
|
|
161
|
-
// Radius-connected lines below ought to be considered
|
|
162
|
-
// as a temporary solution. It do not allow to set
|
|
163
|
-
// different radius on each corner. However, I suppose it's fairly
|
|
164
|
-
// fine for button-related use cases.
|
|
165
|
-
// Therefore it might be used as long as:
|
|
166
|
-
// 1. ReactViewManager is not a generic class with a possibility to handle another ViewGroup
|
|
167
|
-
// 2. There's no way to force native behavior of ReactViewGroup's superclass's onTouchEvent
|
|
168
|
-
colorDrawable.setCornerRadius(mBorderRadius);
|
|
169
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
|
170
|
-
&& selectable instanceof RippleDrawable) {
|
|
171
|
-
PaintDrawable mask = new PaintDrawable(Color.WHITE);
|
|
172
|
-
mask.setCornerRadius(mBorderRadius);
|
|
173
|
-
((RippleDrawable) selectable).setDrawableByLayerId(android.R.id.mask, mask);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
applyRippleEffectWhenNeeded(selectable);
|
|
177
|
-
LayerDrawable layerDrawable = new LayerDrawable(
|
|
178
|
-
new Drawable[] { colorDrawable, selectable});
|
|
179
|
-
setBackground(layerDrawable);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
public void setUseDrawableOnForeground(boolean useForeground) {
|
|
184
|
-
mUseForeground = useForeground;
|
|
185
|
-
mNeedBackgroundUpdate = true;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public void setUseBorderlessDrawable(boolean useBorderless) {
|
|
189
|
-
mUseBorderless = useBorderless;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private Drawable createSelectableDrawable() {
|
|
193
|
-
final int version = Build.VERSION.SDK_INT;
|
|
194
|
-
String identifier = mUseBorderless && version >= 21 ? SELECTABLE_ITEM_BACKGROUND_BORDERLESS
|
|
195
|
-
: SELECTABLE_ITEM_BACKGROUND;
|
|
196
|
-
int attrID = getAttrId(getContext(), identifier);
|
|
197
|
-
getContext().getTheme().resolveAttribute(attrID, sResolveOutValue, true);
|
|
198
|
-
if (version >= 21) {
|
|
199
|
-
return getResources().getDrawable(sResolveOutValue.resourceId, getContext().getTheme());
|
|
200
|
-
} else {
|
|
201
|
-
return getResources().getDrawable(sResolveOutValue.resourceId);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
206
|
-
private static int getAttrId(Context context, String attr) {
|
|
207
|
-
SoftAssertions.assertNotNull(attr);
|
|
208
|
-
if (SELECTABLE_ITEM_BACKGROUND.equals(attr)) {
|
|
209
|
-
return android.R.attr.selectableItemBackground;
|
|
210
|
-
} else if (SELECTABLE_ITEM_BACKGROUND_BORDERLESS.equals(attr)) {
|
|
211
|
-
return android.R.attr.selectableItemBackgroundBorderless;
|
|
212
|
-
} else {
|
|
213
|
-
return context.getResources().getIdentifier(attr, "attr", "android");
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
@Override
|
|
218
|
-
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
219
|
-
// No-op
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@Override
|
|
223
|
-
public void drawableHotspotChanged(float x, float y) {
|
|
224
|
-
if (sResponder == null || sResponder == this) {
|
|
225
|
-
super.drawableHotspotChanged(x, y);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
@Override
|
|
230
|
-
public void setPressed(boolean pressed) {
|
|
231
|
-
if (pressed && sResponder == null) {
|
|
232
|
-
// first button to be pressed grabs button responder
|
|
233
|
-
sResponder = this;
|
|
234
|
-
}
|
|
235
|
-
if (!pressed || sResponder == this) {
|
|
236
|
-
// we set pressed state only for current responder
|
|
237
|
-
super.setPressed(pressed);
|
|
238
|
-
}
|
|
239
|
-
if (!pressed && sResponder == this) {
|
|
240
|
-
// if the responder is no longer pressed we release button responder
|
|
241
|
-
sResponder = null;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@Override
|
|
246
|
-
public void dispatchDrawableHotspotChanged(float x, float y) {
|
|
247
|
-
// by default viewgroup would pass hotspot change events
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@Override
|
|
252
|
-
public String getName() {
|
|
253
|
-
return "RNGestureHandlerButton";
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
@Override
|
|
257
|
-
public ButtonViewGroup createViewInstance(ThemedReactContext context) {
|
|
258
|
-
return new ButtonViewGroup(context);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@TargetApi(Build.VERSION_CODES.M)
|
|
262
|
-
@ReactProp(name = "foreground")
|
|
263
|
-
public void setForeground(ButtonViewGroup view, boolean useDrawableOnForeground) {
|
|
264
|
-
view.setUseDrawableOnForeground(useDrawableOnForeground);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
@ReactProp(name = "borderless")
|
|
268
|
-
public void setBorderless(ButtonViewGroup view, boolean useBorderlessDrawable) {
|
|
269
|
-
view.setUseBorderlessDrawable(useBorderlessDrawable);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@ReactProp(name = "enabled")
|
|
273
|
-
public void setEnabled(ButtonViewGroup view, boolean enabled) {
|
|
274
|
-
view.setEnabled(enabled);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
@ReactProp(name = ViewProps.BORDER_RADIUS)
|
|
278
|
-
public void setBorderRadius(ButtonViewGroup view, float borderRadius) {
|
|
279
|
-
view.setBorderRadius(borderRadius);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@ReactProp(name = "rippleColor")
|
|
283
|
-
public void setRippleColor(ButtonViewGroup view, Integer rippleColor) {
|
|
284
|
-
view.setRippleColor(rippleColor);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
@ReactProp(name = "rippleRadius")
|
|
288
|
-
public void setRippleRadius(ButtonViewGroup view, Integer rippleRadius) {
|
|
289
|
-
view.setRippleRadius(rippleRadius);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
@Override
|
|
293
|
-
protected void onAfterUpdateTransaction(ButtonViewGroup view) {
|
|
294
|
-
view.updateBackground();
|
|
295
|
-
}
|
|
296
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
package com.swmansion.gesturehandler.react;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.os.Bundle;
|
|
5
|
-
import android.util.AttributeSet;
|
|
6
|
-
import android.view.MotionEvent;
|
|
7
|
-
|
|
8
|
-
import com.facebook.react.ReactInstanceManager;
|
|
9
|
-
import com.facebook.react.ReactRootView;
|
|
10
|
-
|
|
11
|
-
import androidx.annotation.Nullable;
|
|
12
|
-
|
|
13
|
-
public class RNGestureHandlerEnabledRootView extends ReactRootView {
|
|
14
|
-
|
|
15
|
-
private @Nullable ReactInstanceManager mReactInstanceManager;
|
|
16
|
-
private @Nullable RNGestureHandlerRootHelper mGestureRootHelper;
|
|
17
|
-
|
|
18
|
-
public RNGestureHandlerEnabledRootView(Context context) {
|
|
19
|
-
super(context);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public RNGestureHandlerEnabledRootView(Context context, AttributeSet attrs) {
|
|
23
|
-
super(context, attrs);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Override
|
|
27
|
-
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
|
28
|
-
if (mGestureRootHelper != null) {
|
|
29
|
-
mGestureRootHelper.requestDisallowInterceptTouchEvent(disallowIntercept);
|
|
30
|
-
}
|
|
31
|
-
super.requestDisallowInterceptTouchEvent(disallowIntercept);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Override
|
|
35
|
-
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
36
|
-
if (mGestureRootHelper != null && mGestureRootHelper.dispatchTouchEvent(ev)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return super.dispatchTouchEvent(ev);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* This method is used to enable root view to start processing touch events through the gesture
|
|
44
|
-
* handler library logic. Unless this method is called (which happens as a result of instantiating
|
|
45
|
-
* new gesture handler from JS) the root view component will just proxy all touch related methods
|
|
46
|
-
* to its superclass. Thus in the "disabled" state all touch related events will fallback to
|
|
47
|
-
* default RN behavior.
|
|
48
|
-
*/
|
|
49
|
-
public void initialize() {
|
|
50
|
-
if (mGestureRootHelper != null) {
|
|
51
|
-
throw new IllegalStateException("GestureHandler already initialized for root view " + this);
|
|
52
|
-
}
|
|
53
|
-
mGestureRootHelper = new RNGestureHandlerRootHelper(
|
|
54
|
-
mReactInstanceManager.getCurrentReactContext(), this);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public void tearDown() {
|
|
58
|
-
if (mGestureRootHelper != null) {
|
|
59
|
-
mGestureRootHelper.tearDown();
|
|
60
|
-
mGestureRootHelper = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@Override
|
|
65
|
-
public void startReactApplication(
|
|
66
|
-
ReactInstanceManager reactInstanceManager,
|
|
67
|
-
String moduleName,
|
|
68
|
-
@Nullable Bundle initialProperties) {
|
|
69
|
-
super.startReactApplication(reactInstanceManager, moduleName, initialProperties);
|
|
70
|
-
mReactInstanceManager = reactInstanceManager;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
package com.swmansion.gesturehandler.react;
|
|
2
|
-
|
|
3
|
-
import androidx.core.util.Pools;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.Arguments;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import com.facebook.react.uimanager.events.Event;
|
|
8
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
9
|
-
import com.swmansion.gesturehandler.GestureHandler;
|
|
10
|
-
|
|
11
|
-
import androidx.annotation.Nullable;
|
|
12
|
-
|
|
13
|
-
public class RNGestureHandlerEvent extends Event<RNGestureHandlerEvent> {
|
|
14
|
-
|
|
15
|
-
public static final String EVENT_NAME = "onGestureHandlerEvent";
|
|
16
|
-
|
|
17
|
-
private static final int TOUCH_EVENTS_POOL_SIZE = 7; // magic
|
|
18
|
-
|
|
19
|
-
private static final Pools.SynchronizedPool<RNGestureHandlerEvent> EVENTS_POOL =
|
|
20
|
-
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
|
|
21
|
-
|
|
22
|
-
public static RNGestureHandlerEvent obtain(
|
|
23
|
-
GestureHandler handler,
|
|
24
|
-
@Nullable RNGestureHandlerEventDataExtractor dataExtractor) {
|
|
25
|
-
RNGestureHandlerEvent event = EVENTS_POOL.acquire();
|
|
26
|
-
if (event == null) {
|
|
27
|
-
event = new RNGestureHandlerEvent();
|
|
28
|
-
}
|
|
29
|
-
event.init(handler, dataExtractor);
|
|
30
|
-
return event;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private WritableMap mExtraData;
|
|
34
|
-
private short mCoalescingKey;
|
|
35
|
-
|
|
36
|
-
private RNGestureHandlerEvent() {
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private void init(
|
|
40
|
-
GestureHandler handler,
|
|
41
|
-
@Nullable RNGestureHandlerEventDataExtractor dataExtractor) {
|
|
42
|
-
super.init(handler.getView().getId());
|
|
43
|
-
mExtraData = Arguments.createMap();
|
|
44
|
-
if (dataExtractor != null) {
|
|
45
|
-
dataExtractor.extractEventData(handler, mExtraData);
|
|
46
|
-
}
|
|
47
|
-
mExtraData.putInt("handlerTag", handler.getTag());
|
|
48
|
-
mExtraData.putInt("state", handler.getState());
|
|
49
|
-
mCoalescingKey = handler.getEventCoalescingKey();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Override
|
|
53
|
-
public void onDispose() {
|
|
54
|
-
mExtraData = null;
|
|
55
|
-
EVENTS_POOL.release(this);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@Override
|
|
59
|
-
public String getEventName() {
|
|
60
|
-
return EVENT_NAME;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@Override
|
|
64
|
-
public boolean canCoalesce() {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Override
|
|
69
|
-
public short getCoalescingKey() {
|
|
70
|
-
return mCoalescingKey;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@Override
|
|
74
|
-
public void dispatch(RCTEventEmitter rctEventEmitter) {
|
|
75
|
-
rctEventEmitter.receiveEvent(getViewTag(), EVENT_NAME, mExtraData);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
package com.swmansion.gesturehandler.react;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.WritableMap;
|
|
4
|
-
import com.swmansion.gesturehandler.GestureHandler;
|
|
5
|
-
|
|
6
|
-
public interface RNGestureHandlerEventDataExtractor<T extends GestureHandler> {
|
|
7
|
-
void extractEventData(T handler, WritableMap eventData);
|
|
8
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
package com.swmansion.gesturehandler.react;
|
|
2
|
-
|
|
3
|
-
import android.util.SparseArray;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
-
import com.swmansion.gesturehandler.GestureHandler;
|
|
8
|
-
import com.swmansion.gesturehandler.GestureHandlerInteractionController;
|
|
9
|
-
|
|
10
|
-
public class RNGestureHandlerInteractionManager implements GestureHandlerInteractionController {
|
|
11
|
-
|
|
12
|
-
private static final String KEY_WAIT_FOR = "waitFor";
|
|
13
|
-
private static final String KEY_SIMULTANEOUS_HANDLERS = "simultaneousHandlers";
|
|
14
|
-
|
|
15
|
-
private SparseArray<int[]> mWaitForRelations = new SparseArray<>();
|
|
16
|
-
private SparseArray<int[]> mSimultaneousRelations = new SparseArray<>();
|
|
17
|
-
|
|
18
|
-
public void dropRelationsForHandlerWithTag(int handlerTag) {
|
|
19
|
-
mWaitForRelations.remove(handlerTag);
|
|
20
|
-
mSimultaneousRelations.remove(handlerTag);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private int[] convertHandlerTagsArray(ReadableMap config, String key) {
|
|
24
|
-
ReadableArray array = config.getArray(key);
|
|
25
|
-
int[] result = new int[array.size()];
|
|
26
|
-
for (int i = 0; i < result.length; i++) {
|
|
27
|
-
result[i] = array.getInt(i);
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public void configureInteractions(GestureHandler handler, ReadableMap config) {
|
|
33
|
-
handler.setInteractionController(this);
|
|
34
|
-
if (config.hasKey(KEY_WAIT_FOR)) {
|
|
35
|
-
int[] tags = convertHandlerTagsArray(config, KEY_WAIT_FOR);
|
|
36
|
-
mWaitForRelations.put(handler.getTag(), tags);
|
|
37
|
-
}
|
|
38
|
-
if (config.hasKey(KEY_SIMULTANEOUS_HANDLERS)) {
|
|
39
|
-
int[] tags = convertHandlerTagsArray(config, KEY_SIMULTANEOUS_HANDLERS);
|
|
40
|
-
mSimultaneousRelations.put(handler.getTag(), tags);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Override
|
|
45
|
-
public boolean shouldWaitForHandlerFailure(GestureHandler handler, GestureHandler otherHandler) {
|
|
46
|
-
int[] waitForTags = mWaitForRelations.get(handler.getTag());
|
|
47
|
-
if (waitForTags != null) {
|
|
48
|
-
for (int i = 0; i < waitForTags.length; i++) {
|
|
49
|
-
if (waitForTags[i] == otherHandler.getTag()) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Override
|
|
58
|
-
public boolean shouldRequireHandlerToWaitForFailure(GestureHandler handler,
|
|
59
|
-
GestureHandler otherHandler) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@Override
|
|
64
|
-
public boolean shouldHandlerBeCancelledBy(GestureHandler handler, GestureHandler otherHandler) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Override
|
|
69
|
-
public boolean shouldRecognizeSimultaneously(GestureHandler handler,
|
|
70
|
-
GestureHandler otherHandler) {
|
|
71
|
-
int[] simultHandlerTags = mSimultaneousRelations.get(handler.getTag());
|
|
72
|
-
if (simultHandlerTags != null) {
|
|
73
|
-
for (int i = 0; i < simultHandlerTags.length; i++) {
|
|
74
|
-
if (simultHandlerTags[i] == otherHandler.getTag()) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public void reset() {
|
|
83
|
-
mWaitForRelations.clear();
|
|
84
|
-
mSimultaneousRelations.clear();
|
|
85
|
-
}
|
|
86
|
-
}
|