react-native-gesture-handler 2.16.0-rc.0 → 2.16.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +2 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +9 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +3 -0
- package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/DiagonalDirections.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/FlingGestureHandler.kt +61 -24
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +17 -22
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +30 -11
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureUtils.kt +3 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/Vector.kt +66 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +119 -19
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +1 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +4 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +1 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +4 -7
- package/apple/Handlers/RNLongPressHandler.m +5 -13
- package/apple/Handlers/RNPinchHandler.m +12 -1
- package/apple/RNGestureHandler.m +3 -1
- package/lib/commonjs/Directions.js +19 -6
- package/lib/commonjs/Directions.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +97 -4
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.native.js +16 -0
- package/lib/commonjs/RNGestureHandlerModule.native.js.map +1 -0
- package/lib/commonjs/RNRenderer.js +5 -10
- package/lib/commonjs/RNRenderer.js.map +1 -1
- package/lib/commonjs/RNRenderer.native.js +16 -0
- package/lib/commonjs/RNRenderer.native.js.map +1 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +19 -82
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.native.js +115 -0
- package/lib/commonjs/components/GestureComponents.native.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -3
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.native.js +14 -0
- package/lib/commonjs/components/GestureHandlerButton.native.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerRootView.js +0 -6
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +7 -1
- package/lib/commonjs/components/GestureHandlerRootView.native.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +3 -1
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.js +1 -12
- package/lib/commonjs/getReactNativeVersion.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.native.js +22 -0
- package/lib/commonjs/getReactNativeVersion.native.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.js +5 -34
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.native.js +44 -0
- package/lib/commonjs/getShadowNodeFromRef.native.js.map +1 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.js +5 -7
- package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.native.js +14 -0
- package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +11 -5
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/customDirectEventTypes.js +11 -0
- package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -0
- package/lib/commonjs/handlers/customDirectEventTypes.native.js +14 -0
- package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +13 -2
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js +13 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +135 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js +66 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js +10 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js +76 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/tapGesture.js +42 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/commonjs/index.js +8 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +2 -0
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/commonjs/utils.js +5 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/Gestures.js +66 -0
- package/lib/commonjs/web/Gestures.js.map +1 -0
- package/lib/commonjs/web/constants.js +3 -8
- package/lib/commonjs/web/constants.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +36 -12
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +11 -9
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/IGestureHandler.js +2 -0
- package/lib/commonjs/web/handlers/IGestureHandler.js.map +1 -0
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +5 -6
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +3 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +1 -13
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +114 -115
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +10 -5
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/InteractionManager.js +12 -3
- package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
- package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +55 -27
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +26 -5
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +58 -0
- package/lib/commonjs/web/tools/Vector.js.map +1 -0
- package/lib/commonjs/web/utils.js +9 -1
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/commonjs/web_hammer/NodeManager.js.map +1 -1
- package/lib/module/Directions.js +16 -4
- package/lib/module/Directions.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +84 -4
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.native.js +5 -0
- package/lib/module/RNGestureHandlerModule.native.js.map +1 -0
- package/lib/module/RNRenderer.js +3 -3
- package/lib/module/RNRenderer.js.map +1 -1
- package/lib/module/RNRenderer.native.js +4 -0
- package/lib/module/RNRenderer.native.js.map +1 -0
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureComponents.js +18 -80
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/GestureComponents.native.js +90 -0
- package/lib/module/components/GestureComponents.native.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.js +8 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.native.js +3 -0
- package/lib/module/components/GestureHandlerButton.native.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.js +0 -5
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +6 -1
- package/lib/module/components/GestureHandlerRootView.native.js.map +1 -0
- package/lib/module/components/Swipeable.js +3 -1
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +1 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/getReactNativeVersion.js +1 -7
- package/lib/module/getReactNativeVersion.js.map +1 -1
- package/lib/module/getReactNativeVersion.native.js +10 -0
- package/lib/module/getReactNativeVersion.native.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.js +4 -33
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.native.js +37 -0
- package/lib/module/getShadowNodeFromRef.native.js.map +1 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.js +4 -2
- package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.native.js +3 -0
- package/lib/module/handlers/PressabilityDebugView.native.js.map +1 -0
- package/lib/module/handlers/createHandler.js +11 -6
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/customDirectEventTypes.js +5 -0
- package/lib/module/handlers/customDirectEventTypes.js.map +1 -0
- package/lib/module/handlers/customDirectEventTypes.native.js +3 -0
- package/lib/module/handlers/customDirectEventTypes.native.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +11 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +25 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +13 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +135 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js +12 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +10 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +76 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js +42 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +2 -0
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/module/utils.js +5 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/Gestures.js +39 -0
- package/lib/module/web/Gestures.js.map +1 -0
- package/lib/module/web/constants.js +1 -6
- package/lib/module/web/constants.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +34 -12
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +10 -9
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/IGestureHandler.js +2 -0
- package/lib/module/web/handlers/IGestureHandler.js.map +1 -0
- package/lib/module/web/handlers/NativeViewGestureHandler.js +5 -6
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +3 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +0 -11
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +114 -115
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +9 -4
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/InteractionManager.js +9 -3
- package/lib/module/web/tools/InteractionManager.js.map +1 -1
- package/lib/module/web/tools/NodeManager.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +53 -26
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +26 -5
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/Vector.js +47 -0
- package/lib/module/web/tools/Vector.js.map +1 -0
- package/lib/module/web/utils.js +2 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/module/web_hammer/NodeManager.js.map +1 -1
- package/lib/typescript/Directions.d.ts +7 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +15 -2
- package/lib/typescript/RNGestureHandlerModule.native.d.ts +2 -0
- package/lib/typescript/RNRenderer.d.ts +3 -1
- package/lib/typescript/RNRenderer.native.d.ts +1 -0
- package/lib/typescript/components/DrawerLayout.d.ts +1 -2
- package/lib/typescript/components/GestureComponents.d.ts +7 -21
- package/lib/typescript/components/GestureComponents.native.d.ts +22 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
- package/lib/typescript/components/GestureHandlerButton.native.d.ts +4 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -1
- package/lib/typescript/getReactNativeVersion.d.ts +1 -4
- package/lib/typescript/getReactNativeVersion.native.d.ts +4 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
- package/lib/typescript/getShadowNodeFromRef.native.d.ts +1 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/PanGestureHandler.d.ts +4 -4
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
- package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +1 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +2 -0
- package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +1 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +11 -2
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +38 -1
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +11 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +14 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +114 -2
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +57 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +10 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +8 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +67 -4
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +35 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/mocks.d.ts +1 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +4 -1
- package/lib/typescript/web/Gestures.d.ts +36 -0
- package/lib/typescript/web/constants.d.ts +1 -6
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +3 -3
- package/lib/typescript/web/handlers/GestureHandler.d.ts +13 -11
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +38 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/web/interfaces.d.ts +8 -10
- package/lib/typescript/web/tools/EventManager.d.ts +15 -12
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +3 -4
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +7 -5
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +3 -3
- package/lib/typescript/web/tools/InteractionManager.d.ts +6 -6
- package/lib/typescript/web/tools/NodeManager.d.ts +4 -3
- package/lib/typescript/web/tools/PointerEventManager.d.ts +11 -2
- package/lib/typescript/web/tools/TouchEventManager.d.ts +6 -1
- package/lib/typescript/web/tools/Vector.d.ts +15 -0
- package/lib/typescript/web/utils.d.ts +4 -4
- package/lib/typescript/web_hammer/NodeManager.d.ts +1 -1
- package/package.json +4 -2
- package/src/Directions.ts +21 -4
- package/src/RNGestureHandlerModule.native.ts +5 -0
- package/src/RNGestureHandlerModule.ts +104 -4
- package/src/RNRenderer.native.ts +3 -0
- package/src/RNRenderer.ts +3 -3
- package/src/components/DrawerLayout.tsx +1 -1
- package/src/components/GestureComponents.native.tsx +148 -0
- package/src/components/GestureComponents.tsx +24 -131
- package/src/components/GestureHandlerButton.native.tsx +5 -0
- package/src/components/GestureHandlerButton.tsx +5 -4
- package/src/components/{GestureHandlerRootView.web.tsx → GestureHandlerRootView.native.tsx} +6 -0
- package/src/components/GestureHandlerRootView.tsx +0 -6
- package/src/components/Swipeable.tsx +2 -0
- package/src/components/touchables/GenericTouchable.tsx +3 -0
- package/src/getReactNativeVersion.native.ts +11 -0
- package/src/getReactNativeVersion.ts +1 -9
- package/src/getShadowNodeFromRef.native.ts +44 -0
- package/src/getShadowNodeFromRef.ts +4 -41
- package/src/handlers/PanGestureHandler.ts +8 -4
- package/src/handlers/PressabilityDebugView.native.tsx +2 -0
- package/src/handlers/PressabilityDebugView.tsx +4 -2
- package/src/handlers/createHandler.tsx +24 -14
- package/src/handlers/customDirectEventTypes.native.ts +2 -0
- package/src/handlers/customDirectEventTypes.ts +5 -0
- package/src/handlers/gestureHandlerCommon.ts +28 -1
- package/src/handlers/gestures/GestureDetector.tsx +62 -4
- package/src/handlers/gestures/flingGesture.ts +11 -0
- package/src/handlers/gestures/forceTouchGesture.ts +14 -0
- package/src/handlers/gestures/gesture.ts +114 -1
- package/src/handlers/gestures/gestureObjects.ts +57 -0
- package/src/handlers/gestures/gestureStateManager.web.ts +1 -1
- package/src/handlers/gestures/hoverGesture.ts +1 -1
- package/src/handlers/gestures/longPressGesture.ts +10 -0
- package/src/handlers/gestures/nativeGesture.ts +8 -0
- package/src/handlers/gestures/panGesture.ts +75 -4
- package/src/handlers/gestures/tapGesture.ts +35 -0
- package/src/index.ts +1 -1
- package/src/mocks.ts +2 -0
- package/src/specs/RNGestureHandlerButtonNativeComponent.ts +4 -0
- package/src/utils.ts +9 -2
- package/src/web/Gestures.ts +41 -0
- package/src/web/constants.ts +1 -7
- package/src/web/handlers/FlingGestureHandler.ts +54 -24
- package/src/web/handlers/GestureHandler.ts +23 -19
- package/src/web/handlers/IGestureHandler.ts +50 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +5 -6
- package/src/web/handlers/PanGestureHandler.ts +4 -0
- package/src/web/interfaces.ts +14 -10
- package/src/web/tools/EventManager.ts +16 -14
- package/src/web/tools/GestureHandlerDelegate.ts +3 -4
- package/src/web/tools/GestureHandlerOrchestrator.ts +160 -145
- package/src/web/tools/GestureHandlerWebDelegate.ts +14 -9
- package/src/web/tools/InteractionManager.ts +18 -12
- package/src/web/tools/NodeManager.ts +4 -3
- package/src/web/tools/PointerEventManager.ts +181 -166
- package/src/web/tools/TouchEventManager.ts +126 -114
- package/src/web/tools/Vector.ts +60 -0
- package/src/web/utils.ts +7 -4
- package/src/web_hammer/NodeManager.ts +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +0 -163
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +0 -1
- package/lib/commonjs/RNRenderer.web.js +0 -11
- package/lib/commonjs/RNRenderer.web.js.map +0 -1
- package/lib/commonjs/components/GestureComponents.web.js +0 -52
- package/lib/commonjs/components/GestureComponents.web.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerButton.web.js +0 -24
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +0 -1
- package/lib/commonjs/getReactNativeVersion.web.js +0 -11
- package/lib/commonjs/getReactNativeVersion.web.js.map +0 -1
- package/lib/commonjs/getShadowNodeFromRef.web.js +0 -15
- package/lib/commonjs/getShadowNodeFromRef.web.js.map +0 -1
- package/lib/commonjs/handlers/PressabilityDebugView.web.js +0 -12
- package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +0 -1
- package/lib/module/RNGestureHandlerModule.web.js +0 -122
- package/lib/module/RNGestureHandlerModule.web.js.map +0 -1
- package/lib/module/RNRenderer.web.js +0 -4
- package/lib/module/RNRenderer.web.js.map +0 -1
- package/lib/module/components/GestureComponents.web.js +0 -28
- package/lib/module/components/GestureComponents.web.js.map +0 -1
- package/lib/module/components/GestureHandlerButton.web.js +0 -9
- package/lib/module/components/GestureHandlerButton.web.js.map +0 -1
- package/lib/module/components/GestureHandlerRootView.web.js.map +0 -1
- package/lib/module/getReactNativeVersion.web.js +0 -4
- package/lib/module/getReactNativeVersion.web.js.map +0 -1
- package/lib/module/getShadowNodeFromRef.web.js +0 -8
- package/lib/module/getShadowNodeFromRef.web.js.map +0 -1
- package/lib/module/handlers/PressabilityDebugView.web.js +0 -5
- package/lib/module/handlers/PressabilityDebugView.web.js.map +0 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -50
- package/lib/typescript/RNRenderer.web.d.ts +0 -3
- package/lib/typescript/components/GestureComponents.web.d.ts +0 -8
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -4
- package/lib/typescript/getReactNativeVersion.web.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
- package/src/RNGestureHandlerModule.web.ts +0 -146
- package/src/RNRenderer.web.ts +0 -3
- package/src/components/GestureComponents.web.tsx +0 -41
- package/src/components/GestureHandlerButton.web.tsx +0 -6
- package/src/getReactNativeVersion.web.ts +0 -3
- package/src/getShadowNodeFromRef.web.ts +0 -7
- package/src/handlers/PressabilityDebugView.web.tsx +0 -4
- /package/lib/typescript/components/{GestureHandlerRootView.web.d.ts → GestureHandlerRootView.native.d.ts} +0 -0
@@ -19,6 +19,7 @@ import {
|
|
19
19
|
HandlerStateChangeEvent,
|
20
20
|
scheduleFlushOperations,
|
21
21
|
UserSelect,
|
22
|
+
TouchAction,
|
22
23
|
} from '../gestureHandlerCommon';
|
23
24
|
import {
|
24
25
|
GestureStateManager,
|
@@ -41,7 +42,6 @@ import { isFabric, isJestEnv, tagMessage } from '../../utils';
|
|
41
42
|
import { getReactNativeVersion } from '../../getReactNativeVersion';
|
42
43
|
import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
|
43
44
|
import { Platform } from 'react-native';
|
44
|
-
import type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';
|
45
45
|
import { onGestureHandlerEvent } from './eventReceiver';
|
46
46
|
import { RNRenderer } from '../../RNRenderer';
|
47
47
|
import { isNewWebImplementationEnabled } from '../../EnableNewWebImplementation';
|
@@ -49,6 +49,14 @@ import { nativeViewGestureHandlerProps } from '../NativeViewGestureHandler';
|
|
49
49
|
import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext';
|
50
50
|
import { ghQueueMicrotask } from '../../ghQueueMicrotask';
|
51
51
|
|
52
|
+
type AttachGestureHandlerWeb = (
|
53
|
+
handlerTag: number,
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
55
|
+
newView: any,
|
56
|
+
_actionType: ActionType,
|
57
|
+
propsRef: React.RefObject<unknown>
|
58
|
+
) => void;
|
59
|
+
|
52
60
|
declare const global: {
|
53
61
|
isFormsStackingContext: (node: unknown) => boolean | null; // JSI function
|
54
62
|
};
|
@@ -219,9 +227,7 @@ function attachHandlers({
|
|
219
227
|
: ActionType.JS_FUNCTION_NEW_API;
|
220
228
|
|
221
229
|
if (Platform.OS === 'web') {
|
222
|
-
(
|
223
|
-
RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler
|
224
|
-
)(
|
230
|
+
(RNGestureHandlerModule.attachGestureHandler as AttachGestureHandlerWeb)(
|
225
231
|
gesture.handlerTag,
|
226
232
|
viewTag,
|
227
233
|
ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
@@ -614,11 +620,43 @@ const applyEnableContextMenuProp = (
|
|
614
620
|
}
|
615
621
|
};
|
616
622
|
|
623
|
+
const applyTouchActionProp = (
|
624
|
+
touchAction: TouchAction,
|
625
|
+
gesture: ComposedGesture | GestureType
|
626
|
+
): void => {
|
627
|
+
for (const g of gesture.toGestureArray()) {
|
628
|
+
g.config.touchAction = touchAction;
|
629
|
+
}
|
630
|
+
};
|
631
|
+
|
617
632
|
interface GestureDetectorProps {
|
633
|
+
/**
|
634
|
+
* A gesture object containing the configuration and callbacks.
|
635
|
+
* Can be any of:
|
636
|
+
* - base gestures (`Tap`, `Pan`, ...)
|
637
|
+
* - `ComposedGesture` (`Race`, `Simultaneous`, `Exclusive`)
|
638
|
+
*/
|
618
639
|
gesture: ComposedGesture | GestureType;
|
619
640
|
children?: React.ReactNode;
|
641
|
+
|
642
|
+
/**
|
643
|
+
* #### Web only
|
644
|
+
* This parameter allows to specify which `userSelect` property should be applied to underlying view.
|
645
|
+
* Possible values are `"none" | "auto" | "text"`. Default value is set to `"none"`.
|
646
|
+
*/
|
620
647
|
userSelect?: UserSelect;
|
648
|
+
/**
|
649
|
+
* #### Web only
|
650
|
+
* Specifies whether context menu should be enabled after clicking on underlying view with right mouse button.
|
651
|
+
* Default value is set to `false`.
|
652
|
+
*/
|
621
653
|
enableContextMenu?: boolean;
|
654
|
+
/**
|
655
|
+
* #### Web only
|
656
|
+
* This parameter allows to specify which `touchAction` property should be applied to underlying view.
|
657
|
+
* Supports all CSS touch-action values (e.g. `"none"`, `"pan-y"`). Default value is set to `"none"`.
|
658
|
+
*/
|
659
|
+
touchAction?: TouchAction;
|
622
660
|
}
|
623
661
|
interface GestureDetectorState {
|
624
662
|
firstRender: boolean;
|
@@ -626,6 +664,22 @@ interface GestureDetectorState {
|
|
626
664
|
previousViewTag: number;
|
627
665
|
forceReattach: boolean;
|
628
666
|
}
|
667
|
+
|
668
|
+
/**
|
669
|
+
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
|
670
|
+
*
|
671
|
+
* ### Props
|
672
|
+
* - `gesture`
|
673
|
+
* - `userSelect` (**Web only**)
|
674
|
+
* - `enableContextMenu` (**Web only**)
|
675
|
+
* - `touchAction` (**Web only**)
|
676
|
+
*
|
677
|
+
* ### Remarks
|
678
|
+
* - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
|
679
|
+
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
|
680
|
+
*
|
681
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
|
682
|
+
*/
|
629
683
|
export const GestureDetector = (props: GestureDetectorProps) => {
|
630
684
|
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
631
685
|
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
|
@@ -644,6 +698,10 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
644
698
|
applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
|
645
699
|
}
|
646
700
|
|
701
|
+
if (props.touchAction !== undefined) {
|
702
|
+
applyTouchActionProp(props.touchAction, gestureConfig);
|
703
|
+
}
|
704
|
+
|
647
705
|
const gesture = gestureConfig.toGestureArray();
|
648
706
|
const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);
|
649
707
|
|
@@ -13,11 +13,22 @@ export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
|
|
13
13
|
this.handlerName = 'FlingGestureHandler';
|
14
14
|
}
|
15
15
|
|
16
|
+
/**
|
17
|
+
* Determine exact number of points required to handle the fling gesture.
|
18
|
+
* @param pointers
|
19
|
+
*/
|
16
20
|
numberOfPointers(pointers: number) {
|
17
21
|
this.config.numberOfPointers = pointers;
|
18
22
|
return this;
|
19
23
|
}
|
20
24
|
|
25
|
+
/**
|
26
|
+
* Expressed allowed direction of movement.
|
27
|
+
* Expected values are exported as constants in the Directions object.
|
28
|
+
* Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.
|
29
|
+
* @param direction
|
30
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
|
31
|
+
*/
|
21
32
|
direction(direction: number) {
|
22
33
|
this.config.direction = direction;
|
23
34
|
return this;
|
@@ -40,16 +40,30 @@ export class ForceTouchGesture extends ContinousBaseGesture<
|
|
40
40
|
this.handlerName = 'ForceTouchGestureHandler';
|
41
41
|
}
|
42
42
|
|
43
|
+
/**
|
44
|
+
* A minimal pressure that is required before gesture can activate.
|
45
|
+
* Should be a value from range [0.0, 1.0]. Default is 0.2.
|
46
|
+
* @param force
|
47
|
+
*/
|
43
48
|
minForce(force: number) {
|
44
49
|
this.config.minForce = force;
|
45
50
|
return this;
|
46
51
|
}
|
47
52
|
|
53
|
+
/**
|
54
|
+
* A maximal pressure that could be applied for gesture.
|
55
|
+
* If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
|
56
|
+
* @param force
|
57
|
+
*/
|
48
58
|
maxForce(force: number) {
|
49
59
|
this.config.maxForce = force;
|
50
60
|
return this;
|
51
61
|
}
|
52
62
|
|
63
|
+
/**
|
64
|
+
* Value defining if haptic feedback has to be performed on activation.
|
65
|
+
* @param value
|
66
|
+
*/
|
53
67
|
feedbackOnActivation(value: boolean) {
|
54
68
|
this.config.feedbackOnActivation = value;
|
55
69
|
return this;
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
GestureStateChangeEvent,
|
8
8
|
GestureUpdateEvent,
|
9
9
|
ActiveCursor,
|
10
|
+
MouseButton,
|
10
11
|
} from '../gestureHandlerCommon';
|
11
12
|
import { getNextHandlerTag } from '../handlersRegistry';
|
12
13
|
import { GestureStateManagerType } from './gestureStateManager';
|
@@ -17,7 +18,6 @@ import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
|
|
17
18
|
import { TapGestureHandlerEventPayload } from '../TapGestureHandler';
|
18
19
|
import { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';
|
19
20
|
import { isRemoteDebuggingEnabled } from '../../utils';
|
20
|
-
import { MouseButton } from '../../web/interfaces';
|
21
21
|
|
22
22
|
export type GestureType =
|
23
23
|
| BaseGesture<Record<string, unknown>>
|
@@ -155,6 +155,10 @@ export abstract class BaseGesture<
|
|
155
155
|
: [gesture];
|
156
156
|
}
|
157
157
|
|
158
|
+
/**
|
159
|
+
* Sets a `ref` to the gesture object, allowing for interoperability with the old API.
|
160
|
+
* @param ref
|
161
|
+
*/
|
158
162
|
withRef(ref: React.MutableRefObject<GestureType | undefined>) {
|
159
163
|
this.config.ref = ref;
|
160
164
|
return this;
|
@@ -166,18 +170,32 @@ export abstract class BaseGesture<
|
|
166
170
|
return callback.__workletHash !== undefined;
|
167
171
|
}
|
168
172
|
|
173
|
+
/**
|
174
|
+
* Set the callback that is being called when given gesture handler starts receiving touches.
|
175
|
+
* At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
|
176
|
+
* @param callback
|
177
|
+
*/
|
169
178
|
onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {
|
170
179
|
this.handlers.onBegin = callback;
|
171
180
|
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
|
172
181
|
return this;
|
173
182
|
}
|
174
183
|
|
184
|
+
/**
|
185
|
+
* Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
|
186
|
+
* @param callback
|
187
|
+
*/
|
175
188
|
onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {
|
176
189
|
this.handlers.onStart = callback;
|
177
190
|
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
|
178
191
|
return this;
|
179
192
|
}
|
180
193
|
|
194
|
+
/**
|
195
|
+
* Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
|
196
|
+
* It will be called only if the handler was previously in the `ACTIVE` state.
|
197
|
+
* @param callback
|
198
|
+
*/
|
181
199
|
onEnd(
|
182
200
|
callback: (
|
183
201
|
event: GestureStateChangeEvent<EventPayloadT>,
|
@@ -190,6 +208,10 @@ export abstract class BaseGesture<
|
|
190
208
|
return this;
|
191
209
|
}
|
192
210
|
|
211
|
+
/**
|
212
|
+
* Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
|
213
|
+
* @param callback
|
214
|
+
*/
|
193
215
|
onFinalize(
|
194
216
|
callback: (
|
195
217
|
event: GestureStateChangeEvent<EventPayloadT>,
|
@@ -202,6 +224,10 @@ export abstract class BaseGesture<
|
|
202
224
|
return this;
|
203
225
|
}
|
204
226
|
|
227
|
+
/**
|
228
|
+
* Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
|
229
|
+
* @param callback
|
230
|
+
*/
|
205
231
|
onTouchesDown(callback: TouchEventHandlerType) {
|
206
232
|
this.config.needsPointerData = true;
|
207
233
|
this.handlers.onTouchesDown = callback;
|
@@ -211,6 +237,10 @@ export abstract class BaseGesture<
|
|
211
237
|
return this;
|
212
238
|
}
|
213
239
|
|
240
|
+
/**
|
241
|
+
* Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
|
242
|
+
* @param callback
|
243
|
+
*/
|
214
244
|
onTouchesMove(callback: TouchEventHandlerType) {
|
215
245
|
this.config.needsPointerData = true;
|
216
246
|
this.handlers.onTouchesMove = callback;
|
@@ -220,6 +250,10 @@ export abstract class BaseGesture<
|
|
220
250
|
return this;
|
221
251
|
}
|
222
252
|
|
253
|
+
/**
|
254
|
+
* Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
|
255
|
+
* @param callback
|
256
|
+
*/
|
223
257
|
onTouchesUp(callback: TouchEventHandlerType) {
|
224
258
|
this.config.needsPointerData = true;
|
225
259
|
this.handlers.onTouchesUp = callback;
|
@@ -229,6 +263,10 @@ export abstract class BaseGesture<
|
|
229
263
|
return this;
|
230
264
|
}
|
231
265
|
|
266
|
+
/**
|
267
|
+
* Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
|
268
|
+
* @param callback
|
269
|
+
*/
|
232
270
|
onTouchesCancelled(callback: TouchEventHandlerType) {
|
233
271
|
this.config.needsPointerData = true;
|
234
272
|
this.handlers.onTouchesCancelled = callback;
|
@@ -238,36 +276,77 @@ export abstract class BaseGesture<
|
|
238
276
|
return this;
|
239
277
|
}
|
240
278
|
|
279
|
+
/**
|
280
|
+
* Indicates whether the given handler should be analyzing stream of touch events or not.
|
281
|
+
* @param enabled
|
282
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
|
283
|
+
*/
|
241
284
|
enabled(enabled: boolean) {
|
242
285
|
this.config.enabled = enabled;
|
243
286
|
return this;
|
244
287
|
}
|
245
288
|
|
289
|
+
/**
|
290
|
+
* When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
|
291
|
+
* @param value
|
292
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
|
293
|
+
*/
|
246
294
|
shouldCancelWhenOutside(value: boolean) {
|
247
295
|
this.config.shouldCancelWhenOutside = value;
|
248
296
|
return this;
|
249
297
|
}
|
250
298
|
|
299
|
+
/**
|
300
|
+
* This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
|
301
|
+
* When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
|
302
|
+
* @param hitSlop
|
303
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
|
304
|
+
*/
|
251
305
|
hitSlop(hitSlop: HitSlop) {
|
252
306
|
this.config.hitSlop = hitSlop;
|
253
307
|
return this;
|
254
308
|
}
|
255
309
|
|
310
|
+
/**
|
311
|
+
* #### Web only
|
312
|
+
* This parameter allows to specify which `cursor` should be used when gesture activates.
|
313
|
+
* Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
|
314
|
+
* @param activeCursor
|
315
|
+
*/
|
256
316
|
activeCursor(activeCursor: ActiveCursor) {
|
257
317
|
this.config.activeCursor = activeCursor;
|
258
318
|
return this;
|
259
319
|
}
|
260
320
|
|
321
|
+
/**
|
322
|
+
* #### Web & Android only
|
323
|
+
* Allows users to choose which mouse button should handler respond to.
|
324
|
+
* Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
|
325
|
+
* Default value is set to `MouseButton.LEFT`.
|
326
|
+
* @param mouseButton
|
327
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
|
328
|
+
*/
|
261
329
|
mouseButton(mouseButton: MouseButton) {
|
262
330
|
this.config.mouseButton = mouseButton;
|
263
331
|
return this;
|
264
332
|
}
|
265
333
|
|
334
|
+
/**
|
335
|
+
* When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
|
336
|
+
* This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
|
337
|
+
* Defaults to `false`.
|
338
|
+
* @param runOnJS
|
339
|
+
*/
|
266
340
|
runOnJS(runOnJS: boolean) {
|
267
341
|
this.config.runOnJS = runOnJS;
|
268
342
|
return this;
|
269
343
|
}
|
270
344
|
|
345
|
+
/**
|
346
|
+
* Allows gestures across different components to be recognized simultaneously.
|
347
|
+
* @param gestures
|
348
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
|
349
|
+
*/
|
271
350
|
simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {
|
272
351
|
for (const gesture of gestures) {
|
273
352
|
this.addDependency('simultaneousWith', gesture);
|
@@ -275,6 +354,11 @@ export abstract class BaseGesture<
|
|
275
354
|
return this;
|
276
355
|
}
|
277
356
|
|
357
|
+
/**
|
358
|
+
* Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
|
359
|
+
* @param gestures
|
360
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
|
361
|
+
*/
|
278
362
|
requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {
|
279
363
|
for (const gesture of gestures) {
|
280
364
|
this.addDependency('requireToFail', gesture);
|
@@ -282,6 +366,11 @@ export abstract class BaseGesture<
|
|
282
366
|
return this;
|
283
367
|
}
|
284
368
|
|
369
|
+
/**
|
370
|
+
* Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
|
371
|
+
* @param gestures
|
372
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
|
373
|
+
*/
|
285
374
|
blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {
|
286
375
|
for (const gesture of gestures) {
|
287
376
|
this.addDependency('blocksHandlers', gesture);
|
@@ -289,11 +378,21 @@ export abstract class BaseGesture<
|
|
289
378
|
return this;
|
290
379
|
}
|
291
380
|
|
381
|
+
/**
|
382
|
+
* Sets a `testID` property for gesture object, allowing for querying for it in tests.
|
383
|
+
* @param id
|
384
|
+
*/
|
292
385
|
withTestId(id: string) {
|
293
386
|
this.config.testId = id;
|
294
387
|
return this;
|
295
388
|
}
|
296
389
|
|
390
|
+
/**
|
391
|
+
* #### iOS only
|
392
|
+
* When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
|
393
|
+
* Default value is `true`.
|
394
|
+
* @param value
|
395
|
+
*/
|
297
396
|
cancelsTouchesInView(value: boolean) {
|
298
397
|
this.config.cancelsTouchesInView = value;
|
299
398
|
return this;
|
@@ -332,12 +431,21 @@ export abstract class ContinousBaseGesture<
|
|
332
431
|
EventPayloadT extends Record<string, unknown>,
|
333
432
|
EventChangePayloadT extends Record<string, unknown>
|
334
433
|
> extends BaseGesture<EventPayloadT> {
|
434
|
+
/**
|
435
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
436
|
+
* @param callback
|
437
|
+
*/
|
335
438
|
onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {
|
336
439
|
this.handlers.onUpdate = callback;
|
337
440
|
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
|
338
441
|
return this;
|
339
442
|
}
|
340
443
|
|
444
|
+
/**
|
445
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
446
|
+
* This callback will receive information about change in value in relation to the last received event.
|
447
|
+
* @param callback
|
448
|
+
*/
|
341
449
|
onChange(
|
342
450
|
callback: (
|
343
451
|
event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>
|
@@ -348,6 +456,11 @@ export abstract class ContinousBaseGesture<
|
|
348
456
|
return this;
|
349
457
|
}
|
350
458
|
|
459
|
+
/**
|
460
|
+
* When `true` the handler will not activate by itself even if its activation criteria are met.
|
461
|
+
* Instead you can manipulate its state using state manager.
|
462
|
+
* @param manualActivation
|
463
|
+
*/
|
351
464
|
manualActivation(manualActivation: boolean) {
|
352
465
|
this.config.manualActivation = manualActivation;
|
353
466
|
return this;
|
@@ -15,43 +15,97 @@ import { NativeGesture } from './nativeGesture';
|
|
15
15
|
import { ManualGesture } from './manualGesture';
|
16
16
|
import { HoverGesture } from './hoverGesture';
|
17
17
|
|
18
|
+
/**
|
19
|
+
* `Gesture` is the object that allows you to create and compose gestures.
|
20
|
+
*
|
21
|
+
* ### Remarks
|
22
|
+
* - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.
|
23
|
+
*
|
24
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture
|
25
|
+
*/
|
18
26
|
export const GestureObjects = {
|
27
|
+
/**
|
28
|
+
* A discrete gesture that recognizes one or many taps.
|
29
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
|
30
|
+
*/
|
19
31
|
Tap: () => {
|
20
32
|
return new TapGesture();
|
21
33
|
},
|
22
34
|
|
35
|
+
/**
|
36
|
+
* A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
|
37
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
|
38
|
+
*/
|
23
39
|
Pan: () => {
|
24
40
|
return new PanGesture();
|
25
41
|
},
|
26
42
|
|
43
|
+
/**
|
44
|
+
* A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
|
45
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
|
46
|
+
*/
|
27
47
|
Pinch: () => {
|
28
48
|
return new PinchGesture();
|
29
49
|
},
|
30
50
|
|
51
|
+
/**
|
52
|
+
* A continuous gesture that can recognize rotation and track its movement.
|
53
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
|
54
|
+
*/
|
31
55
|
Rotation: () => {
|
32
56
|
return new RotationGesture();
|
33
57
|
},
|
34
58
|
|
59
|
+
/**
|
60
|
+
* A discrete gesture that activates when the movement is sufficiently fast.
|
61
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
|
62
|
+
*/
|
35
63
|
Fling: () => {
|
36
64
|
return new FlingGesture();
|
37
65
|
},
|
38
66
|
|
67
|
+
/**
|
68
|
+
* A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
|
69
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
|
70
|
+
*/
|
39
71
|
LongPress: () => {
|
40
72
|
return new LongPressGesture();
|
41
73
|
},
|
42
74
|
|
75
|
+
/**
|
76
|
+
* #### iOS only
|
77
|
+
* A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
|
78
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
|
79
|
+
*/
|
43
80
|
ForceTouch: () => {
|
44
81
|
return new ForceTouchGesture();
|
45
82
|
},
|
46
83
|
|
84
|
+
/**
|
85
|
+
* A gesture that allows other touch handling components to participate in RNGH's gesture system.
|
86
|
+
* When used, the other component should be the direct child of a `GestureDetector`.
|
87
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
|
88
|
+
*/
|
47
89
|
Native: () => {
|
48
90
|
return new NativeGesture();
|
49
91
|
},
|
50
92
|
|
93
|
+
/**
|
94
|
+
* A plain gesture that has no specific activation criteria nor event data set.
|
95
|
+
* Its state has to be controlled manually using a state manager.
|
96
|
+
* It will not fail when all the pointers are lifted from the screen.
|
97
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture
|
98
|
+
*/
|
51
99
|
Manual: () => {
|
52
100
|
return new ManualGesture();
|
53
101
|
},
|
54
102
|
|
103
|
+
/**
|
104
|
+
* A continuous gesture that can recognize hovering above the view it's attached to.
|
105
|
+
* The hover effect may be activated by moving a mouse or a stylus over the view.
|
106
|
+
*
|
107
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture
|
108
|
+
*/
|
55
109
|
Hover: () => {
|
56
110
|
return new HoverGesture();
|
57
111
|
},
|
@@ -59,6 +113,7 @@ export const GestureObjects = {
|
|
59
113
|
/**
|
60
114
|
* Builds a composed gesture consisting of gestures provided as parameters.
|
61
115
|
* The first one that becomes active cancels the rest of gestures.
|
116
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
|
62
117
|
*/
|
63
118
|
Race: (...gestures: Gesture[]) => {
|
64
119
|
return new ComposedGesture(...gestures);
|
@@ -66,6 +121,7 @@ export const GestureObjects = {
|
|
66
121
|
|
67
122
|
/**
|
68
123
|
* Builds a composed gesture that allows all base gestures to run simultaneously.
|
124
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
|
69
125
|
*/
|
70
126
|
Simultaneous(...gestures: Gesture[]) {
|
71
127
|
return new SimultaneousGesture(...gestures);
|
@@ -77,6 +133,7 @@ export const GestureObjects = {
|
|
77
133
|
* than the second one, second one has higher priority than the third one, and so on.
|
78
134
|
* For example, to make a gesture that recognizes both single and double tap you need
|
79
135
|
* to call Exclusive(doubleTap, singleTap).
|
136
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive
|
80
137
|
*/
|
81
138
|
Exclusive(...gestures: Gesture[]) {
|
82
139
|
return new ExclusiveGesture(...gestures);
|
@@ -14,11 +14,21 @@ export class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPa
|
|
14
14
|
this.shouldCancelWhenOutside(true);
|
15
15
|
}
|
16
16
|
|
17
|
+
/**
|
18
|
+
* Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.
|
19
|
+
* The default value is 500.
|
20
|
+
* @param duration
|
21
|
+
*/
|
17
22
|
minDuration(duration: number) {
|
18
23
|
this.config.minDurationMs = duration;
|
19
24
|
return this;
|
20
25
|
}
|
21
26
|
|
27
|
+
/**
|
28
|
+
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.
|
29
|
+
* @param distance
|
30
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number
|
31
|
+
*/
|
22
32
|
maxDistance(distance: number) {
|
23
33
|
this.config.maxDist = distance;
|
24
34
|
return this;
|
@@ -13,11 +13,19 @@ export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload>
|
|
13
13
|
this.handlerName = 'NativeViewGestureHandler';
|
14
14
|
}
|
15
15
|
|
16
|
+
/**
|
17
|
+
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
|
18
|
+
* @param value
|
19
|
+
*/
|
16
20
|
shouldActivateOnStart(value: boolean) {
|
17
21
|
this.config.shouldActivateOnStart = value;
|
18
22
|
return this;
|
19
23
|
}
|
20
24
|
|
25
|
+
/**
|
26
|
+
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
27
|
+
* @param value
|
28
|
+
*/
|
21
29
|
disallowInterruption(value: boolean) {
|
22
30
|
this.config.disallowInterruption = value;
|
23
31
|
return this;
|