react-native-gesture-handler 1.10.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/DrawerLayout/package.json +3 -3
- package/README.md +7 -6
- package/Swipeable/package.json +3 -3
- package/android/build.gradle +48 -1
- package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- package/android/gradle.properties +19 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +713 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +562 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +289 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +88 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +79 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
- package/ios/Handlers/RNFlingHandler.m +78 -5
- package/ios/Handlers/RNForceTouchHandler.m +29 -4
- package/ios/Handlers/RNLongPressHandler.m +105 -3
- package/ios/Handlers/RNManualHandler.h +4 -0
- package/ios/Handlers/RNManualHandler.m +73 -0
- package/ios/Handlers/RNNativeViewHandler.m +30 -2
- package/ios/Handlers/RNPanHandler.m +64 -4
- package/ios/Handlers/RNPinchHandler.m +61 -2
- package/ios/Handlers/RNRotationHandler.m +60 -1
- package/ios/Handlers/RNTapHandler.m +55 -8
- package/ios/RNGestureHandler.h +18 -4
- package/ios/RNGestureHandler.m +123 -13
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/RNGestureHandlerEvents.h +9 -0
- package/ios/RNGestureHandlerEvents.m +34 -0
- package/ios/RNGestureHandlerManager.h +7 -0
- package/ios/RNGestureHandlerManager.m +62 -34
- package/ios/RNGestureHandlerModule.m +39 -3
- package/ios/RNGestureHandlerPointerTracker.h +25 -0
- package/ios/RNGestureHandlerPointerTracker.m +237 -0
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/RNManualActivationRecognizer.h +10 -0
- package/ios/RNManualActivationRecognizer.m +80 -0
- package/ios/RNRootViewGestureRecognizer.m +1 -1
- package/ios/RNTouchEventType.h +9 -0
- package/jestSetup.js +7 -1
- package/lib/commonjs/Directions.js +15 -0
- package/lib/commonjs/Directions.js.map +1 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +24 -0
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.js +20 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/PlatformConstants.js +15 -0
- package/lib/commonjs/PlatformConstants.js.map +1 -0
- package/lib/commonjs/PlatformConstants.web.js +14 -0
- package/lib/commonjs/PlatformConstants.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +22 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js +80 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/commonjs/State.js +18 -0
- package/lib/commonjs/State.js.map +1 -0
- package/lib/commonjs/components/DrawerLayout.js +535 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js +207 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +76 -0
- package/lib/commonjs/components/GestureComponents.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.web.js +46 -0
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -0
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +365 -0
- package/lib/commonjs/components/Swipeable.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +278 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js +109 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +100 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +12 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js +75 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +26 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/index.js +40 -0
- package/lib/commonjs/components/touchables/index.js.map +1 -0
- package/lib/commonjs/gestureHandlerRootHOC.js +39 -0
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +25 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +373 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -0
- package/lib/commonjs/handlers/createNativeWrapper.js +70 -0
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +426 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +124 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +39 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +185 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/panGesture.js +116 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +31 -0
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
- package/lib/commonjs/index.js +338 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +64 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/typeUtils.js +2 -0
- package/lib/commonjs/typeUtils.js.map +1 -0
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js +105 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/DraggingGestureHandler.js +53 -0
- package/lib/commonjs/web/DraggingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/Errors.js +16 -0
- package/lib/commonjs/web/Errors.js.map +1 -0
- package/lib/commonjs/web/FlingGestureHandler.js +170 -0
- package/lib/commonjs/web/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/GestureHandler.js +533 -0
- package/lib/commonjs/web/GestureHandler.js.map +1 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js +54 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/LongPressGestureHandler.js +71 -0
- package/lib/commonjs/web/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js +62 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NodeManager.js +43 -0
- package/lib/commonjs/web/NodeManager.js.map +1 -0
- package/lib/commonjs/web/PanGestureHandler.js +189 -0
- package/lib/commonjs/web/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PinchGestureHandler.js +40 -0
- package/lib/commonjs/web/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PressGestureHandler.js +188 -0
- package/lib/commonjs/web/PressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/RotationGestureHandler.js +44 -0
- package/lib/commonjs/web/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/web/TapGestureHandler.js +192 -0
- package/lib/commonjs/web/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/web/constants.js +64 -0
- package/lib/commonjs/web/constants.js.map +1 -0
- package/lib/commonjs/web/utils.js +42 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/module/Directions.js +7 -0
- package/lib/module/Directions.js.map +1 -0
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +10 -0
- package/lib/module/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/GestureHandlerRootView.js +7 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -0
- package/lib/module/PlatformConstants.js +5 -0
- package/lib/module/PlatformConstants.js.map +1 -0
- package/lib/module/PlatformConstants.web.js +7 -0
- package/lib/module/PlatformConstants.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +13 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.web.js +56 -0
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/module/State.js +10 -0
- package/lib/module/State.js.map +1 -0
- package/lib/module/components/DrawerLayout.js +520 -0
- package/lib/module/components/DrawerLayout.js.map +1 -0
- package/lib/module/components/GestureButtons.js +172 -0
- package/lib/module/components/GestureButtons.js.map +1 -0
- package/lib/module/components/GestureComponents.js +53 -0
- package/lib/module/components/GestureComponents.js.map +1 -0
- package/lib/module/components/GestureComponents.web.js +25 -0
- package/lib/module/components/GestureComponents.web.js.map +1 -0
- package/{dist/src → lib/module}/components/GestureHandlerButton.js +1 -0
- package/lib/module/components/GestureHandlerButton.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.web.js +9 -0
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +347 -0
- package/lib/module/components/Swipeable.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js +262 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js +95 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +84 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/TouchableNativeFeedback.js +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js +61 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/index.js +1 -0
- package/lib/module/components/touchables/index.js.map +1 -0
- package/lib/module/gestureHandlerRootHOC.js +21 -0
- package/lib/module/gestureHandlerRootHOC.js.map +1 -0
- package/lib/module/handlers/FlingGestureHandler.js +10 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js +10 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/module/handlers/NativeViewGestureHandler.js +11 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/handlers/PanGestureHandler.js +106 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -0
- package/lib/module/handlers/PinchGestureHandler.js +9 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/module/handlers/RotationGestureHandler.js +9 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/module/handlers/TapGestureHandler.js +10 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +348 -0
- package/lib/module/handlers/createHandler.js.map +1 -0
- package/lib/module/handlers/createNativeWrapper.js +58 -0
- package/lib/module/handlers/createNativeWrapper.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +389 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +109 -0
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/module/handlers/gestures/flingGesture.js +24 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js +29 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +167 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +79 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/module/handlers/gestures/longPressGesture.js +24 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/module/handlers/gestures/manualGesture.js +9 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/module/handlers/gestures/nativeGesture.js +24 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/handlers/gestures/panGesture.js +106 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +9 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/module/handlers/gestures/rotationGesture.js +9 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/module/handlers/gestures/tapGesture.js +49 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +16 -0
- package/lib/module/handlers/handlersRegistry.js.map +1 -0
- package/lib/module/index.js +34 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +54 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/typeUtils.js +2 -0
- package/lib/module/typeUtils.js.map +1 -0
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/DiscreteGestureHandler.js +94 -0
- package/lib/module/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/DraggingGestureHandler.js +40 -0
- package/lib/module/web/DraggingGestureHandler.js.map +1 -0
- package/lib/module/web/Errors.js +7 -0
- package/lib/module/web/Errors.js.map +1 -0
- package/lib/module/web/FlingGestureHandler.js +156 -0
- package/lib/module/web/FlingGestureHandler.js.map +1 -0
- package/lib/module/web/GestureHandler.js +518 -0
- package/lib/module/web/GestureHandler.js.map +1 -0
- package/lib/module/web/IndiscreteGestureHandler.js +44 -0
- package/lib/module/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/LongPressGestureHandler.js +58 -0
- package/lib/module/web/LongPressGestureHandler.js.map +1 -0
- package/lib/module/web/NativeViewGestureHandler.js +45 -0
- package/lib/module/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web/NodeManager.js +30 -0
- package/lib/module/web/NodeManager.js.map +1 -0
- package/lib/module/web/PanGestureHandler.js +175 -0
- package/lib/module/web/PanGestureHandler.js.map +1 -0
- package/lib/module/web/PinchGestureHandler.js +29 -0
- package/lib/module/web/PinchGestureHandler.js.map +1 -0
- package/lib/module/web/PressGestureHandler.js +174 -0
- package/lib/module/web/PressGestureHandler.js.map +1 -0
- package/lib/module/web/RotationGestureHandler.js +32 -0
- package/lib/module/web/RotationGestureHandler.js.map +1 -0
- package/lib/module/web/TapGestureHandler.js +180 -0
- package/lib/module/web/TapGestureHandler.js.map +1 -0
- package/lib/module/web/constants.js +43 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/utils.js +19 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/typescript/Directions.d.ts +7 -0
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -0
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -0
- package/{dist/src → lib/typescript}/PlatformConstants.d.ts +0 -0
- package/{dist/src → lib/typescript}/PlatformConstants.web.d.ts +0 -0
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.d.ts +1 -8
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.web.d.ts +1 -1
- package/{dist/src → lib/typescript}/State.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/DrawerLayout.d.ts +50 -1
- package/{dist/src → lib/typescript}/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +18 -0
- package/{dist/src → lib/typescript}/components/GestureComponents.web.d.ts +4 -4
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.web.d.ts +0 -0
- package/lib/typescript/components/Swipeable.d.ts +150 -0
- package/{dist/src → lib/typescript}/components/touchables/GenericTouchable.d.ts +3 -3
- package/{dist/src → lib/typescript}/components/touchables/TouchableHighlight.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.android.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableOpacity.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableWithoutFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/index.d.ts +0 -0
- package/{dist/src → lib/typescript}/gestureHandlerRootHOC.d.ts +0 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +27 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
- package/{dist/src → lib/typescript}/handlers/createHandler.d.ts +1 -1
- package/{dist/src → lib/typescript}/handlers/createNativeWrapper.d.ts +0 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/{dist/src → lib/typescript}/handlers/gestureHandlerTypesCompat.d.ts +8 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +10 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +93 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +5 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +19 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
- package/lib/typescript/index.d.ts +44 -0
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +43 -0
- package/{dist/src → lib/typescript}/typeUtils.d.ts +0 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/{dist/src → lib/typescript}/web/DiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/DraggingGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/Errors.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/FlingGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/GestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/IndiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/LongPressGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NativeViewGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NodeManager.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/PanGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PinchGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PressGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/RotationGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/TapGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/constants.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/utils.d.ts +0 -0
- package/package.json +38 -15
- package/src/Directions.ts +8 -2
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/PlatformConstants.ts +3 -2
- package/src/RNGestureHandlerModule.ts +15 -9
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +114 -41
- package/src/components/GestureButtons.tsx +45 -5
- package/src/components/GestureComponents.tsx +47 -41
- package/src/components/Swipeable.tsx +108 -21
- package/src/components/touchables/GenericTouchable.tsx +3 -2
- package/src/components/touchables/TouchableOpacity.tsx +1 -1
- package/src/handlers/FlingGestureHandler.ts +57 -0
- package/src/handlers/ForceTouchGestureHandler.ts +83 -0
- package/src/handlers/LongPressGestureHandler.ts +84 -0
- package/src/handlers/NativeViewGestureHandler.ts +31 -7
- package/src/handlers/PanGestureHandler.ts +321 -0
- package/src/handlers/PinchGestureHandler.ts +46 -0
- package/src/handlers/RotationGestureHandler.ts +46 -0
- package/src/handlers/TapGestureHandler.ts +90 -0
- package/src/handlers/createHandler.ts +60 -81
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +498 -0
- package/src/handlers/gestures/eventReceiver.ts +135 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +32 -0
- package/src/handlers/gestures/gesture.ts +279 -0
- package/src/handlers/gestures/gestureComposition.ts +109 -0
- package/src/handlers/gestures/gestureObjects.ts +79 -0
- package/src/handlers/gestures/gestureStateManager.ts +60 -0
- package/src/handlers/gestures/longPressGesture.ts +27 -0
- package/src/handlers/gestures/manualGesture.ts +11 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +105 -0
- package/src/handlers/gestures/pinchGesture.ts +12 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +12 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +156 -0
- package/src/init.ts +5 -0
- package/src/mocks.ts +65 -0
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +2 -3
- package/src/web/NativeViewGestureHandler.ts +1 -3
- package/src/web/NodeManager.ts +5 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
- package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -16
- package/dist/src/Directions.d.ts +0 -7
- package/dist/src/Directions.js +0 -2
- package/dist/src/GestureHandlerRootView.android.d.ts +0 -4
- package/dist/src/GestureHandlerRootView.android.expo.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.android.expo.js +0 -2
- package/dist/src/GestureHandlerRootView.android.js +0 -21
- package/dist/src/GestureHandlerRootView.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.js +0 -2
- package/dist/src/PlatformConstants.js +0 -2
- package/dist/src/PlatformConstants.web.js +0 -5
- package/dist/src/RNGestureHandlerModule.js +0 -3
- package/dist/src/RNGestureHandlerModule.web.js +0 -47
- package/dist/src/State.js +0 -9
- package/dist/src/__mocks__/RNGestureHandlerModule.d.ts +0 -23
- package/dist/src/__mocks__/RNGestureHandlerModule.js +0 -25
- package/dist/src/components/DrawerLayout.js +0 -391
- package/dist/src/components/GestureButtons.js +0 -113
- package/dist/src/components/GestureComponents.d.ts +0 -45
- package/dist/src/components/GestureComponents.js +0 -18
- package/dist/src/components/GestureComponents.web.js +0 -18
- package/dist/src/components/GestureHandlerButton.web.js +0 -3
- package/dist/src/components/Swipeable.d.ts +0 -83
- package/dist/src/components/Swipeable.js +0 -249
- package/dist/src/components/touchables/GenericTouchable.js +0 -210
- package/dist/src/components/touchables/TouchableHighlight.js +0 -73
- package/dist/src/components/touchables/TouchableNativeFeedback.android.js +0 -63
- package/dist/src/components/touchables/TouchableOpacity.js +0 -50
- package/dist/src/components/touchables/TouchableWithoutFeedback.js +0 -5
- package/dist/src/gestureHandlerRootHOC.js +0 -17
- package/dist/src/handlers/NativeViewGestureHandler.d.ts +0 -12
- package/dist/src/handlers/NativeViewGestureHandler.js +0 -13
- package/dist/src/handlers/createHandler.js +0 -292
- package/dist/src/handlers/createNativeWrapper.js +0 -51
- package/dist/src/handlers/gestureHandlerTypesCompat.js +0 -1
- package/dist/src/handlers/gestureHandlers.d.ts +0 -158
- package/dist/src/handlers/gestureHandlers.js +0 -247
- package/dist/src/typeUtils.js +0 -1
- package/dist/src/web/DiscreteGestureHandler.js +0 -48
- package/dist/src/web/DraggingGestureHandler.js +0 -25
- package/dist/src/web/Errors.js +0 -5
- package/dist/src/web/FlingGestureHandler.js +0 -119
- package/dist/src/web/GestureHandler.js +0 -413
- package/dist/src/web/IndiscreteGestureHandler.js +0 -26
- package/dist/src/web/LongPressGestureHandler.js +0 -46
- package/dist/src/web/NativeViewGestureHandler.js +0 -39
- package/dist/src/web/NodeManager.js +0 -22
- package/dist/src/web/PanGestureHandler.js +0 -145
- package/dist/src/web/PinchGestureHandler.js +0 -19
- package/dist/src/web/PressGestureHandler.js +0 -135
- package/dist/src/web/RotationGestureHandler.js +0 -20
- package/dist/src/web/TapGestureHandler.js +0 -143
- package/dist/src/web/constants.js +0 -42
- package/dist/src/web/utils.js +0 -15
- package/index.ts +0 -117
- package/src/GestureHandlerRootView.android.expo.tsx +0 -3
- package/src/__mocks__/RNGestureHandlerModule.ts +0 -27
- package/src/handlers/gestureHandlers.ts +0 -511
@@ -1,18 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { DrawerLayoutAndroid as RNDrawerLayoutAndroid, FlatList as RNFlatList, Switch as RNSwitch, TextInput as RNTextInput, ScrollView as RNScrollView, } from 'react-native';
|
3
|
-
import createNativeWrapper from '../handlers/createNativeWrapper';
|
4
|
-
export const ScrollView = createNativeWrapper(RNScrollView, {
|
5
|
-
disallowInterruption: true,
|
6
|
-
});
|
7
|
-
export const Switch = createNativeWrapper(RNSwitch, {
|
8
|
-
shouldCancelWhenOutside: false,
|
9
|
-
shouldActivateOnStart: true,
|
10
|
-
disallowInterruption: true,
|
11
|
-
});
|
12
|
-
export const TextInput = createNativeWrapper(RNTextInput);
|
13
|
-
export const DrawerLayoutAndroid = createNativeWrapper(RNDrawerLayoutAndroid, {
|
14
|
-
disallowInterruption: true,
|
15
|
-
});
|
16
|
-
// @ts-ignore -- TODO(TS) to investigate if it's needed
|
17
|
-
DrawerLayoutAndroid.positions = RNDrawerLayoutAndroid.positions;
|
18
|
-
export const FlatList = React.forwardRef((props, ref) => (<RNFlatList ref={ref} {...props} renderScrollComponent={(scrollProps) => <ScrollView {...scrollProps}/>}/>));
|
@@ -1,83 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { Component } from 'react';
|
3
|
-
import { Animated, StyleProp, ViewStyle } from 'react-native';
|
4
|
-
import { PanGestureHandlerProps } from '../handlers/gestureHandlers';
|
5
|
-
declare type SwipeableExcludes = Exclude<keyof PanGestureHandlerProps, 'onGestureEvent' | 'onHandlerStateChange'>;
|
6
|
-
interface SwipeableProps extends Pick<PanGestureHandlerProps, SwipeableExcludes> {
|
7
|
-
enableTrackpadTwoFingerGesture?: boolean;
|
8
|
-
friction?: number;
|
9
|
-
leftThreshold?: number;
|
10
|
-
rightThreshold?: number;
|
11
|
-
overshootLeft?: boolean;
|
12
|
-
overshootRight?: boolean;
|
13
|
-
overshootFriction?: number;
|
14
|
-
onSwipeableLeftOpen?: () => void;
|
15
|
-
onSwipeableRightOpen?: () => void;
|
16
|
-
onSwipeableOpen?: () => void;
|
17
|
-
onSwipeableClose?: () => void;
|
18
|
-
onSwipeableLeftWillOpen?: () => void;
|
19
|
-
onSwipeableRightWillOpen?: () => void;
|
20
|
-
onSwipeableWillOpen?: () => void;
|
21
|
-
onSwipeableWillClose?: () => void;
|
22
|
-
/**
|
23
|
-
*
|
24
|
-
* This map describes the values to use as inputRange for extra interpolation:
|
25
|
-
* AnimatedValue: [startValue, endValue]
|
26
|
-
*
|
27
|
-
* progressAnimatedValue: [0, 1]
|
28
|
-
* dragAnimatedValue: [0, +]
|
29
|
-
*
|
30
|
-
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
31
|
-
* */
|
32
|
-
renderLeftActions?: (progressAnimatedValue: Animated.AnimatedInterpolation, dragAnimatedValue: Animated.AnimatedInterpolation) => React.ReactNode;
|
33
|
-
/**
|
34
|
-
*
|
35
|
-
* This map describes the values to use as inputRange for extra interpolation:
|
36
|
-
* AnimatedValue: [startValue, endValue]
|
37
|
-
*
|
38
|
-
* progressAnimatedValue: [0, 1]
|
39
|
-
* dragAnimatedValue: [0, -]
|
40
|
-
*
|
41
|
-
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
42
|
-
* */
|
43
|
-
renderRightActions?: (progressAnimatedValue: Animated.AnimatedInterpolation, dragAnimatedValue: Animated.AnimatedInterpolation) => React.ReactNode;
|
44
|
-
useNativeAnimations?: boolean;
|
45
|
-
animationOptions?: Record<string, unknown>;
|
46
|
-
containerStyle?: StyleProp<ViewStyle>;
|
47
|
-
childrenContainerStyle?: StyleProp<ViewStyle>;
|
48
|
-
}
|
49
|
-
declare type SwipeableState = {
|
50
|
-
dragX: Animated.Value;
|
51
|
-
rowTranslation: Animated.Value;
|
52
|
-
rowState: number;
|
53
|
-
leftWidth?: number;
|
54
|
-
rightOffset?: number;
|
55
|
-
rowWidth?: number;
|
56
|
-
};
|
57
|
-
export default class Swipeable extends Component<SwipeableProps, SwipeableState> {
|
58
|
-
static defaultProps: {
|
59
|
-
friction: number;
|
60
|
-
overshootFriction: number;
|
61
|
-
useNativeAnimations: boolean;
|
62
|
-
};
|
63
|
-
constructor(props: SwipeableProps);
|
64
|
-
UNSAFE_componentWillUpdate(props: SwipeableProps, state: SwipeableState): void;
|
65
|
-
private onGestureEvent?;
|
66
|
-
private transX?;
|
67
|
-
private showLeftAction?;
|
68
|
-
private leftActionTranslate?;
|
69
|
-
private showRightAction?;
|
70
|
-
private rightActionTranslate?;
|
71
|
-
private updateAnimatedEvent;
|
72
|
-
private onTapHandlerStateChange;
|
73
|
-
private onHandlerStateChange;
|
74
|
-
private handleRelease;
|
75
|
-
private animateRow;
|
76
|
-
private onRowLayout;
|
77
|
-
private currentOffset;
|
78
|
-
close: () => void;
|
79
|
-
openLeft: () => void;
|
80
|
-
openRight: () => void;
|
81
|
-
render(): JSX.Element;
|
82
|
-
}
|
83
|
-
export {};
|
@@ -1,249 +0,0 @@
|
|
1
|
-
// Similarily to the DrawerLayout component this deserves to be put in a
|
2
|
-
// separate repo. Although, keeping it here for the time being will allow us
|
3
|
-
// to move faster and fix possible issues quicker
|
4
|
-
import * as React from 'react';
|
5
|
-
import { Component } from 'react';
|
6
|
-
import { Animated, StyleSheet, View, I18nManager, } from 'react-native';
|
7
|
-
import { PanGestureHandler, TapGestureHandler, } from '../handlers/gestureHandlers';
|
8
|
-
import { State } from '../State';
|
9
|
-
const DRAG_TOSS = 0.05;
|
10
|
-
export default class Swipeable extends Component {
|
11
|
-
constructor(props) {
|
12
|
-
super(props);
|
13
|
-
this.updateAnimatedEvent = (props, state) => {
|
14
|
-
const { friction, overshootFriction } = props;
|
15
|
-
const { dragX, rowTranslation, leftWidth = 0, rowWidth = 0 } = state;
|
16
|
-
const { rightOffset = rowWidth } = state;
|
17
|
-
const rightWidth = Math.max(0, rowWidth - rightOffset);
|
18
|
-
const { overshootLeft = leftWidth > 0, overshootRight = rightWidth > 0, } = props;
|
19
|
-
const transX = Animated.add(rowTranslation, dragX.interpolate({
|
20
|
-
inputRange: [0, friction],
|
21
|
-
outputRange: [0, 1],
|
22
|
-
})).interpolate({
|
23
|
-
inputRange: [
|
24
|
-
-rightWidth - (overshootRight ? 1 : overshootFriction),
|
25
|
-
-rightWidth,
|
26
|
-
leftWidth,
|
27
|
-
leftWidth + (overshootLeft ? 1 : overshootFriction),
|
28
|
-
],
|
29
|
-
outputRange: [
|
30
|
-
-rightWidth - (overshootRight || overshootFriction > 1 ? 1 : 0),
|
31
|
-
-rightWidth,
|
32
|
-
leftWidth,
|
33
|
-
leftWidth + (overshootLeft || overshootFriction > 1 ? 1 : 0),
|
34
|
-
],
|
35
|
-
});
|
36
|
-
this.transX = transX;
|
37
|
-
this.showLeftAction =
|
38
|
-
leftWidth > 0
|
39
|
-
? transX.interpolate({
|
40
|
-
inputRange: [-1, 0, leftWidth],
|
41
|
-
outputRange: [0, 0, 1],
|
42
|
-
})
|
43
|
-
: new Animated.Value(0);
|
44
|
-
this.leftActionTranslate = this.showLeftAction.interpolate({
|
45
|
-
inputRange: [0, Number.MIN_VALUE],
|
46
|
-
outputRange: [-10000, 0],
|
47
|
-
extrapolate: 'clamp',
|
48
|
-
});
|
49
|
-
this.showRightAction =
|
50
|
-
rightWidth > 0
|
51
|
-
? transX.interpolate({
|
52
|
-
inputRange: [-rightWidth, 0, 1],
|
53
|
-
outputRange: [1, 0, 0],
|
54
|
-
})
|
55
|
-
: new Animated.Value(0);
|
56
|
-
this.rightActionTranslate = this.showRightAction.interpolate({
|
57
|
-
inputRange: [0, Number.MIN_VALUE],
|
58
|
-
outputRange: [-10000, 0],
|
59
|
-
extrapolate: 'clamp',
|
60
|
-
});
|
61
|
-
};
|
62
|
-
this.onTapHandlerStateChange = ({ nativeEvent, }) => {
|
63
|
-
if (nativeEvent.oldState === State.ACTIVE) {
|
64
|
-
this.close();
|
65
|
-
}
|
66
|
-
};
|
67
|
-
this.onHandlerStateChange = (ev) => {
|
68
|
-
if (ev.nativeEvent.oldState === State.ACTIVE) {
|
69
|
-
this.handleRelease(ev);
|
70
|
-
}
|
71
|
-
};
|
72
|
-
this.handleRelease = (ev) => {
|
73
|
-
const { velocityX, translationX: dragX } = ev.nativeEvent;
|
74
|
-
const { leftWidth = 0, rowWidth = 0, rowState } = this.state;
|
75
|
-
const { rightOffset = rowWidth } = this.state;
|
76
|
-
const rightWidth = rowWidth - rightOffset;
|
77
|
-
const { friction, leftThreshold = leftWidth / 2, rightThreshold = rightWidth / 2, } = this.props;
|
78
|
-
const startOffsetX = this.currentOffset() + dragX / friction;
|
79
|
-
const translationX = (dragX + DRAG_TOSS * velocityX) / friction;
|
80
|
-
let toValue = 0;
|
81
|
-
if (rowState === 0) {
|
82
|
-
if (translationX > leftThreshold) {
|
83
|
-
toValue = leftWidth;
|
84
|
-
}
|
85
|
-
else if (translationX < -rightThreshold) {
|
86
|
-
toValue = -rightWidth;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
else if (rowState === 1) {
|
90
|
-
// swiped to left
|
91
|
-
if (translationX > -leftThreshold) {
|
92
|
-
toValue = leftWidth;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
else {
|
96
|
-
// swiped to right
|
97
|
-
if (translationX < rightThreshold) {
|
98
|
-
toValue = -rightWidth;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
this.animateRow(startOffsetX, toValue, velocityX / friction);
|
102
|
-
};
|
103
|
-
this.animateRow = (fromValue, toValue, velocityX) => {
|
104
|
-
const { dragX, rowTranslation } = this.state;
|
105
|
-
dragX.setValue(0);
|
106
|
-
rowTranslation.setValue(fromValue);
|
107
|
-
this.setState({ rowState: Math.sign(toValue) });
|
108
|
-
Animated.spring(rowTranslation, {
|
109
|
-
restSpeedThreshold: 1.7,
|
110
|
-
restDisplacementThreshold: 0.4,
|
111
|
-
velocity: velocityX,
|
112
|
-
bounciness: 0,
|
113
|
-
toValue,
|
114
|
-
useNativeDriver: this.props.useNativeAnimations,
|
115
|
-
...this.props.animationOptions,
|
116
|
-
}).start(({ finished }) => {
|
117
|
-
if (finished) {
|
118
|
-
if (toValue > 0 && this.props.onSwipeableLeftOpen) {
|
119
|
-
this.props.onSwipeableLeftOpen();
|
120
|
-
}
|
121
|
-
else if (toValue < 0 && this.props.onSwipeableRightOpen) {
|
122
|
-
this.props.onSwipeableRightOpen();
|
123
|
-
}
|
124
|
-
if (toValue === 0) {
|
125
|
-
this.props.onSwipeableClose?.();
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
this.props.onSwipeableOpen?.();
|
129
|
-
}
|
130
|
-
}
|
131
|
-
});
|
132
|
-
if (toValue > 0 && this.props.onSwipeableLeftWillOpen) {
|
133
|
-
this.props.onSwipeableLeftWillOpen();
|
134
|
-
}
|
135
|
-
else if (toValue < 0 && this.props.onSwipeableRightWillOpen) {
|
136
|
-
this.props.onSwipeableRightWillOpen();
|
137
|
-
}
|
138
|
-
if (toValue === 0) {
|
139
|
-
this.props.onSwipeableWillClose?.();
|
140
|
-
}
|
141
|
-
else {
|
142
|
-
this.props.onSwipeableWillOpen?.();
|
143
|
-
}
|
144
|
-
};
|
145
|
-
this.onRowLayout = ({ nativeEvent }) => {
|
146
|
-
this.setState({ rowWidth: nativeEvent.layout.width });
|
147
|
-
};
|
148
|
-
this.currentOffset = () => {
|
149
|
-
const { leftWidth = 0, rowWidth = 0, rowState } = this.state;
|
150
|
-
const { rightOffset = rowWidth } = this.state;
|
151
|
-
const rightWidth = rowWidth - rightOffset;
|
152
|
-
if (rowState === 1) {
|
153
|
-
return leftWidth;
|
154
|
-
}
|
155
|
-
else if (rowState === -1) {
|
156
|
-
return -rightWidth;
|
157
|
-
}
|
158
|
-
return 0;
|
159
|
-
};
|
160
|
-
this.close = () => {
|
161
|
-
this.animateRow(this.currentOffset(), 0);
|
162
|
-
};
|
163
|
-
this.openLeft = () => {
|
164
|
-
const { leftWidth = 0 } = this.state;
|
165
|
-
this.animateRow(this.currentOffset(), leftWidth);
|
166
|
-
};
|
167
|
-
this.openRight = () => {
|
168
|
-
const { rowWidth = 0 } = this.state;
|
169
|
-
const { rightOffset = rowWidth } = this.state;
|
170
|
-
const rightWidth = rowWidth - rightOffset;
|
171
|
-
this.animateRow(this.currentOffset(), -rightWidth);
|
172
|
-
};
|
173
|
-
const dragX = new Animated.Value(0);
|
174
|
-
this.state = {
|
175
|
-
dragX,
|
176
|
-
rowTranslation: new Animated.Value(0),
|
177
|
-
rowState: 0,
|
178
|
-
leftWidth: undefined,
|
179
|
-
rightOffset: undefined,
|
180
|
-
rowWidth: undefined,
|
181
|
-
};
|
182
|
-
this.updateAnimatedEvent(props, this.state);
|
183
|
-
this.onGestureEvent = Animated.event([{ nativeEvent: { translationX: dragX } }], { useNativeDriver: props.useNativeAnimations });
|
184
|
-
}
|
185
|
-
UNSAFE_componentWillUpdate(props, state) {
|
186
|
-
if (this.props.friction !== props.friction ||
|
187
|
-
this.props.overshootLeft !== props.overshootLeft ||
|
188
|
-
this.props.overshootRight !== props.overshootRight ||
|
189
|
-
this.props.overshootFriction !== props.overshootFriction ||
|
190
|
-
this.state.leftWidth !== state.leftWidth ||
|
191
|
-
this.state.rightOffset !== state.rightOffset ||
|
192
|
-
this.state.rowWidth !== state.rowWidth) {
|
193
|
-
this.updateAnimatedEvent(props, state);
|
194
|
-
}
|
195
|
-
}
|
196
|
-
render() {
|
197
|
-
const { rowState } = this.state;
|
198
|
-
const { children, renderLeftActions, renderRightActions } = this.props;
|
199
|
-
const left = renderLeftActions && (<Animated.View style={[
|
200
|
-
styles.leftActions,
|
201
|
-
// all those and below parameters can have ! since they are all asigned in constructor in `updateAnimatedEvent` but TS cannot spot it for some reason
|
202
|
-
{ transform: [{ translateX: this.leftActionTranslate }] },
|
203
|
-
]}>
|
204
|
-
{renderLeftActions(this.showLeftAction, this.transX)}
|
205
|
-
<View onLayout={({ nativeEvent }) => this.setState({ leftWidth: nativeEvent.layout.x })}/>
|
206
|
-
</Animated.View>);
|
207
|
-
const right = renderRightActions && (<Animated.View style={[
|
208
|
-
styles.rightActions,
|
209
|
-
{ transform: [{ translateX: this.rightActionTranslate }] },
|
210
|
-
]}>
|
211
|
-
{renderRightActions(this.showRightAction, this.transX)}
|
212
|
-
<View onLayout={({ nativeEvent }) => this.setState({ rightOffset: nativeEvent.layout.x })}/>
|
213
|
-
</Animated.View>);
|
214
|
-
return (<PanGestureHandler activeOffsetX={[-10, 10]} {...this.props} onGestureEvent={this.onGestureEvent} onHandlerStateChange={this.onHandlerStateChange}>
|
215
|
-
<Animated.View onLayout={this.onRowLayout} style={[styles.container, this.props.containerStyle]}>
|
216
|
-
{left}
|
217
|
-
{right}
|
218
|
-
<TapGestureHandler enabled={rowState !== 0} onHandlerStateChange={this.onTapHandlerStateChange}>
|
219
|
-
<Animated.View pointerEvents={rowState === 0 ? 'auto' : 'box-only'} style={[
|
220
|
-
{
|
221
|
-
transform: [{ translateX: this.transX }],
|
222
|
-
},
|
223
|
-
this.props.childrenContainerStyle,
|
224
|
-
]}>
|
225
|
-
{children}
|
226
|
-
</Animated.View>
|
227
|
-
</TapGestureHandler>
|
228
|
-
</Animated.View>
|
229
|
-
</PanGestureHandler>);
|
230
|
-
}
|
231
|
-
}
|
232
|
-
Swipeable.defaultProps = {
|
233
|
-
friction: 1,
|
234
|
-
overshootFriction: 1,
|
235
|
-
useNativeAnimations: true,
|
236
|
-
};
|
237
|
-
const styles = StyleSheet.create({
|
238
|
-
container: {
|
239
|
-
overflow: 'hidden',
|
240
|
-
},
|
241
|
-
leftActions: {
|
242
|
-
...StyleSheet.absoluteFillObject,
|
243
|
-
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
|
244
|
-
},
|
245
|
-
rightActions: {
|
246
|
-
...StyleSheet.absoluteFillObject,
|
247
|
-
flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',
|
248
|
-
},
|
249
|
-
});
|
@@ -1,210 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { Component } from 'react';
|
3
|
-
import { Animated, Platform, } from 'react-native';
|
4
|
-
import { State } from '../../State';
|
5
|
-
import { BaseButton } from '../GestureButtons';
|
6
|
-
/**
|
7
|
-
* Each touchable is a states' machine which preforms transitions.
|
8
|
-
* On very beginning (and on the very end or recognition) touchable is
|
9
|
-
* UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger
|
10
|
-
* travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition
|
11
|
-
* finishes in UNDETERMINED state.
|
12
|
-
*/
|
13
|
-
export const TOUCHABLE_STATE = {
|
14
|
-
UNDETERMINED: 0,
|
15
|
-
BEGAN: 1,
|
16
|
-
MOVED_OUTSIDE: 2,
|
17
|
-
};
|
18
|
-
/**
|
19
|
-
* GenericTouchable is not intented to be used as it is.
|
20
|
-
* Should be treated as a source for the rest of touchables
|
21
|
-
*/
|
22
|
-
export default class GenericTouchable extends Component {
|
23
|
-
constructor() {
|
24
|
-
super(...arguments);
|
25
|
-
// This flag is required since recognition of longPress implies not-invoking onPress
|
26
|
-
this.longPressDetected = false;
|
27
|
-
this.pointerInside = true;
|
28
|
-
// State of touchable
|
29
|
-
this.STATE = TOUCHABLE_STATE.UNDETERMINED;
|
30
|
-
this.onGestureEvent = ({ nativeEvent: { pointerInside }, }) => {
|
31
|
-
if (this.pointerInside !== pointerInside) {
|
32
|
-
if (pointerInside) {
|
33
|
-
this.onMoveIn();
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
this.onMoveOut();
|
37
|
-
}
|
38
|
-
}
|
39
|
-
this.pointerInside = pointerInside;
|
40
|
-
};
|
41
|
-
this.onHandlerStateChange = ({ nativeEvent, }) => {
|
42
|
-
const { state } = nativeEvent;
|
43
|
-
if (state === State.CANCELLED || state === State.FAILED) {
|
44
|
-
// Need to handle case with external cancellation (e.g. by ScrollView)
|
45
|
-
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
|
46
|
-
}
|
47
|
-
else if (
|
48
|
-
// This platform check is an implication of slightly different behavior of handlers on different platform.
|
49
|
-
// And Android "Active" state is achieving on first move of a finger, not on press in.
|
50
|
-
// On iOS event on "Began" is not delivered.
|
51
|
-
state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&
|
52
|
-
this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
|
53
|
-
// Moving inside requires
|
54
|
-
this.handlePressIn();
|
55
|
-
}
|
56
|
-
else if (state === State.END) {
|
57
|
-
const shouldCallOnPress = !this.longPressDetected &&
|
58
|
-
this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&
|
59
|
-
this.pressOutTimeout === null;
|
60
|
-
this.handleGoToUndetermined();
|
61
|
-
if (shouldCallOnPress) {
|
62
|
-
// Calls only inside component whether no long press was called previously
|
63
|
-
this.props.onPress?.();
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
this.onLongPressDetected = () => {
|
68
|
-
this.longPressDetected = true;
|
69
|
-
// checked for in the caller of `onLongPressDetected`, but better to check twice
|
70
|
-
this.props.onLongPress?.();
|
71
|
-
};
|
72
|
-
}
|
73
|
-
// handlePressIn in called on first touch on traveling inside component.
|
74
|
-
// Handles state transition with delay.
|
75
|
-
handlePressIn() {
|
76
|
-
if (this.props.delayPressIn) {
|
77
|
-
this.pressInTimeout = setTimeout(() => {
|
78
|
-
this.moveToState(TOUCHABLE_STATE.BEGAN);
|
79
|
-
this.pressInTimeout = null;
|
80
|
-
}, this.props.delayPressIn);
|
81
|
-
}
|
82
|
-
else {
|
83
|
-
this.moveToState(TOUCHABLE_STATE.BEGAN);
|
84
|
-
}
|
85
|
-
if (this.props.onLongPress) {
|
86
|
-
const time = (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);
|
87
|
-
this.longPressTimeout = setTimeout(this.onLongPressDetected, time);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
// handleMoveOutside in called on traveling outside component.
|
91
|
-
// Handles state transition with delay.
|
92
|
-
handleMoveOutside() {
|
93
|
-
if (this.props.delayPressOut) {
|
94
|
-
this.pressOutTimeout =
|
95
|
-
this.pressOutTimeout ||
|
96
|
-
setTimeout(() => {
|
97
|
-
this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);
|
98
|
-
this.pressOutTimeout = null;
|
99
|
-
}, this.props.delayPressOut);
|
100
|
-
}
|
101
|
-
else {
|
102
|
-
this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
// handleGoToUndetermined transits to UNDETERMINED state with proper delay
|
106
|
-
handleGoToUndetermined() {
|
107
|
-
clearTimeout(this.pressOutTimeout); // TODO: maybe it can be undefined
|
108
|
-
if (this.props.delayPressOut) {
|
109
|
-
this.pressOutTimeout = setTimeout(() => {
|
110
|
-
if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
|
111
|
-
this.moveToState(TOUCHABLE_STATE.BEGAN);
|
112
|
-
}
|
113
|
-
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
|
114
|
-
this.pressOutTimeout = null;
|
115
|
-
}, this.props.delayPressOut);
|
116
|
-
}
|
117
|
-
else {
|
118
|
-
if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {
|
119
|
-
this.moveToState(TOUCHABLE_STATE.BEGAN);
|
120
|
-
}
|
121
|
-
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
|
122
|
-
}
|
123
|
-
}
|
124
|
-
componentDidMount() {
|
125
|
-
this.reset();
|
126
|
-
}
|
127
|
-
// reset timeout to prevent memory leaks.
|
128
|
-
reset() {
|
129
|
-
this.longPressDetected = false;
|
130
|
-
this.pointerInside = true;
|
131
|
-
clearTimeout(this.pressInTimeout);
|
132
|
-
clearTimeout(this.pressOutTimeout);
|
133
|
-
clearTimeout(this.longPressTimeout);
|
134
|
-
this.pressOutTimeout = null;
|
135
|
-
this.longPressTimeout = null;
|
136
|
-
this.pressInTimeout = null;
|
137
|
-
}
|
138
|
-
// All states' transitions are defined here.
|
139
|
-
moveToState(newState) {
|
140
|
-
if (newState === this.STATE) {
|
141
|
-
// Ignore dummy transitions
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
if (newState === TOUCHABLE_STATE.BEGAN) {
|
145
|
-
// First touch and moving inside
|
146
|
-
this.props.onPressIn?.();
|
147
|
-
}
|
148
|
-
else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {
|
149
|
-
// Moving outside
|
150
|
-
this.props.onPressOut?.();
|
151
|
-
}
|
152
|
-
else if (newState === TOUCHABLE_STATE.UNDETERMINED) {
|
153
|
-
// Need to reset each time on transition to UNDETERMINED
|
154
|
-
this.reset();
|
155
|
-
if (this.STATE === TOUCHABLE_STATE.BEGAN) {
|
156
|
-
// ... and if it happens inside button.
|
157
|
-
this.props.onPressOut?.();
|
158
|
-
}
|
159
|
-
}
|
160
|
-
// Finally call lister (used by subclasses)
|
161
|
-
this.props.onStateChange?.(this.STATE, newState);
|
162
|
-
// ... and make transition.
|
163
|
-
this.STATE = newState;
|
164
|
-
}
|
165
|
-
componentWillUnmount() {
|
166
|
-
// to prevent memory leaks
|
167
|
-
this.reset();
|
168
|
-
}
|
169
|
-
onMoveIn() {
|
170
|
-
if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {
|
171
|
-
// This call is not throttled with delays (like in RN's implementation).
|
172
|
-
this.moveToState(TOUCHABLE_STATE.BEGAN);
|
173
|
-
}
|
174
|
-
}
|
175
|
-
onMoveOut() {
|
176
|
-
// long press should no longer be detected
|
177
|
-
clearTimeout(this.longPressTimeout);
|
178
|
-
this.longPressTimeout = null;
|
179
|
-
if (this.STATE === TOUCHABLE_STATE.BEGAN) {
|
180
|
-
this.handleMoveOutside();
|
181
|
-
}
|
182
|
-
}
|
183
|
-
render() {
|
184
|
-
const coreProps = {
|
185
|
-
accessible: this.props.accessible !== false,
|
186
|
-
accessibilityLabel: this.props.accessibilityLabel,
|
187
|
-
accessibilityHint: this.props.accessibilityHint,
|
188
|
-
accessibilityRole: this.props.accessibilityRole,
|
189
|
-
// TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,
|
190
|
-
// would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016
|
191
|
-
accessibilityState: this.props.accessibilityState,
|
192
|
-
nativeID: this.props.nativeID,
|
193
|
-
onLayout: this.props.onLayout,
|
194
|
-
hitSlop: this.props.hitSlop,
|
195
|
-
};
|
196
|
-
return (<BaseButton style={this.props.containerStyle} onHandlerStateChange={
|
197
|
-
// TODO: not sure if it can be undefined instead of null
|
198
|
-
this.props.disabled ? undefined : this.onHandlerStateChange} onGestureEvent={this.onGestureEvent} hitSlop={this.props.hitSlop} shouldActivateOnStart={this.props.shouldActivateOnStart} disallowInterruption={this.props.disallowInterruption} testID={this.props.testID} {...this.props.extraButtonProps}>
|
199
|
-
<Animated.View {...coreProps} style={this.props.style}>
|
200
|
-
{this.props.children}
|
201
|
-
</Animated.View>
|
202
|
-
</BaseButton>);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
GenericTouchable.defaultProps = {
|
206
|
-
delayLongPress: 600,
|
207
|
-
extraButtonProps: {
|
208
|
-
rippleColor: 'transparent',
|
209
|
-
},
|
210
|
-
};
|
@@ -1,73 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { Component } from 'react';
|
3
|
-
import GenericTouchable, { TOUCHABLE_STATE, } from './GenericTouchable';
|
4
|
-
import { StyleSheet, View, } from 'react-native';
|
5
|
-
/**
|
6
|
-
* TouchableHighlight follows RN's implementation
|
7
|
-
*/
|
8
|
-
export default class TouchableHighlight extends Component {
|
9
|
-
constructor(props) {
|
10
|
-
super(props);
|
11
|
-
// Copied from RN
|
12
|
-
this.showUnderlay = () => {
|
13
|
-
if (!this.hasPressHandler()) {
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
this.setState({
|
17
|
-
extraChildStyle: {
|
18
|
-
opacity: this.props.activeOpacity,
|
19
|
-
},
|
20
|
-
extraUnderlayStyle: {
|
21
|
-
backgroundColor: this.props.underlayColor,
|
22
|
-
},
|
23
|
-
});
|
24
|
-
this.props.onShowUnderlay?.();
|
25
|
-
};
|
26
|
-
this.hasPressHandler = () => this.props.onPress ||
|
27
|
-
this.props.onPressIn ||
|
28
|
-
this.props.onPressOut ||
|
29
|
-
this.props.onLongPress;
|
30
|
-
this.hideUnderlay = () => {
|
31
|
-
this.setState({
|
32
|
-
extraChildStyle: null,
|
33
|
-
extraUnderlayStyle: null,
|
34
|
-
});
|
35
|
-
this.props.onHideUnderlay?.();
|
36
|
-
};
|
37
|
-
this.onStateChange = (_from, to) => {
|
38
|
-
if (to === TOUCHABLE_STATE.BEGAN) {
|
39
|
-
this.showUnderlay();
|
40
|
-
}
|
41
|
-
else if (to === TOUCHABLE_STATE.UNDETERMINED ||
|
42
|
-
to === TOUCHABLE_STATE.MOVED_OUTSIDE) {
|
43
|
-
this.hideUnderlay();
|
44
|
-
}
|
45
|
-
};
|
46
|
-
this.state = {
|
47
|
-
extraChildStyle: null,
|
48
|
-
extraUnderlayStyle: null,
|
49
|
-
};
|
50
|
-
}
|
51
|
-
renderChildren() {
|
52
|
-
if (!this.props.children) {
|
53
|
-
return <View />;
|
54
|
-
}
|
55
|
-
const child = React.Children.only(this.props.children); // TODO: not sure if OK but fixes error
|
56
|
-
return React.cloneElement(child, {
|
57
|
-
style: StyleSheet.compose(child.props.style, this.state.extraChildStyle),
|
58
|
-
});
|
59
|
-
}
|
60
|
-
render() {
|
61
|
-
const { style = {}, ...rest } = this.props;
|
62
|
-
const { extraUnderlayStyle } = this.state;
|
63
|
-
return (<GenericTouchable {...rest} style={[style, extraUnderlayStyle]} onStateChange={this.onStateChange}>
|
64
|
-
{this.renderChildren()}
|
65
|
-
</GenericTouchable>);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
TouchableHighlight.defaultProps = {
|
69
|
-
...GenericTouchable.defaultProps,
|
70
|
-
activeOpacity: 0.85,
|
71
|
-
delayPressOut: 100,
|
72
|
-
underlayColor: 'black',
|
73
|
-
};
|