react-native-gesture-handler 2.17.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReanimatedSwipeable/package.json +6 -0
- package/android/build.gradle +0 -105
- package/android/gradle.properties +0 -7
- package/android/paper/src/main/java/com/swmansion/gesturehandler/NativeRNGestureHandlerModuleSpec.java +22 -10
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +7 -8
- package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +14 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +3 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +3 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +2 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +8 -7
- package/android/src/main/jni/cpp-adapter.cpp +5 -3
- package/apple/Handlers/RNFlingHandler.m +1 -0
- package/apple/Handlers/RNForceTouchHandler.m +2 -0
- package/apple/Handlers/RNLongPressHandler.m +2 -1
- package/apple/Handlers/RNManualHandler.m +1 -0
- package/apple/Handlers/RNNativeViewHandler.mm +31 -27
- package/apple/Handlers/RNPanHandler.m +1 -0
- package/apple/Handlers/RNPinchHandler.m +1 -0
- package/apple/Handlers/RNRotationHandler.m +1 -0
- package/apple/Handlers/RNTapHandler.m +1 -0
- package/apple/RNGestureHandlerModule.mm +3 -2
- package/apple/RNRootViewGestureRecognizer.m +5 -0
- package/lib/commonjs/Directions.js +2 -2
- package/lib/commonjs/Directions.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 +2 -2
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js +3 -3
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureButtonsProps.js +6 -0
- package/lib/commonjs/components/GestureButtonsProps.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +1 -1
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.android.js +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +334 -0
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -0
- package/lib/commonjs/components/Pressable/PressableProps.js +6 -0
- package/lib/commonjs/components/Pressable/PressableProps.js.map +1 -0
- package/lib/commonjs/components/Pressable/index.js +24 -0
- package/lib/commonjs/components/Pressable/index.js.map +1 -0
- package/lib/commonjs/components/Pressable/utils.js +136 -0
- package/lib/commonjs/components/Pressable/utils.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js +317 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +3 -3
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +4 -4
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchableProps.js +6 -0
- package/lib/commonjs/components/touchables/GenericTouchableProps.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedbackProps.js +6 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedbackProps.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +2 -2
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/ghQueueMicrotask.js +3 -4
- package/lib/commonjs/ghQueueMicrotask.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/GestureHandlerEventPayload.js +2 -0
- package/lib/commonjs/handlers/GestureHandlerEventPayload.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +21 -19
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +3 -3
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -86
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +9 -9
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +2 -2
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +21 -31
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +5 -5
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +7 -7
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js +5 -5
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/commonjs/handlers/getNextHandlerTag.js +12 -0
- package/lib/commonjs/handlers/getNextHandlerTag.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +0 -6
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
- package/lib/commonjs/handlers/utils.js +91 -0
- package/lib/commonjs/handlers/utils.js.map +1 -0
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +1 -1
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils/jestUtils.js +2 -2
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
- package/lib/commonjs/mocks.js +2 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/Gestures.js +1 -1
- package/lib/commonjs/web/Gestures.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +4 -4
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +6 -11
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js +2 -2
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +4 -11
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/LeastSquareSolver.js +18 -18
- package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +2 -2
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +4 -4
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js +6 -6
- package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -1
- package/lib/commonjs/web_hammer/NodeManager.js +2 -0
- package/lib/commonjs/web_hammer/NodeManager.js.map +1 -1
- package/lib/module/Directions.js +2 -2
- package/lib/module/Directions.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 +2 -2
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js +3 -3
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureButtonsProps.js +2 -0
- package/lib/module/components/GestureButtonsProps.js.map +1 -0
- package/lib/module/components/GestureComponents.js +1 -1
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js +1 -1
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +309 -0
- package/lib/module/components/Pressable/Pressable.js.map +1 -0
- package/lib/module/components/Pressable/PressableProps.js +2 -0
- package/lib/module/components/Pressable/PressableProps.js.map +1 -0
- package/lib/module/components/Pressable/index.js +3 -0
- package/lib/module/components/Pressable/index.js.map +1 -0
- package/lib/module/components/Pressable/utils.js +120 -0
- package/lib/module/components/Pressable/utils.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable.js +293 -0
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -0
- package/lib/module/components/Swipeable.js +3 -3
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +4 -4
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchableProps.js +2 -0
- package/lib/module/components/touchables/GenericTouchableProps.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedbackProps.js +2 -0
- package/lib/module/components/touchables/TouchableNativeFeedbackProps.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +2 -2
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/ghQueueMicrotask.js +3 -4
- package/lib/module/ghQueueMicrotask.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/GestureHandlerEventPayload.js +2 -0
- package/lib/module/handlers/GestureHandlerEventPayload.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +6 -5
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/createNativeWrapper.js +3 -3
- package/lib/module/handlers/createNativeWrapper.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +0 -72
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +4 -4
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +18 -28
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +5 -5
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +6 -6
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureComposition.js +5 -5
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/handlers/getNextHandlerTag.js +5 -0
- package/lib/module/handlers/getNextHandlerTag.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +0 -4
- package/lib/module/handlers/handlersRegistry.js.map +1 -1
- package/lib/module/handlers/utils.js +73 -0
- package/lib/module/handlers/utils.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +1 -1
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils/jestUtils.js +2 -2
- package/lib/module/jestUtils/jestUtils.js.map +1 -1
- package/lib/module/mocks.js +2 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/Gestures.js +1 -1
- package/lib/module/web/Gestures.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +4 -4
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +6 -11
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/EventManager.js +2 -2
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +4 -11
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/LeastSquareSolver.js +18 -18
- package/lib/module/web/tools/LeastSquareSolver.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +2 -2
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +1 -1
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +4 -4
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/VelocityTracker.js +6 -6
- package/lib/module/web/tools/VelocityTracker.js.map +1 -1
- package/lib/module/web_hammer/NodeManager.js +1 -1
- package/lib/module/web_hammer/NodeManager.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +2 -85
- package/lib/typescript/components/GestureButtonsProps.d.ts +99 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +1 -1
- package/lib/typescript/components/Pressable/Pressable.d.ts +3 -0
- package/lib/typescript/components/Pressable/PressableProps.d.ts +116 -0
- package/lib/typescript/components/Pressable/index.d.ts +2 -0
- package/lib/typescript/components/Pressable/utils.d.ts +15 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +125 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +4 -16
- package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +14 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +2 -9
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +9 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +2 -1
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -10
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +159 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -35
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/PanGestureHandler.d.ts +3 -51
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +2 -23
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +2 -23
- package/lib/typescript/handlers/TapGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -5
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +10 -9
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -8
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +2 -1
- package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -2
- package/lib/typescript/handlers/utils.d.ts +6 -0
- package/lib/typescript/index.d.ts +12 -9
- package/lib/typescript/jestUtils/jestUtils.d.ts +9 -7
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/NodeManager.d.ts +4 -5
- package/package.json +14 -16
- package/src/Directions.ts +2 -2
- package/src/RNGestureHandlerModule.web.ts +2 -2
- package/src/components/DrawerLayout.tsx +7 -9
- package/src/components/GestureButtons.tsx +13 -123
- package/src/components/GestureButtonsProps.ts +115 -0
- package/src/components/GestureComponents.tsx +1 -1
- package/src/components/GestureHandlerButton.tsx +1 -1
- package/src/components/GestureHandlerRootView.android.tsx +1 -1
- package/src/components/GestureHandlerRootView.tsx +1 -1
- package/src/components/Pressable/Pressable.tsx +398 -0
- package/src/components/Pressable/PressableProps.tsx +149 -0
- package/src/components/Pressable/index.ts +2 -0
- package/src/components/Pressable/utils.ts +180 -0
- package/src/components/ReanimatedSwipeable.tsx +629 -0
- package/src/components/Swipeable.tsx +6 -6
- package/src/components/touchables/GenericTouchable.tsx +9 -36
- package/src/components/touchables/GenericTouchableProps.ts +26 -0
- package/src/components/touchables/TouchableHighlight.tsx +2 -4
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +7 -17
- package/src/components/touchables/TouchableNativeFeedbackProps.tsx +12 -0
- package/src/components/touchables/TouchableOpacity.tsx +3 -5
- package/src/components/touchables/TouchableWithoutFeedback.tsx +2 -1
- package/src/getShadowNodeFromRef.ts +2 -2
- package/src/ghQueueMicrotask.ts +7 -4
- package/src/handlers/FlingGestureHandler.ts +1 -6
- package/src/handlers/ForceTouchGestureHandler.ts +1 -12
- package/src/handlers/GestureHandlerEventPayload.ts +184 -0
- package/src/handlers/LongPressGestureHandler.ts +1 -40
- package/src/handlers/NativeViewGestureHandler.ts +1 -7
- package/src/handlers/PanGestureHandler.ts +1 -58
- package/src/handlers/PinchGestureHandler.ts +1 -27
- package/src/handlers/RotationGestureHandler.ts +1 -27
- package/src/handlers/TapGestureHandler.ts +1 -6
- package/src/handlers/createHandler.tsx +6 -11
- package/src/handlers/createNativeWrapper.tsx +3 -3
- package/src/handlers/gestureHandlerCommon.ts +3 -79
- package/src/handlers/gestureHandlerTypesCompat.ts +16 -30
- package/src/handlers/gestures/GestureDetector/Wrap.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +4 -7
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +1 -1
- package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +20 -30
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
- package/src/handlers/gestures/GestureDetector/utils.ts +5 -5
- package/src/handlers/gestures/flingGesture.ts +2 -4
- package/src/handlers/gestures/forceTouchGesture.ts +2 -4
- package/src/handlers/gestures/gesture.ts +17 -15
- package/src/handlers/gestures/gestureComposition.ts +5 -5
- package/src/handlers/gestures/gestureStateManager.ts +1 -1
- package/src/handlers/gestures/longPressGesture.ts +2 -4
- package/src/handlers/gestures/nativeGesture.ts +2 -4
- package/src/handlers/gestures/panGesture.ts +2 -4
- package/src/handlers/gestures/pinchGesture.ts +1 -1
- package/src/handlers/gestures/rotationGesture.ts +1 -1
- package/src/handlers/gestures/tapGesture.ts +2 -4
- package/src/handlers/getNextHandlerTag.ts +5 -0
- package/src/handlers/handlersRegistry.ts +0 -6
- package/src/handlers/utils.ts +75 -0
- package/src/index.ts +25 -36
- package/src/init.ts +1 -1
- package/src/jestUtils/jestUtils.ts +12 -10
- package/src/mocks.ts +2 -2
- package/src/utils.ts +1 -1
- package/src/web/Gestures.ts +1 -1
- package/src/web/detectors/RotationGestureDetector.ts +1 -1
- package/src/web/detectors/ScaleGestureDetector.ts +4 -4
- package/src/web/handlers/FlingGestureHandler.ts +1 -1
- package/src/web/handlers/GestureHandler.ts +8 -14
- package/src/web/handlers/NativeViewGestureHandler.ts +3 -3
- package/src/web/handlers/PanGestureHandler.ts +1 -1
- package/src/web/handlers/TapGestureHandler.ts +1 -1
- package/src/web/tools/EventManager.ts +2 -2
- package/src/web/tools/GestureHandlerWebDelegate.ts +3 -8
- package/src/web/tools/LeastSquareSolver.ts +18 -18
- package/src/web/tools/PointerEventManager.ts +2 -2
- package/src/web/tools/PointerTracker.ts +2 -1
- package/src/web/tools/TouchEventManager.ts +4 -4
- package/src/web/tools/VelocityTracker.ts +6 -6
- package/src/web_hammer/NodeManager.ts +2 -11
@@ -0,0 +1,309 @@
|
|
1
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
2
|
+
import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';
|
3
|
+
import { GestureDetector } from '../../handlers/gestures/GestureDetector';
|
4
|
+
import { Platform, View, processColor, StyleSheet } from 'react-native';
|
5
|
+
import NativeButton from '../GestureHandlerButton';
|
6
|
+
import { numberAsInset, gestureToPressableEvent, isTouchWithinInset, gestureTouchToPressableEvent, addInsets, splitStyles } from './utils';
|
7
|
+
import { PressabilityDebugView } from '../../handlers/PressabilityDebugView';
|
8
|
+
const DEFAULT_LONG_PRESS_DURATION = 500;
|
9
|
+
export default function Pressable(props) {
|
10
|
+
var _props$testOnly_press, _props$delayLongPress, _props$unstable_press, _props$android_disabl, _props$android_ripple, _props$android_ripple2, _props$android_ripple3, _props$android_ripple4;
|
11
|
+
|
12
|
+
const [pressedState, setPressedState] = useState((_props$testOnly_press = props.testOnly_pressed) !== null && _props$testOnly_press !== void 0 ? _props$testOnly_press : false);
|
13
|
+
const pressableRef = useRef(null); // Disabled when onLongPress has been called
|
14
|
+
|
15
|
+
const isPressCallbackEnabled = useRef(true);
|
16
|
+
const hasPassedBoundsChecks = useRef(false);
|
17
|
+
const shouldPreventNativeEffects = useRef(false);
|
18
|
+
const normalizedHitSlop = useMemo(() => {
|
19
|
+
var _props$hitSlop;
|
20
|
+
|
21
|
+
return typeof props.hitSlop === 'number' ? numberAsInset(props.hitSlop) : (_props$hitSlop = props.hitSlop) !== null && _props$hitSlop !== void 0 ? _props$hitSlop : {};
|
22
|
+
}, [props.hitSlop]);
|
23
|
+
const normalizedPressRetentionOffset = useMemo(() => {
|
24
|
+
var _props$pressRetention;
|
25
|
+
|
26
|
+
return typeof props.pressRetentionOffset === 'number' ? numberAsInset(props.pressRetentionOffset) : (_props$pressRetention = props.pressRetentionOffset) !== null && _props$pressRetention !== void 0 ? _props$pressRetention : {};
|
27
|
+
}, [props.pressRetentionOffset]);
|
28
|
+
const hoverInTimeout = useRef(null);
|
29
|
+
const hoverOutTimeout = useRef(null);
|
30
|
+
const hoverGesture = useMemo(() => Gesture.Hover().manualActivation(true) // Stops Hover from blocking Native gesture activation on web
|
31
|
+
.cancelsTouchesInView(false).onBegin(event => {
|
32
|
+
var _props$onHoverIn2;
|
33
|
+
|
34
|
+
if (hoverOutTimeout.current) {
|
35
|
+
clearTimeout(hoverOutTimeout.current);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (props.delayHoverIn) {
|
39
|
+
hoverInTimeout.current = setTimeout(() => {
|
40
|
+
var _props$onHoverIn;
|
41
|
+
|
42
|
+
return (_props$onHoverIn = props.onHoverIn) === null || _props$onHoverIn === void 0 ? void 0 : _props$onHoverIn.call(props, gestureToPressableEvent(event));
|
43
|
+
}, props.delayHoverIn);
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
(_props$onHoverIn2 = props.onHoverIn) === null || _props$onHoverIn2 === void 0 ? void 0 : _props$onHoverIn2.call(props, gestureToPressableEvent(event));
|
48
|
+
}).onFinalize(event => {
|
49
|
+
var _props$onHoverOut2;
|
50
|
+
|
51
|
+
if (hoverInTimeout.current) {
|
52
|
+
clearTimeout(hoverInTimeout.current);
|
53
|
+
}
|
54
|
+
|
55
|
+
if (props.delayHoverOut) {
|
56
|
+
hoverOutTimeout.current = setTimeout(() => {
|
57
|
+
var _props$onHoverOut;
|
58
|
+
|
59
|
+
return (_props$onHoverOut = props.onHoverOut) === null || _props$onHoverOut === void 0 ? void 0 : _props$onHoverOut.call(props, gestureToPressableEvent(event));
|
60
|
+
}, props.delayHoverOut);
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
(_props$onHoverOut2 = props.onHoverOut) === null || _props$onHoverOut2 === void 0 ? void 0 : _props$onHoverOut2.call(props, gestureToPressableEvent(event));
|
65
|
+
}), [props]);
|
66
|
+
const pressDelayTimeoutRef = useRef(null);
|
67
|
+
const isTouchPropagationAllowed = useRef(false); // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use
|
68
|
+
|
69
|
+
const deferredEventPayload = useRef(null);
|
70
|
+
const pressInHandler = useCallback(event => {
|
71
|
+
var _props$onPressIn;
|
72
|
+
|
73
|
+
if (handlingOnTouchesDown.current) {
|
74
|
+
deferredEventPayload.current = event;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!isTouchPropagationAllowed.current) {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
|
81
|
+
deferredEventPayload.current = null;
|
82
|
+
(_props$onPressIn = props.onPressIn) === null || _props$onPressIn === void 0 ? void 0 : _props$onPressIn.call(props, event);
|
83
|
+
isPressCallbackEnabled.current = true;
|
84
|
+
pressDelayTimeoutRef.current = null;
|
85
|
+
setPressedState(true);
|
86
|
+
}, [props]);
|
87
|
+
const pressOutHandler = useCallback(event => {
|
88
|
+
var _props$onPressOut;
|
89
|
+
|
90
|
+
if (!hasPassedBoundsChecks.current || event.nativeEvent.touches.length > event.nativeEvent.changedTouches.length) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
|
94
|
+
if (props.unstable_pressDelay && pressDelayTimeoutRef.current !== null) {
|
95
|
+
// When delay is preemptively finished by lifting touches,
|
96
|
+
// we want to immediately activate it's effects - pressInHandler,
|
97
|
+
// even though we are located at the pressOutHandler
|
98
|
+
clearTimeout(pressDelayTimeoutRef.current);
|
99
|
+
pressInHandler(event);
|
100
|
+
}
|
101
|
+
|
102
|
+
if (deferredEventPayload.current) {
|
103
|
+
var _props$onPressIn2;
|
104
|
+
|
105
|
+
(_props$onPressIn2 = props.onPressIn) === null || _props$onPressIn2 === void 0 ? void 0 : _props$onPressIn2.call(props, deferredEventPayload.current);
|
106
|
+
deferredEventPayload.current = null;
|
107
|
+
}
|
108
|
+
|
109
|
+
(_props$onPressOut = props.onPressOut) === null || _props$onPressOut === void 0 ? void 0 : _props$onPressOut.call(props, event);
|
110
|
+
|
111
|
+
if (isPressCallbackEnabled.current) {
|
112
|
+
var _props$onPress;
|
113
|
+
|
114
|
+
(_props$onPress = props.onPress) === null || _props$onPress === void 0 ? void 0 : _props$onPress.call(props, event);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (longPressTimeoutRef.current) {
|
118
|
+
clearTimeout(longPressTimeoutRef.current);
|
119
|
+
longPressTimeoutRef.current = null;
|
120
|
+
}
|
121
|
+
|
122
|
+
isTouchPropagationAllowed.current = false;
|
123
|
+
hasPassedBoundsChecks.current = false;
|
124
|
+
isPressCallbackEnabled.current = true;
|
125
|
+
setPressedState(false);
|
126
|
+
}, [pressInHandler, props]);
|
127
|
+
const handlingOnTouchesDown = useRef(false);
|
128
|
+
const onEndHandlingTouchesDown = useRef(null);
|
129
|
+
const cancelledMidPress = useRef(false);
|
130
|
+
const activateLongPress = useCallback(event => {
|
131
|
+
if (!isTouchPropagationAllowed.current) {
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
|
135
|
+
if (hasPassedBoundsChecks.current) {
|
136
|
+
var _props$onLongPress;
|
137
|
+
|
138
|
+
(_props$onLongPress = props.onLongPress) === null || _props$onLongPress === void 0 ? void 0 : _props$onLongPress.call(props, gestureTouchToPressableEvent(event));
|
139
|
+
isPressCallbackEnabled.current = false;
|
140
|
+
}
|
141
|
+
|
142
|
+
if (longPressTimeoutRef.current) {
|
143
|
+
clearTimeout(longPressTimeoutRef.current);
|
144
|
+
longPressTimeoutRef.current = null;
|
145
|
+
}
|
146
|
+
}, [props]);
|
147
|
+
const longPressTimeoutRef = useRef(null);
|
148
|
+
const longPressMinDuration = ((_props$delayLongPress = props.delayLongPress) !== null && _props$delayLongPress !== void 0 ? _props$delayLongPress : DEFAULT_LONG_PRESS_DURATION) + ((_props$unstable_press = props.unstable_pressDelay) !== null && _props$unstable_press !== void 0 ? _props$unstable_press : 0);
|
149
|
+
const pressAndTouchGesture = useMemo(() => Gesture.LongPress().minDuration(Number.MAX_SAFE_INTEGER) // Stops long press from blocking native gesture
|
150
|
+
.maxDistance(Number.MAX_SAFE_INTEGER) // Stops long press from cancelling after set distance
|
151
|
+
.cancelsTouchesInView(false).onTouchesDown(event => {
|
152
|
+
var _pressableRef$current;
|
153
|
+
|
154
|
+
handlingOnTouchesDown.current = true;
|
155
|
+
(_pressableRef$current = pressableRef.current) === null || _pressableRef$current === void 0 ? void 0 : _pressableRef$current.measure((_x, _y, width, height) => {
|
156
|
+
var _onEndHandlingTouches;
|
157
|
+
|
158
|
+
if (!isTouchWithinInset({
|
159
|
+
width,
|
160
|
+
height
|
161
|
+
}, normalizedHitSlop, event.changedTouches.at(-1)) || hasPassedBoundsChecks.current || cancelledMidPress.current) {
|
162
|
+
cancelledMidPress.current = false;
|
163
|
+
onEndHandlingTouchesDown.current = null;
|
164
|
+
handlingOnTouchesDown.current = false;
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
|
168
|
+
hasPassedBoundsChecks.current = true; // In case of multiple touches, the first one starts long press gesture
|
169
|
+
|
170
|
+
if (longPressTimeoutRef.current === null) {
|
171
|
+
// Start long press gesture timer
|
172
|
+
longPressTimeoutRef.current = setTimeout(() => activateLongPress(event), longPressMinDuration);
|
173
|
+
}
|
174
|
+
|
175
|
+
if (props.unstable_pressDelay) {
|
176
|
+
pressDelayTimeoutRef.current = setTimeout(() => {
|
177
|
+
pressInHandler(gestureTouchToPressableEvent(event));
|
178
|
+
}, props.unstable_pressDelay);
|
179
|
+
} else {
|
180
|
+
pressInHandler(gestureTouchToPressableEvent(event));
|
181
|
+
}
|
182
|
+
|
183
|
+
(_onEndHandlingTouches = onEndHandlingTouchesDown.current) === null || _onEndHandlingTouches === void 0 ? void 0 : _onEndHandlingTouches.call(onEndHandlingTouchesDown);
|
184
|
+
onEndHandlingTouchesDown.current = null;
|
185
|
+
handlingOnTouchesDown.current = false;
|
186
|
+
});
|
187
|
+
}).onTouchesUp(event => {
|
188
|
+
if (handlingOnTouchesDown.current) {
|
189
|
+
onEndHandlingTouchesDown.current = () => pressOutHandler(gestureTouchToPressableEvent(event));
|
190
|
+
|
191
|
+
return;
|
192
|
+
} // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart
|
193
|
+
// This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.
|
194
|
+
|
195
|
+
|
196
|
+
if (deferredEventPayload.current !== null) {
|
197
|
+
shouldPreventNativeEffects.current = true;
|
198
|
+
}
|
199
|
+
|
200
|
+
pressOutHandler(gestureTouchToPressableEvent(event));
|
201
|
+
}).onTouchesCancelled(event => {
|
202
|
+
isPressCallbackEnabled.current = false;
|
203
|
+
|
204
|
+
if (handlingOnTouchesDown.current) {
|
205
|
+
cancelledMidPress.current = true;
|
206
|
+
|
207
|
+
onEndHandlingTouchesDown.current = () => pressOutHandler(gestureTouchToPressableEvent(event));
|
208
|
+
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
|
212
|
+
if (!hasPassedBoundsChecks.current || event.allTouches.length > event.changedTouches.length) {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
pressOutHandler(gestureTouchToPressableEvent(event));
|
217
|
+
}), [activateLongPress, longPressMinDuration, normalizedHitSlop, pressInHandler, pressOutHandler, props.unstable_pressDelay]); // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events
|
218
|
+
|
219
|
+
const buttonGesture = useMemo(() => Gesture.Native().onBegin(() => {
|
220
|
+
// Android sets BEGAN state on press down
|
221
|
+
if (Platform.OS === 'android') {
|
222
|
+
isTouchPropagationAllowed.current = true;
|
223
|
+
}
|
224
|
+
}).onStart(() => {
|
225
|
+
if (Platform.OS === 'web') {
|
226
|
+
isTouchPropagationAllowed.current = true;
|
227
|
+
} // iOS sets ACTIVE state on press down
|
228
|
+
|
229
|
+
|
230
|
+
if (Platform.OS !== 'ios') {
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
|
234
|
+
if (deferredEventPayload.current) {
|
235
|
+
isTouchPropagationAllowed.current = true;
|
236
|
+
|
237
|
+
if (hasPassedBoundsChecks.current) {
|
238
|
+
pressInHandler(deferredEventPayload.current);
|
239
|
+
deferredEventPayload.current = null;
|
240
|
+
} else {
|
241
|
+
pressOutHandler(deferredEventPayload.current);
|
242
|
+
isTouchPropagationAllowed.current = false;
|
243
|
+
}
|
244
|
+
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
|
248
|
+
if (hasPassedBoundsChecks.current) {
|
249
|
+
isTouchPropagationAllowed.current = true;
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
|
253
|
+
if (shouldPreventNativeEffects.current) {
|
254
|
+
shouldPreventNativeEffects.current = false;
|
255
|
+
return;
|
256
|
+
}
|
257
|
+
|
258
|
+
isTouchPropagationAllowed.current = true;
|
259
|
+
}), [pressInHandler, pressOutHandler]);
|
260
|
+
const appliedHitSlop = addInsets(normalizedHitSlop, normalizedPressRetentionOffset);
|
261
|
+
const isPressableEnabled = props.disabled !== true;
|
262
|
+
const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];
|
263
|
+
|
264
|
+
for (const gesture of gestures) {
|
265
|
+
gesture.enabled(isPressableEnabled);
|
266
|
+
gesture.runOnJS(true);
|
267
|
+
gesture.hitSlop(appliedHitSlop);
|
268
|
+
gesture.shouldCancelWhenOutside(false);
|
269
|
+
|
270
|
+
if (Platform.OS !== 'web') {
|
271
|
+
gesture.shouldCancelWhenOutside(true);
|
272
|
+
}
|
273
|
+
} // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area
|
274
|
+
|
275
|
+
|
276
|
+
buttonGesture.hitSlop(normalizedHitSlop);
|
277
|
+
const gesture = Gesture.Simultaneous(...gestures);
|
278
|
+
const defaultRippleColor = props.android_ripple ? undefined : 'transparent'; // `cursor: 'pointer'` on `RNButton` crashes iOS
|
279
|
+
|
280
|
+
const pointerStyle = Platform.OS === 'web' ? {
|
281
|
+
cursor: 'pointer'
|
282
|
+
} : {};
|
283
|
+
const styleProp = typeof props.style === 'function' ? props.style({
|
284
|
+
pressed: pressedState
|
285
|
+
}) : props.style;
|
286
|
+
const childrenProp = typeof props.children === 'function' ? props.children({
|
287
|
+
pressed: pressedState
|
288
|
+
}) : props.children;
|
289
|
+
const flattenedStyles = StyleSheet.flatten(styleProp !== null && styleProp !== void 0 ? styleProp : {});
|
290
|
+
const [innerStyles, outerStyles] = splitStyles(flattenedStyles);
|
291
|
+
return /*#__PURE__*/React.createElement(View, {
|
292
|
+
style: outerStyles
|
293
|
+
}, /*#__PURE__*/React.createElement(GestureDetector, {
|
294
|
+
gesture: gesture
|
295
|
+
}, /*#__PURE__*/React.createElement(NativeButton, {
|
296
|
+
ref: pressableRef,
|
297
|
+
testID: props.testID,
|
298
|
+
hitSlop: appliedHitSlop,
|
299
|
+
enabled: isPressableEnabled,
|
300
|
+
touchSoundDisabled: (_props$android_disabl = props.android_disableSound) !== null && _props$android_disabl !== void 0 ? _props$android_disabl : undefined,
|
301
|
+
rippleColor: processColor((_props$android_ripple = (_props$android_ripple2 = props.android_ripple) === null || _props$android_ripple2 === void 0 ? void 0 : _props$android_ripple2.color) !== null && _props$android_ripple !== void 0 ? _props$android_ripple : defaultRippleColor),
|
302
|
+
rippleRadius: (_props$android_ripple3 = (_props$android_ripple4 = props.android_ripple) === null || _props$android_ripple4 === void 0 ? void 0 : _props$android_ripple4.radius) !== null && _props$android_ripple3 !== void 0 ? _props$android_ripple3 : undefined,
|
303
|
+
style: [StyleSheet.absoluteFill, pointerStyle, innerStyles]
|
304
|
+
}, childrenProp, __DEV__ ? /*#__PURE__*/React.createElement(PressabilityDebugView, {
|
305
|
+
color: "red",
|
306
|
+
hitSlop: normalizedHitSlop
|
307
|
+
}) : null)));
|
308
|
+
}
|
309
|
+
//# sourceMappingURL=Pressable.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["Pressable.tsx"],"names":["React","useCallback","useMemo","useRef","useState","GestureObjects","Gesture","GestureDetector","Platform","View","processColor","StyleSheet","NativeButton","numberAsInset","gestureToPressableEvent","isTouchWithinInset","gestureTouchToPressableEvent","addInsets","splitStyles","PressabilityDebugView","DEFAULT_LONG_PRESS_DURATION","Pressable","props","pressedState","setPressedState","testOnly_pressed","pressableRef","isPressCallbackEnabled","hasPassedBoundsChecks","shouldPreventNativeEffects","normalizedHitSlop","hitSlop","normalizedPressRetentionOffset","pressRetentionOffset","hoverInTimeout","hoverOutTimeout","hoverGesture","Hover","manualActivation","cancelsTouchesInView","onBegin","event","current","clearTimeout","delayHoverIn","setTimeout","onHoverIn","onFinalize","delayHoverOut","onHoverOut","pressDelayTimeoutRef","isTouchPropagationAllowed","deferredEventPayload","pressInHandler","handlingOnTouchesDown","onPressIn","pressOutHandler","nativeEvent","touches","length","changedTouches","unstable_pressDelay","onPressOut","onPress","longPressTimeoutRef","onEndHandlingTouchesDown","cancelledMidPress","activateLongPress","onLongPress","longPressMinDuration","delayLongPress","pressAndTouchGesture","LongPress","minDuration","Number","MAX_SAFE_INTEGER","maxDistance","onTouchesDown","measure","_x","_y","width","height","at","onTouchesUp","onTouchesCancelled","allTouches","buttonGesture","Native","OS","onStart","appliedHitSlop","isPressableEnabled","disabled","gestures","gesture","enabled","runOnJS","shouldCancelWhenOutside","Simultaneous","defaultRippleColor","android_ripple","undefined","pointerStyle","cursor","styleProp","style","pressed","childrenProp","children","flattenedStyles","flatten","innerStyles","outerStyles","testID","android_disableSound","color","radius","absoluteFill","__DEV__"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,OAA7B,EAAsCC,MAAtC,EAA8CC,QAA9C,QAA8D,OAA9D;AACA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,wCAA1C;AACA,SAASC,eAAT,QAAgC,yCAAhC;AAEA,SAEEC,QAFF,EAIEC,IAJF,EAMEC,YANF,EAOEC,UAPF,QAQO,cARP;AASA,OAAOC,YAAP,MAAyB,yBAAzB;AACA,SACEC,aADF,EAEEC,uBAFF,EAGEC,kBAHF,EAIEC,4BAJF,EAKEC,SALF,EAMEC,WANF,QAOO,SAPP;AAQA,SAASC,qBAAT,QAAsC,sCAAtC;AAGA,MAAMC,2BAA2B,GAAG,GAApC;AAEA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;A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GAChB,OAAOtF,KAAK,CAACuF,QAAb,KAA0B,UAA1B,GACIvF,KAAK,CAACuF,QAAN,CAAe;AAAEF,IAAAA,OAAO,EAAEpF;AAAX,GAAf,CADJ,GAEID,KAAK,CAACuF,QAHZ;AAKA,QAAMC,eAAe,GAAGnG,UAAU,CAACoG,OAAX,CAAmBN,SAAnB,aAAmBA,SAAnB,cAAmBA,SAAnB,GAAgC,EAAhC,CAAxB;AAEA,QAAM,CAACO,WAAD,EAAcC,WAAd,IAA6B/F,WAAW,CAAC4F,eAAD,CAA9C;AAEA,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEG;AAAb,kBACE,oBAAC,eAAD;AAAiB,IAAA,OAAO,EAAElB;AAA1B,kBACE,oBAAC,YAAD;AACE,IAAA,GAAG,EAAErE,YADP;AAEE,IAAA,MAAM,EAAEJ,KAAK,CAAC4F,MAFhB;AAGE,IAAA,OAAO,EAAEvB,cAHX;AAIE,IAAA,OAAO,EAAEC,kBAJX;AAKE,IAAA,kBAAkB,2BAAEtE,KAAK,CAAC6F,oBAAR,yEAAgCb,SALpD;AAME,IAAA,WAAW,EAAE5F,YAAY,oDACvBY,KAAK,CAAC+E,cADiB,2DACvB,uBAAsBe,KADC,yEACQhB,kBADR,CAN3B;AASE,IAAA,YAAY,sDAAE9E,KAAK,CAAC+E,cAAR,2DAAE,uBAAsBgB,MAAxB,2EAAkCf,SAThD;AAUE,IAAA,KAAK,EAAE,CAAC3F,UAAU,CAAC2G,YAAZ,EAA0Bf,YAA1B,EAAwCS,WAAxC;AAVT,KAWGJ,YAXH,EAYGW,OAAO,gBACN,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAC,KAA7B;AAAmC,IAAA,OAAO,EAAEzF;AAA5C,IADM,GAEJ,IAdN,CADF,CADF,CADF;AAsBD","sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../../handlers/gestures/GestureDetector';\nimport { PressableEvent, PressableProps } from './PressableProps';\nimport {\n Insets,\n Platform,\n StyleProp,\n View,\n ViewStyle,\n processColor,\n StyleSheet,\n} from 'react-native';\nimport NativeButton from '../GestureHandlerButton';\nimport {\n numberAsInset,\n gestureToPressableEvent,\n isTouchWithinInset,\n gestureTouchToPressableEvent,\n addInsets,\n splitStyles,\n} from './utils';\nimport { PressabilityDebugView } from '../../handlers/PressabilityDebugView';\nimport { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';\n\nconst DEFAULT_LONG_PRESS_DURATION = 500;\n\nexport default function Pressable(props: PressableProps) {\n const [pressedState, setPressedState] = useState(\n props.testOnly_pressed ?? false\n );\n\n const pressableRef = useRef<View>(null);\n\n // Disabled when onLongPress has been called\n const isPressCallbackEnabled = useRef<boolean>(true);\n const hasPassedBoundsChecks = useRef<boolean>(false);\n const shouldPreventNativeEffects = useRef<boolean>(false);\n\n const normalizedHitSlop: Insets = useMemo(\n () =>\n typeof props.hitSlop === 'number'\n ? numberAsInset(props.hitSlop)\n : props.hitSlop ?? {},\n [props.hitSlop]\n );\n\n const normalizedPressRetentionOffset: Insets = useMemo(\n () =>\n typeof props.pressRetentionOffset === 'number'\n ? numberAsInset(props.pressRetentionOffset)\n : props.pressRetentionOffset ?? {},\n [props.pressRetentionOffset]\n );\n\n const hoverInTimeout = useRef<number | null>(null);\n const hoverOutTimeout = useRef<number | null>(null);\n\n const hoverGesture = useMemo(\n () =>\n Gesture.Hover()\n .manualActivation(true) // Stops Hover from blocking Native gesture activation on web\n .cancelsTouchesInView(false)\n .onBegin((event) => {\n if (hoverOutTimeout.current) {\n clearTimeout(hoverOutTimeout.current);\n }\n if (props.delayHoverIn) {\n hoverInTimeout.current = setTimeout(\n () => props.onHoverIn?.(gestureToPressableEvent(event)),\n props.delayHoverIn\n );\n return;\n }\n props.onHoverIn?.(gestureToPressableEvent(event));\n })\n .onFinalize((event) => {\n if (hoverInTimeout.current) {\n clearTimeout(hoverInTimeout.current);\n }\n if (props.delayHoverOut) {\n hoverOutTimeout.current = setTimeout(\n () => props.onHoverOut?.(gestureToPressableEvent(event)),\n props.delayHoverOut\n );\n return;\n }\n props.onHoverOut?.(gestureToPressableEvent(event));\n }),\n [props]\n );\n\n const pressDelayTimeoutRef = useRef<number | null>(null);\n const isTouchPropagationAllowed = useRef<boolean>(false);\n\n // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use\n const deferredEventPayload = useRef<PressableEvent | null>(null);\n\n const pressInHandler = useCallback(\n (event: PressableEvent) => {\n if (handlingOnTouchesDown.current) {\n deferredEventPayload.current = event;\n }\n\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n deferredEventPayload.current = null;\n\n props.onPressIn?.(event);\n isPressCallbackEnabled.current = true;\n pressDelayTimeoutRef.current = null;\n setPressedState(true);\n },\n [props]\n );\n\n const pressOutHandler = useCallback(\n (event: PressableEvent) => {\n if (\n !hasPassedBoundsChecks.current ||\n event.nativeEvent.touches.length >\n event.nativeEvent.changedTouches.length\n ) {\n return;\n }\n\n if (props.unstable_pressDelay && pressDelayTimeoutRef.current !== null) {\n // When delay is preemptively finished by lifting touches,\n // we want to immediately activate it's effects - pressInHandler,\n // even though we are located at the pressOutHandler\n clearTimeout(pressDelayTimeoutRef.current);\n pressInHandler(event);\n }\n\n if (deferredEventPayload.current) {\n props.onPressIn?.(deferredEventPayload.current);\n deferredEventPayload.current = null;\n }\n\n props.onPressOut?.(event);\n\n if (isPressCallbackEnabled.current) {\n props.onPress?.(event);\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n\n isTouchPropagationAllowed.current = false;\n hasPassedBoundsChecks.current = false;\n isPressCallbackEnabled.current = true;\n setPressedState(false);\n },\n [pressInHandler, props]\n );\n\n const handlingOnTouchesDown = useRef<boolean>(false);\n const onEndHandlingTouchesDown = useRef<(() => void) | null>(null);\n const cancelledMidPress = useRef<boolean>(false);\n\n const activateLongPress = useCallback(\n (event: GestureTouchEvent) => {\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n props.onLongPress?.(gestureTouchToPressableEvent(event));\n isPressCallbackEnabled.current = false;\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n },\n [props]\n );\n\n const longPressTimeoutRef = useRef<number | null>(null);\n const longPressMinDuration =\n (props.delayLongPress ?? DEFAULT_LONG_PRESS_DURATION) +\n (props.unstable_pressDelay ?? 0);\n\n const pressAndTouchGesture = useMemo(\n () =>\n Gesture.LongPress()\n .minDuration(Number.MAX_SAFE_INTEGER) // Stops long press from blocking native gesture\n .maxDistance(Number.MAX_SAFE_INTEGER) // Stops long press from cancelling after set distance\n .cancelsTouchesInView(false)\n .onTouchesDown((event) => {\n handlingOnTouchesDown.current = true;\n pressableRef.current?.measure((_x, _y, width, height) => {\n if (\n !isTouchWithinInset(\n {\n width,\n height,\n },\n normalizedHitSlop,\n event.changedTouches.at(-1)\n ) ||\n hasPassedBoundsChecks.current ||\n cancelledMidPress.current\n ) {\n cancelledMidPress.current = false;\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n return;\n }\n\n hasPassedBoundsChecks.current = true;\n\n // In case of multiple touches, the first one starts long press gesture\n if (longPressTimeoutRef.current === null) {\n // Start long press gesture timer\n longPressTimeoutRef.current = setTimeout(\n () => activateLongPress(event),\n longPressMinDuration\n );\n }\n\n if (props.unstable_pressDelay) {\n pressDelayTimeoutRef.current = setTimeout(() => {\n pressInHandler(gestureTouchToPressableEvent(event));\n }, props.unstable_pressDelay);\n } else {\n pressInHandler(gestureTouchToPressableEvent(event));\n }\n\n onEndHandlingTouchesDown.current?.();\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n });\n })\n .onTouchesUp((event) => {\n if (handlingOnTouchesDown.current) {\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart\n // This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.\n if (deferredEventPayload.current !== null) {\n shouldPreventNativeEffects.current = true;\n }\n pressOutHandler(gestureTouchToPressableEvent(event));\n })\n .onTouchesCancelled((event) => {\n isPressCallbackEnabled.current = false;\n\n if (handlingOnTouchesDown.current) {\n cancelledMidPress.current = true;\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n\n if (\n !hasPassedBoundsChecks.current ||\n event.allTouches.length > event.changedTouches.length\n ) {\n return;\n }\n\n pressOutHandler(gestureTouchToPressableEvent(event));\n }),\n [\n activateLongPress,\n longPressMinDuration,\n normalizedHitSlop,\n pressInHandler,\n pressOutHandler,\n props.unstable_pressDelay,\n ]\n );\n\n // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events\n const buttonGesture = useMemo(\n () =>\n Gesture.Native()\n .onBegin(() => {\n // Android sets BEGAN state on press down\n if (Platform.OS === 'android') {\n isTouchPropagationAllowed.current = true;\n }\n })\n .onStart(() => {\n if (Platform.OS === 'web') {\n isTouchPropagationAllowed.current = true;\n }\n\n // iOS sets ACTIVE state on press down\n if (Platform.OS !== 'ios') {\n return;\n }\n\n if (deferredEventPayload.current) {\n isTouchPropagationAllowed.current = true;\n\n if (hasPassedBoundsChecks.current) {\n pressInHandler(deferredEventPayload.current);\n deferredEventPayload.current = null;\n } else {\n pressOutHandler(deferredEventPayload.current);\n isTouchPropagationAllowed.current = false;\n }\n\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n isTouchPropagationAllowed.current = true;\n return;\n }\n\n if (shouldPreventNativeEffects.current) {\n shouldPreventNativeEffects.current = false;\n return;\n }\n\n isTouchPropagationAllowed.current = true;\n }),\n [pressInHandler, pressOutHandler]\n );\n\n const appliedHitSlop = addInsets(\n normalizedHitSlop,\n normalizedPressRetentionOffset\n );\n\n const isPressableEnabled = props.disabled !== true;\n\n const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];\n\n for (const gesture of gestures) {\n gesture.enabled(isPressableEnabled);\n gesture.runOnJS(true);\n gesture.hitSlop(appliedHitSlop);\n gesture.shouldCancelWhenOutside(false);\n\n if (Platform.OS !== 'web') {\n gesture.shouldCancelWhenOutside(true);\n }\n }\n\n // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area\n buttonGesture.hitSlop(normalizedHitSlop);\n\n const gesture = Gesture.Simultaneous(...gestures);\n\n const defaultRippleColor = props.android_ripple ? undefined : 'transparent';\n\n // `cursor: 'pointer'` on `RNButton` crashes iOS\n const pointerStyle: StyleProp<ViewStyle> =\n Platform.OS === 'web' ? { cursor: 'pointer' } : {};\n\n const styleProp =\n typeof props.style === 'function'\n ? props.style({ pressed: pressedState })\n : props.style;\n\n const childrenProp =\n typeof props.children === 'function'\n ? props.children({ pressed: pressedState })\n : props.children;\n\n const flattenedStyles = StyleSheet.flatten(styleProp ?? {});\n\n const [innerStyles, outerStyles] = splitStyles(flattenedStyles);\n\n return (\n <View style={outerStyles}>\n <GestureDetector gesture={gesture}>\n <NativeButton\n ref={pressableRef}\n testID={props.testID}\n hitSlop={appliedHitSlop}\n enabled={isPressableEnabled}\n touchSoundDisabled={props.android_disableSound ?? undefined}\n rippleColor={processColor(\n props.android_ripple?.color ?? defaultRippleColor\n )}\n rippleRadius={props.android_ripple?.radius ?? undefined}\n style={[StyleSheet.absoluteFill, pointerStyle, innerStyles]}>\n {childrenProp}\n {__DEV__ ? (\n <PressabilityDebugView color=\"red\" hitSlop={normalizedHitSlop} />\n ) : null}\n </NativeButton>\n </GestureDetector>\n </View>\n );\n}\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["PressableProps","default"],"mappings":"AAAA,SAASA,cAAT,QAA+B,kBAA/B;AACA,SAASC,OAAT,QAAwB,aAAxB","sourcesContent":["export { PressableProps } from './PressableProps';\nexport { default } from './Pressable';\n"]}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
const numberAsInset = value => ({
|
2
|
+
left: value,
|
3
|
+
right: value,
|
4
|
+
top: value,
|
5
|
+
bottom: value
|
6
|
+
});
|
7
|
+
|
8
|
+
const addInsets = (a, b) => {
|
9
|
+
var _a$left, _b$left, _a$right, _b$right, _a$top, _b$top, _a$bottom, _b$bottom;
|
10
|
+
|
11
|
+
return {
|
12
|
+
left: ((_a$left = a.left) !== null && _a$left !== void 0 ? _a$left : 0) + ((_b$left = b.left) !== null && _b$left !== void 0 ? _b$left : 0),
|
13
|
+
right: ((_a$right = a.right) !== null && _a$right !== void 0 ? _a$right : 0) + ((_b$right = b.right) !== null && _b$right !== void 0 ? _b$right : 0),
|
14
|
+
top: ((_a$top = a.top) !== null && _a$top !== void 0 ? _a$top : 0) + ((_b$top = b.top) !== null && _b$top !== void 0 ? _b$top : 0),
|
15
|
+
bottom: ((_a$bottom = a.bottom) !== null && _a$bottom !== void 0 ? _a$bottom : 0) + ((_b$bottom = b.bottom) !== null && _b$bottom !== void 0 ? _b$bottom : 0)
|
16
|
+
};
|
17
|
+
};
|
18
|
+
|
19
|
+
const touchDataToPressEvent = (data, timestamp, targetId) => ({
|
20
|
+
identifier: data.id,
|
21
|
+
locationX: data.x,
|
22
|
+
locationY: data.y,
|
23
|
+
pageX: data.absoluteX,
|
24
|
+
pageY: data.absoluteY,
|
25
|
+
target: targetId,
|
26
|
+
timestamp: timestamp,
|
27
|
+
touches: [],
|
28
|
+
// Always empty - legacy compatibility
|
29
|
+
changedTouches: [] // Always empty - legacy compatibility
|
30
|
+
|
31
|
+
});
|
32
|
+
|
33
|
+
const gestureToPressEvent = (event, timestamp, targetId) => ({
|
34
|
+
identifier: event.handlerTag,
|
35
|
+
locationX: event.x,
|
36
|
+
locationY: event.y,
|
37
|
+
pageX: event.absoluteX,
|
38
|
+
pageY: event.absoluteY,
|
39
|
+
target: targetId,
|
40
|
+
timestamp: timestamp,
|
41
|
+
touches: [],
|
42
|
+
// Always empty - legacy compatibility
|
43
|
+
changedTouches: [] // Always empty - legacy compatibility
|
44
|
+
|
45
|
+
});
|
46
|
+
|
47
|
+
const isTouchWithinInset = (dimensions, inset, touch) => {
|
48
|
+
var _touch$x, _inset$right, _touch$y, _inset$bottom, _touch$x2, _inset$left, _touch$y2, _inset$top;
|
49
|
+
|
50
|
+
return ((_touch$x = touch === null || touch === void 0 ? void 0 : touch.x) !== null && _touch$x !== void 0 ? _touch$x : 0) < ((_inset$right = inset.right) !== null && _inset$right !== void 0 ? _inset$right : 0) + dimensions.width && ((_touch$y = touch === null || touch === void 0 ? void 0 : touch.y) !== null && _touch$y !== void 0 ? _touch$y : 0) < ((_inset$bottom = inset.bottom) !== null && _inset$bottom !== void 0 ? _inset$bottom : 0) + dimensions.height && ((_touch$x2 = touch === null || touch === void 0 ? void 0 : touch.x) !== null && _touch$x2 !== void 0 ? _touch$x2 : 0) > -((_inset$left = inset.left) !== null && _inset$left !== void 0 ? _inset$left : 0) && ((_touch$y2 = touch === null || touch === void 0 ? void 0 : touch.y) !== null && _touch$y2 !== void 0 ? _touch$y2 : 0) > -((_inset$top = inset.top) !== null && _inset$top !== void 0 ? _inset$top : 0);
|
51
|
+
};
|
52
|
+
|
53
|
+
const gestureToPressableEvent = event => {
|
54
|
+
const timestamp = Date.now(); // As far as I can see, there isn't a conventional way of getting targetId with the data we get
|
55
|
+
|
56
|
+
const targetId = 0;
|
57
|
+
const pressEvent = gestureToPressEvent(event, timestamp, targetId);
|
58
|
+
return {
|
59
|
+
nativeEvent: {
|
60
|
+
touches: [pressEvent],
|
61
|
+
changedTouches: [pressEvent],
|
62
|
+
identifier: pressEvent.identifier,
|
63
|
+
locationX: event.x,
|
64
|
+
locationY: event.y,
|
65
|
+
pageX: event.absoluteX,
|
66
|
+
pageY: event.absoluteY,
|
67
|
+
target: targetId,
|
68
|
+
timestamp: timestamp,
|
69
|
+
force: undefined
|
70
|
+
}
|
71
|
+
};
|
72
|
+
};
|
73
|
+
|
74
|
+
const gestureTouchToPressableEvent = event => {
|
75
|
+
var _event$allTouches$at$, _event$allTouches$at, _event$allTouches$at$2, _event$allTouches$at2, _event$allTouches$at$3, _event$allTouches$at3, _event$allTouches$at$4, _event$allTouches$at4;
|
76
|
+
|
77
|
+
const timestamp = Date.now(); // As far as I can see, there isn't a conventional way of getting targetId with the data we get
|
78
|
+
|
79
|
+
const targetId = 0;
|
80
|
+
const touchesList = event.allTouches.map(touch => touchDataToPressEvent(touch, timestamp, targetId));
|
81
|
+
const changedTouchesList = event.changedTouches.map(touch => touchDataToPressEvent(touch, timestamp, targetId));
|
82
|
+
return {
|
83
|
+
nativeEvent: {
|
84
|
+
touches: touchesList,
|
85
|
+
changedTouches: changedTouchesList,
|
86
|
+
identifier: event.handlerTag,
|
87
|
+
locationX: (_event$allTouches$at$ = (_event$allTouches$at = event.allTouches.at(0)) === null || _event$allTouches$at === void 0 ? void 0 : _event$allTouches$at.x) !== null && _event$allTouches$at$ !== void 0 ? _event$allTouches$at$ : -1,
|
88
|
+
locationY: (_event$allTouches$at$2 = (_event$allTouches$at2 = event.allTouches.at(0)) === null || _event$allTouches$at2 === void 0 ? void 0 : _event$allTouches$at2.y) !== null && _event$allTouches$at$2 !== void 0 ? _event$allTouches$at$2 : -1,
|
89
|
+
pageX: (_event$allTouches$at$3 = (_event$allTouches$at3 = event.allTouches.at(0)) === null || _event$allTouches$at3 === void 0 ? void 0 : _event$allTouches$at3.absoluteX) !== null && _event$allTouches$at$3 !== void 0 ? _event$allTouches$at$3 : -1,
|
90
|
+
pageY: (_event$allTouches$at$4 = (_event$allTouches$at4 = event.allTouches.at(0)) === null || _event$allTouches$at4 === void 0 ? void 0 : _event$allTouches$at4.absoluteY) !== null && _event$allTouches$at$4 !== void 0 ? _event$allTouches$at$4 : -1,
|
91
|
+
target: targetId,
|
92
|
+
timestamp: timestamp,
|
93
|
+
force: undefined
|
94
|
+
}
|
95
|
+
};
|
96
|
+
};
|
97
|
+
|
98
|
+
// Source:
|
99
|
+
// - From ViewStyle extracted FlexStyle sub-interface which contains all of the box-model manipulating props.
|
100
|
+
// - From FlexStyle handpicked those styles, which act on the inner part of the box-model.
|
101
|
+
const innerStyleKeys = new Set(['alignContent', 'alignItems', 'flexBasis', 'flexDirection', 'flexWrap', 'rowGap', 'gap', 'columnGap', 'justifyContent', 'overflow', 'padding', 'paddingBottom', 'paddingEnd', 'paddingHorizontal', 'paddingLeft', 'paddingRight', 'paddingStart', 'paddingTop', 'paddingVertical', 'start', 'end', 'direction' // iOS only
|
102
|
+
]);
|
103
|
+
|
104
|
+
const splitStyles = from => {
|
105
|
+
const outerStyles = {};
|
106
|
+
const innerStyles = {};
|
107
|
+
|
108
|
+
for (const key in from) {
|
109
|
+
if (innerStyleKeys.has(key)) {
|
110
|
+
innerStyles[key] = from[key];
|
111
|
+
} else {
|
112
|
+
outerStyles[key] = from[key];
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
return [innerStyles, outerStyles];
|
117
|
+
};
|
118
|
+
|
119
|
+
export { numberAsInset, addInsets, isTouchWithinInset, gestureToPressableEvent, gestureTouchToPressableEvent, splitStyles };
|
120
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["numberAsInset","value","left","right","top","bottom","addInsets","a","b","touchDataToPressEvent","data","timestamp","targetId","identifier","id","locationX","x","locationY","y","pageX","absoluteX","pageY","absoluteY","target","touches","changedTouches","gestureToPressEvent","event","handlerTag","isTouchWithinInset","dimensions","inset","touch","width","height","gestureToPressableEvent","Date","now","pressEvent","nativeEvent","force","undefined","gestureTouchToPressableEvent","touchesList","allTouches","map","changedTouchesList","at","innerStyleKeys","Set","splitStyles","from","outerStyles","innerStyles","key","has"],"mappings":"AAUA,MAAMA,aAAa,GAAIC,KA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ACO,GAAf,CAAmBD,GAAnB,CAAJ,EAAgD;AAC9CD,MAAAA,WAAW,CAACC,GAAD,CAAX,GAAmBH,IAAI,CAACG,GAAD,CAAvB;AACD,KAFD,MAEO;AACLF,MAAAA,WAAW,CAACE,GAAD,CAAX,GAAmBH,IAAI,CAACG,GAAD,CAAvB;AACD;AACF;;AAED,SAAO,CAACD,WAAD,EAAcD,WAAd,CAAP;AACD,CAbD;;AAeA,SACEpD,aADF,EAEEM,SAFF,EAGEuB,kBAHF,EAIEM,uBAJF,EAKEO,4BALF,EAMEQ,WANF","sourcesContent":["import { Insets, ViewStyle } from 'react-native';\nimport { LongPressGestureHandlerEventPayload } from '../../handlers/GestureHandlerEventPayload';\nimport {\n TouchData,\n GestureStateChangeEvent,\n GestureTouchEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport { HoverGestureHandlerEventPayload } from '../../handlers/gestures/hoverGesture';\nimport { InnerPressableEvent, PressableEvent } from './PressableProps';\n\nconst numberAsInset = (value: number): Insets => ({\n left: value,\n right: value,\n top: value,\n bottom: value,\n});\n\nconst addInsets = (a: Insets, b: Insets): Insets => ({\n left: (a.left ?? 0) + (b.left ?? 0),\n right: (a.right ?? 0) + (b.right ?? 0),\n top: (a.top ?? 0) + (b.top ?? 0),\n bottom: (a.bottom ?? 0) + (b.bottom ?? 0),\n});\n\nconst touchDataToPressEvent = (\n data: TouchData,\n timestamp: number,\n targetId: number\n): InnerPressableEvent => ({\n identifier: data.id,\n locationX: data.x,\n locationY: data.y,\n pageX: data.absoluteX,\n pageY: data.absoluteY,\n target: targetId,\n timestamp: timestamp,\n touches: [], // Always empty - legacy compatibility\n changedTouches: [], // Always empty - legacy compatibility\n});\n\nconst gestureToPressEvent = (\n event: GestureStateChangeEvent<\n HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload\n >,\n timestamp: number,\n targetId: number\n): InnerPressableEvent => ({\n identifier: event.handlerTag,\n locationX: event.x,\n locationY: event.y,\n pageX: event.absoluteX,\n pageY: event.absoluteY,\n target: targetId,\n timestamp: timestamp,\n touches: [], // Always empty - legacy compatibility\n changedTouches: [], // Always empty - legacy compatibility\n});\n\nconst isTouchWithinInset = (\n dimensions: { width: number; height: number },\n inset: Insets,\n touch?: TouchData\n) =>\n (touch?.x ?? 0) < (inset.right ?? 0) + dimensions.width &&\n (touch?.y ?? 0) < (inset.bottom ?? 0) + dimensions.height &&\n (touch?.x ?? 0) > -(inset.left ?? 0) &&\n (touch?.y ?? 0) > -(inset.top ?? 0);\n\nconst gestureToPressableEvent = (\n event: GestureStateChangeEvent<\n HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload\n >\n): PressableEvent => {\n const timestamp = Date.now();\n\n // As far as I can see, there isn't a conventional way of getting targetId with the data we get\n const targetId = 0;\n\n const pressEvent = gestureToPressEvent(event, timestamp, targetId);\n\n return {\n nativeEvent: {\n touches: [pressEvent],\n changedTouches: [pressEvent],\n identifier: pressEvent.identifier,\n locationX: event.x,\n locationY: event.y,\n pageX: event.absoluteX,\n pageY: event.absoluteY,\n target: targetId,\n timestamp: timestamp,\n force: undefined,\n },\n };\n};\n\nconst gestureTouchToPressableEvent = (\n event: GestureTouchEvent\n): PressableEvent => {\n const timestamp = Date.now();\n\n // As far as I can see, there isn't a conventional way of getting targetId with the data we get\n const targetId = 0;\n\n const touchesList = event.allTouches.map((touch: TouchData) =>\n touchDataToPressEvent(touch, timestamp, targetId)\n );\n const changedTouchesList = event.changedTouches.map((touch: TouchData) =>\n touchDataToPressEvent(touch, timestamp, targetId)\n );\n\n return {\n nativeEvent: {\n touches: touchesList,\n changedTouches: changedTouchesList,\n identifier: event.handlerTag,\n locationX: event.allTouches.at(0)?.x ?? -1,\n locationY: event.allTouches.at(0)?.y ?? -1,\n pageX: event.allTouches.at(0)?.absoluteX ?? -1,\n pageY: event.allTouches.at(0)?.absoluteY ?? -1,\n target: targetId,\n timestamp: timestamp,\n force: undefined,\n },\n };\n};\n\ntype StylePropKeys = (keyof ViewStyle)[];\n\n// Source:\n// - From ViewStyle extracted FlexStyle sub-interface which contains all of the box-model manipulating props.\n// - From FlexStyle handpicked those styles, which act on the inner part of the box-model.\nconst innerStyleKeys = new Set([\n 'alignContent',\n 'alignItems',\n 'flexBasis',\n 'flexDirection',\n 'flexWrap',\n 'rowGap',\n 'gap',\n 'columnGap',\n 'justifyContent',\n 'overflow',\n 'padding',\n 'paddingBottom',\n 'paddingEnd',\n 'paddingHorizontal',\n 'paddingLeft',\n 'paddingRight',\n 'paddingStart',\n 'paddingTop',\n 'paddingVertical',\n 'start',\n 'end',\n 'direction', // iOS only\n] as StylePropKeys);\n\nconst splitStyles = (from: ViewStyle): [ViewStyle, ViewStyle] => {\n const outerStyles: Record<string, unknown> = {};\n const innerStyles: Record<string, unknown> = {};\n\n for (const key in from) {\n if (innerStyleKeys.has(key as keyof ViewStyle)) {\n innerStyles[key] = from[key as keyof ViewStyle];\n } else {\n outerStyles[key] = from[key as keyof ViewStyle];\n }\n }\n\n return [innerStyles, outerStyles];\n};\n\nexport {\n numberAsInset,\n addInsets,\n isTouchWithinInset,\n gestureToPressableEvent,\n gestureTouchToPressableEvent,\n splitStyles,\n};\n"]}
|