react-native-gesture-handler 2.16.1 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -3
- package/android/build.gradle +105 -0
- package/android/gradle.properties +7 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +7 -7
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -5
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +4 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +1 -0
- package/apple/RNGestureHandlerButtonComponentView.mm +10 -0
- package/apple/RNGestureHandlerModule.mm +2 -3
- package/lib/commonjs/RNGestureHandlerModule.js +4 -97
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +109 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/commonjs/RNRenderer.js +10 -5
- package/lib/commonjs/RNRenderer.js.map +1 -1
- package/lib/commonjs/RNRenderer.web.js +11 -0
- package/lib/commonjs/RNRenderer.web.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js +27 -12
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +82 -19
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.web.js +52 -0
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +3 -13
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerRootView.js +6 -0
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -7
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/commonjs/getReactNativeVersion.js +12 -1
- package/lib/commonjs/getReactNativeVersion.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.web.js +11 -0
- package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.js +34 -5
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
- package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/commonjs/handlers/PressabilityDebugView.js +7 -5
- package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.web.js +12 -0
- package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +1 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/customDirectEventTypes.js +8 -5
- package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -1
- package/lib/commonjs/handlers/customDirectEventTypes.web.js +11 -0
- package/lib/commonjs/handlers/customDirectEventTypes.web.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +3 -3
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js +42 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +83 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +143 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js +6 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +80 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +180 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +55 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +47 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +176 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +3 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/utils.js +36 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +56 -64
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +28 -18
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +18 -12
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +7 -2
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +89 -57
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +6 -2
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +2 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/commonjs/web/utils.js +31 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +4 -84
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +85 -0
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/module/RNRenderer.js +3 -3
- package/lib/module/RNRenderer.js.map +1 -1
- package/lib/module/RNRenderer.web.js +4 -0
- package/lib/module/RNRenderer.web.js.map +1 -0
- package/lib/module/components/GestureButtons.js +24 -6
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js +80 -18
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/GestureComponents.web.js +28 -0
- package/lib/module/components/GestureComponents.web.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.js +2 -8
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.web.js +9 -0
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.js +5 -0
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -6
- package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/module/getReactNativeVersion.js +7 -1
- package/lib/module/getReactNativeVersion.js.map +1 -1
- package/lib/module/getReactNativeVersion.web.js +4 -0
- package/lib/module/getReactNativeVersion.web.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.js +33 -4
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.web.js +8 -0
- package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/module/handlers/PressabilityDebugView.js +2 -4
- package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.web.js +5 -0
- package/lib/module/handlers/PressabilityDebugView.web.js.map +1 -0
- package/lib/module/handlers/createHandler.js +2 -4
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/customDirectEventTypes.js +2 -4
- package/lib/module/handlers/customDirectEventTypes.js.map +1 -1
- package/lib/module/handlers/customDirectEventTypes.web.js +5 -0
- package/lib/module/handlers/customDirectEventTypes.web.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js +26 -0
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +65 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +115 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +64 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +165 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +41 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +36 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js +142 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +3 -1
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/utils.js +34 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +56 -64
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +28 -18
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +18 -12
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +8 -3
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +89 -57
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +7 -3
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/Vector.js +2 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/module/web/utils.js +29 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +2 -15
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +15 -0
- package/lib/typescript/RNRenderer.d.ts +1 -3
- package/lib/typescript/RNRenderer.web.d.ts +3 -0
- package/lib/typescript/components/GestureButtons.d.ts +3 -34
- package/lib/typescript/components/GestureComponents.d.ts +21 -7
- package/lib/typescript/components/GestureComponents.web.d.ts +8 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +4 -0
- package/lib/typescript/getReactNativeVersion.d.ts +4 -1
- package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -2
- package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +2 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -2
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +2 -0
- package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts} +4 -12
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +20 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +4 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +2 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +5 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -1
- package/lib/typescript/utils.d.ts +10 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +34 -31
- package/lib/typescript/web/utils.d.ts +4 -0
- package/package.json +5 -5
- package/src/RNGestureHandlerModule.ts +4 -104
- package/src/RNGestureHandlerModule.web.ts +105 -0
- package/src/RNRenderer.ts +3 -3
- package/src/RNRenderer.web.ts +3 -0
- package/src/components/GestureButtons.tsx +36 -4
- package/src/components/GestureComponents.tsx +131 -24
- package/src/components/GestureComponents.web.tsx +41 -0
- package/src/components/GestureHandlerButton.tsx +4 -5
- package/src/components/GestureHandlerButton.web.tsx +6 -0
- package/src/components/GestureHandlerRootView.tsx +6 -0
- package/src/components/{GestureHandlerRootView.native.tsx → GestureHandlerRootView.web.tsx} +0 -6
- package/src/getReactNativeVersion.ts +9 -1
- package/src/getReactNativeVersion.web.ts +3 -0
- package/src/getShadowNodeFromRef.ts +41 -4
- package/src/getShadowNodeFromRef.web.ts +7 -0
- package/src/handlers/PressabilityDebugView.tsx +2 -4
- package/src/handlers/PressabilityDebugView.web.tsx +4 -0
- package/src/handlers/createHandler.tsx +1 -3
- package/src/handlers/customDirectEventTypes.ts +2 -5
- package/src/handlers/customDirectEventTypes.web.ts +5 -0
- package/src/handlers/gestureHandlerCommon.ts +4 -1
- package/src/handlers/gestures/GestureDetector/Wrap.tsx +35 -0
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +112 -0
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +14 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +187 -0
- package/src/handlers/gestures/GestureDetector/needsToReattach.ts +27 -0
- package/src/handlers/gestures/GestureDetector/types.ts +32 -0
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +94 -0
- package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +206 -0
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +69 -0
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +54 -0
- package/src/handlers/gestures/GestureDetector/utils.ts +185 -0
- package/src/handlers/gestures/gestureComposition.ts +2 -0
- package/src/handlers/gestures/gestureStateManager.ts +12 -4
- package/src/handlers/gestures/reanimatedWrapper.ts +19 -17
- package/src/utils.ts +39 -0
- package/src/web/detectors/RotationGestureDetector.ts +6 -8
- package/src/web/detectors/ScaleGestureDetector.ts +5 -6
- package/src/web/handlers/FlingGestureHandler.ts +2 -0
- package/src/web/handlers/GestureHandler.ts +53 -62
- package/src/web/handlers/LongPressGestureHandler.ts +2 -0
- package/src/web/handlers/ManualGestureHandler.ts +2 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +8 -4
- package/src/web/handlers/PanGestureHandler.ts +32 -19
- package/src/web/handlers/PinchGestureHandler.ts +2 -0
- package/src/web/handlers/RotationGestureHandler.ts +2 -0
- package/src/web/handlers/TapGestureHandler.ts +20 -12
- package/src/web/interfaces.ts +1 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
- package/src/web/tools/PointerEventManager.ts +10 -3
- package/src/web/tools/PointerTracker.ts +81 -74
- package/src/web/tools/TouchEventManager.ts +5 -3
- package/src/web/tools/Vector.ts +2 -4
- package/src/web/utils.ts +34 -0
- package/lib/commonjs/RNGestureHandlerModule.native.js +0 -16
- package/lib/commonjs/RNGestureHandlerModule.native.js.map +0 -1
- package/lib/commonjs/RNRenderer.native.js +0 -16
- package/lib/commonjs/RNRenderer.native.js.map +0 -1
- package/lib/commonjs/components/GestureComponents.native.js +0 -115
- package/lib/commonjs/components/GestureComponents.native.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerButton.native.js +0 -14
- package/lib/commonjs/components/GestureHandlerButton.native.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerRootView.native.js.map +0 -1
- package/lib/commonjs/getReactNativeVersion.native.js +0 -22
- package/lib/commonjs/getReactNativeVersion.native.js.map +0 -1
- package/lib/commonjs/getShadowNodeFromRef.native.js +0 -44
- package/lib/commonjs/getShadowNodeFromRef.native.js.map +0 -1
- package/lib/commonjs/handlers/PressabilityDebugView.native.js +0 -14
- package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +0 -1
- package/lib/commonjs/handlers/customDirectEventTypes.native.js +0 -14
- package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +0 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -704
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/module/RNGestureHandlerModule.native.js +0 -5
- package/lib/module/RNGestureHandlerModule.native.js.map +0 -1
- package/lib/module/RNRenderer.native.js +0 -4
- package/lib/module/RNRenderer.native.js.map +0 -1
- package/lib/module/components/GestureComponents.native.js +0 -90
- package/lib/module/components/GestureComponents.native.js.map +0 -1
- package/lib/module/components/GestureHandlerButton.native.js +0 -3
- package/lib/module/components/GestureHandlerButton.native.js.map +0 -1
- package/lib/module/components/GestureHandlerRootView.native.js.map +0 -1
- package/lib/module/getReactNativeVersion.native.js +0 -10
- package/lib/module/getReactNativeVersion.native.js.map +0 -1
- package/lib/module/getShadowNodeFromRef.native.js +0 -37
- package/lib/module/getShadowNodeFromRef.native.js.map +0 -1
- package/lib/module/handlers/PressabilityDebugView.native.js +0 -3
- package/lib/module/handlers/PressabilityDebugView.native.js.map +0 -1
- package/lib/module/handlers/customDirectEventTypes.native.js +0 -3
- package/lib/module/handlers/customDirectEventTypes.native.js.map +0 -1
- package/lib/module/handlers/gestures/GestureDetector.js +0 -654
- package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/typescript/RNGestureHandlerModule.native.d.ts +0 -2
- package/lib/typescript/RNRenderer.native.d.ts +0 -1
- package/lib/typescript/components/GestureComponents.native.d.ts +0 -22
- package/lib/typescript/components/GestureHandlerButton.native.d.ts +0 -4
- package/lib/typescript/getReactNativeVersion.native.d.ts +0 -4
- package/lib/typescript/getShadowNodeFromRef.native.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +0 -1
- package/src/RNGestureHandlerModule.native.ts +0 -5
- package/src/RNRenderer.native.ts +0 -3
- package/src/components/GestureComponents.native.tsx +0 -148
- package/src/components/GestureHandlerButton.native.tsx +0 -5
- package/src/getReactNativeVersion.native.ts +0 -11
- package/src/getShadowNodeFromRef.native.ts +0 -44
- package/src/handlers/PressabilityDebugView.native.tsx +0 -2
- package/src/handlers/customDirectEventTypes.native.ts +0 -2
- package/src/handlers/gestures/GestureDetector.tsx +0 -894
- /package/lib/typescript/components/{GestureHandlerRootView.native.d.ts → GestureHandlerRootView.web.d.ts} +0 -0
@@ -1,704 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.GestureDetector = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _gesture = require("./gesture");
|
11
|
-
|
12
|
-
var _reanimatedWrapper = require("./reanimatedWrapper");
|
13
|
-
|
14
|
-
var _handlersRegistry = require("../handlersRegistry");
|
15
|
-
|
16
|
-
var _RNGestureHandlerModule = _interopRequireDefault(require("../../RNGestureHandlerModule"));
|
17
|
-
|
18
|
-
var _gestureHandlerCommon = require("../gestureHandlerCommon");
|
19
|
-
|
20
|
-
var _gestureStateManager = require("./gestureStateManager");
|
21
|
-
|
22
|
-
var _FlingGestureHandler = require("../FlingGestureHandler");
|
23
|
-
|
24
|
-
var _ForceTouchGestureHandler = require("../ForceTouchGestureHandler");
|
25
|
-
|
26
|
-
var _LongPressGestureHandler = require("../LongPressGestureHandler");
|
27
|
-
|
28
|
-
var _PanGestureHandler = require("../PanGestureHandler");
|
29
|
-
|
30
|
-
var _TapGestureHandler = require("../TapGestureHandler");
|
31
|
-
|
32
|
-
var _hoverGesture = require("./hoverGesture");
|
33
|
-
|
34
|
-
var _State = require("../../State");
|
35
|
-
|
36
|
-
var _TouchEventType = require("../../TouchEventType");
|
37
|
-
|
38
|
-
var _ActionType = require("../../ActionType");
|
39
|
-
|
40
|
-
var _utils = require("../../utils");
|
41
|
-
|
42
|
-
var _getReactNativeVersion = require("../../getReactNativeVersion");
|
43
|
-
|
44
|
-
var _getShadowNodeFromRef = require("../../getShadowNodeFromRef");
|
45
|
-
|
46
|
-
var _reactNative = require("react-native");
|
47
|
-
|
48
|
-
var _eventReceiver = require("./eventReceiver");
|
49
|
-
|
50
|
-
var _RNRenderer = require("../../RNRenderer");
|
51
|
-
|
52
|
-
var _EnableNewWebImplementation = require("../../EnableNewWebImplementation");
|
53
|
-
|
54
|
-
var _NativeViewGestureHandler = require("../NativeViewGestureHandler");
|
55
|
-
|
56
|
-
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../../GestureHandlerRootViewContext"));
|
57
|
-
|
58
|
-
var _ghQueueMicrotask = require("../../ghQueueMicrotask");
|
59
|
-
|
60
|
-
var _Reanimated$default$c, _Reanimated$default;
|
61
|
-
|
62
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
63
|
-
|
64
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
65
|
-
|
66
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
67
|
-
|
68
|
-
const ALLOWED_PROPS = [..._gestureHandlerCommon.baseGestureHandlerWithMonitorProps, ..._TapGestureHandler.tapGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerCustomNativeProps, ..._LongPressGestureHandler.longPressGestureHandlerProps, ..._ForceTouchGestureHandler.forceTouchGestureHandlerProps, ..._FlingGestureHandler.flingGestureHandlerProps, ..._hoverGesture.hoverGestureHandlerProps, ..._NativeViewGestureHandler.nativeViewGestureHandlerProps];
|
69
|
-
|
70
|
-
function convertToHandlerTag(ref) {
|
71
|
-
if (typeof ref === 'number') {
|
72
|
-
return ref;
|
73
|
-
} else if (ref instanceof _gesture.BaseGesture) {
|
74
|
-
return ref.handlerTag;
|
75
|
-
} else {
|
76
|
-
var _ref$current$handlerT, _ref$current;
|
77
|
-
|
78
|
-
// @ts-ignore in this case it should be a ref either to gesture object or
|
79
|
-
// a gesture handler component, in both cases handlerTag property exists
|
80
|
-
return (_ref$current$handlerT = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.handlerTag) !== null && _ref$current$handlerT !== void 0 ? _ref$current$handlerT : -1;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
function extractValidHandlerTags(interactionGroup) {
|
85
|
-
var _interactionGroup$map, _interactionGroup$map2;
|
86
|
-
|
87
|
-
return (_interactionGroup$map = interactionGroup === null || interactionGroup === void 0 ? void 0 : (_interactionGroup$map2 = interactionGroup.map(convertToHandlerTag)) === null || _interactionGroup$map2 === void 0 ? void 0 : _interactionGroup$map2.filter(tag => tag > 0)) !== null && _interactionGroup$map !== void 0 ? _interactionGroup$map : [];
|
88
|
-
}
|
89
|
-
|
90
|
-
function dropHandlers(preparedGesture) {
|
91
|
-
for (const handler of preparedGesture.config) {
|
92
|
-
_RNGestureHandlerModule.default.dropGestureHandler(handler.handlerTag);
|
93
|
-
|
94
|
-
(0, _handlersRegistry.unregisterHandler)(handler.handlerTag, handler.config.testId);
|
95
|
-
}
|
96
|
-
|
97
|
-
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
98
|
-
}
|
99
|
-
|
100
|
-
function checkGestureCallbacksForWorklets(gesture) {
|
101
|
-
// if a gesture is explicitly marked to run on the JS thread there is no need to check
|
102
|
-
// if callbacks are worklets as the user is aware they will be ran on the JS thread
|
103
|
-
if (gesture.config.runOnJS) {
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
|
107
|
-
const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
|
108
|
-
const areSomeWorklets = gesture.handlers.isWorklet.includes(true); // if some of the callbacks are worklets and some are not, and the gesture is not
|
109
|
-
// explicitly marked with `.runOnJS(true)` show an error
|
110
|
-
|
111
|
-
if (areSomeNotWorklets && areSomeWorklets) {
|
112
|
-
console.error((0, _utils.tagMessage)(`Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`));
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
function attachHandlers({
|
117
|
-
preparedGesture,
|
118
|
-
gestureConfig,
|
119
|
-
gesture,
|
120
|
-
viewTag,
|
121
|
-
webEventHandlersRef,
|
122
|
-
mountedRef
|
123
|
-
}) {
|
124
|
-
if (!preparedGesture.firstExecution) {
|
125
|
-
gestureConfig.initialize();
|
126
|
-
} else {
|
127
|
-
preparedGesture.firstExecution = false;
|
128
|
-
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
|
129
|
-
// when it's ran
|
130
|
-
|
131
|
-
|
132
|
-
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
|
133
|
-
if (!mountedRef.current) {
|
134
|
-
return;
|
135
|
-
}
|
136
|
-
|
137
|
-
gestureConfig.prepare();
|
138
|
-
});
|
139
|
-
|
140
|
-
for (const handler of gesture) {
|
141
|
-
checkGestureCallbacksForWorklets(handler);
|
142
|
-
|
143
|
-
_RNGestureHandlerModule.default.createGestureHandler(handler.handlerName, handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, ALLOWED_PROPS));
|
144
|
-
|
145
|
-
(0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
|
146
|
-
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
|
147
|
-
// when it's ran
|
148
|
-
|
149
|
-
|
150
|
-
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
|
151
|
-
if (!mountedRef.current) {
|
152
|
-
return;
|
153
|
-
}
|
154
|
-
|
155
|
-
for (const handler of gesture) {
|
156
|
-
let requireToFail = [];
|
157
|
-
|
158
|
-
if (handler.config.requireToFail) {
|
159
|
-
requireToFail = extractValidHandlerTags(handler.config.requireToFail);
|
160
|
-
}
|
161
|
-
|
162
|
-
let simultaneousWith = [];
|
163
|
-
|
164
|
-
if (handler.config.simultaneousWith) {
|
165
|
-
simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
|
166
|
-
}
|
167
|
-
|
168
|
-
let blocksHandlers = [];
|
169
|
-
|
170
|
-
if (handler.config.blocksHandlers) {
|
171
|
-
blocksHandlers = extractValidHandlerTags(handler.config.blocksHandlers);
|
172
|
-
}
|
173
|
-
|
174
|
-
_RNGestureHandlerModule.default.updateGestureHandler(handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, ALLOWED_PROPS, {
|
175
|
-
simultaneousHandlers: simultaneousWith,
|
176
|
-
waitFor: requireToFail,
|
177
|
-
blocksHandlers: blocksHandlers
|
178
|
-
}));
|
179
|
-
}
|
180
|
-
|
181
|
-
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
182
|
-
});
|
183
|
-
preparedGesture.config = gesture;
|
184
|
-
|
185
|
-
for (const gesture of preparedGesture.config) {
|
186
|
-
const actionType = gesture.shouldUseReanimated ? _ActionType.ActionType.REANIMATED_WORKLET : _ActionType.ActionType.JS_FUNCTION_NEW_API;
|
187
|
-
|
188
|
-
if (_reactNative.Platform.OS === 'web') {
|
189
|
-
_RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, _ActionType.ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
190
|
-
webEventHandlersRef);
|
191
|
-
} else {
|
192
|
-
_RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
if (preparedGesture.animatedHandlers) {
|
197
|
-
const isAnimatedGesture = g => g.shouldUseReanimated;
|
198
|
-
|
199
|
-
preparedGesture.animatedHandlers.value = gesture.filter(isAnimatedGesture).map(g => g.handlers);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
|
204
|
-
gestureConfig.prepare();
|
205
|
-
|
206
|
-
for (let i = 0; i < gesture.length; i++) {
|
207
|
-
const handler = preparedGesture.config[i];
|
208
|
-
checkGestureCallbacksForWorklets(handler); // only update handlerTag when it's actually different, it may be the same
|
209
|
-
// if gesture config object is wrapped with useMemo
|
210
|
-
|
211
|
-
if (gesture[i].handlerTag !== handler.handlerTag) {
|
212
|
-
gesture[i].handlerTag = handler.handlerTag;
|
213
|
-
gesture[i].handlers.handlerTag = handler.handlerTag;
|
214
|
-
}
|
215
|
-
} // use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
|
216
|
-
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
|
217
|
-
// in case of external relations)
|
218
|
-
|
219
|
-
|
220
|
-
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
|
221
|
-
if (!mountedRef.current) {
|
222
|
-
return;
|
223
|
-
}
|
224
|
-
|
225
|
-
for (let i = 0; i < gesture.length; i++) {
|
226
|
-
const handler = preparedGesture.config[i];
|
227
|
-
handler.config = gesture[i].config;
|
228
|
-
handler.handlers = gesture[i].handlers;
|
229
|
-
const requireToFail = extractValidHandlerTags(handler.config.requireToFail);
|
230
|
-
const simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
|
231
|
-
|
232
|
-
_RNGestureHandlerModule.default.updateGestureHandler(handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, ALLOWED_PROPS, {
|
233
|
-
simultaneousHandlers: simultaneousWith,
|
234
|
-
waitFor: requireToFail
|
235
|
-
}));
|
236
|
-
|
237
|
-
(0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
|
238
|
-
}
|
239
|
-
|
240
|
-
if (preparedGesture.animatedHandlers) {
|
241
|
-
var _preparedGesture$anim;
|
242
|
-
|
243
|
-
const previousHandlersValue = (_preparedGesture$anim = preparedGesture.animatedHandlers.value) !== null && _preparedGesture$anim !== void 0 ? _preparedGesture$anim : [];
|
244
|
-
const newHandlersValue = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
|
245
|
-
.map(g => g.handlers); // if amount of gesture configs changes, we need to update the callbacks in shared value
|
246
|
-
|
247
|
-
let shouldUpdateSharedValue = previousHandlersValue.length !== newHandlersValue.length;
|
248
|
-
|
249
|
-
if (!shouldUpdateSharedValue) {
|
250
|
-
// if the amount is the same, we need to check if any of the configs inside has changed
|
251
|
-
for (let i = 0; i < newHandlersValue.length; i++) {
|
252
|
-
if ( // we can use the `gestureId` prop as it's unique for every config instance
|
253
|
-
newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId) {
|
254
|
-
shouldUpdateSharedValue = true;
|
255
|
-
break;
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
if (shouldUpdateSharedValue) {
|
261
|
-
preparedGesture.animatedHandlers.value = newHandlersValue;
|
262
|
-
}
|
263
|
-
}
|
264
|
-
|
265
|
-
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
266
|
-
});
|
267
|
-
}
|
268
|
-
|
269
|
-
function needsToReattach(preparedGesture, gesture) {
|
270
|
-
if (gesture.length !== preparedGesture.config.length) {
|
271
|
-
return true;
|
272
|
-
}
|
273
|
-
|
274
|
-
for (let i = 0; i < gesture.length; i++) {
|
275
|
-
if (gesture[i].handlerName !== preparedGesture.config[i].handlerName || gesture[i].shouldUseReanimated !== preparedGesture.config[i].shouldUseReanimated) {
|
276
|
-
return true;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
return false;
|
281
|
-
}
|
282
|
-
|
283
|
-
function isStateChangeEvent(event) {
|
284
|
-
'worklet'; // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
|
285
|
-
|
286
|
-
return event.oldState != null;
|
287
|
-
}
|
288
|
-
|
289
|
-
function isTouchEvent(event) {
|
290
|
-
'worklet';
|
291
|
-
|
292
|
-
return event.eventType != null;
|
293
|
-
}
|
294
|
-
|
295
|
-
function getHandler(type, gesture) {
|
296
|
-
'worklet';
|
297
|
-
|
298
|
-
switch (type) {
|
299
|
-
case _gesture.CALLBACK_TYPE.BEGAN:
|
300
|
-
return gesture.onBegin;
|
301
|
-
|
302
|
-
case _gesture.CALLBACK_TYPE.START:
|
303
|
-
return gesture.onStart;
|
304
|
-
|
305
|
-
case _gesture.CALLBACK_TYPE.UPDATE:
|
306
|
-
return gesture.onUpdate;
|
307
|
-
|
308
|
-
case _gesture.CALLBACK_TYPE.CHANGE:
|
309
|
-
return gesture.onChange;
|
310
|
-
|
311
|
-
case _gesture.CALLBACK_TYPE.END:
|
312
|
-
return gesture.onEnd;
|
313
|
-
|
314
|
-
case _gesture.CALLBACK_TYPE.FINALIZE:
|
315
|
-
return gesture.onFinalize;
|
316
|
-
|
317
|
-
case _gesture.CALLBACK_TYPE.TOUCHES_DOWN:
|
318
|
-
return gesture.onTouchesDown;
|
319
|
-
|
320
|
-
case _gesture.CALLBACK_TYPE.TOUCHES_MOVE:
|
321
|
-
return gesture.onTouchesMove;
|
322
|
-
|
323
|
-
case _gesture.CALLBACK_TYPE.TOUCHES_UP:
|
324
|
-
return gesture.onTouchesUp;
|
325
|
-
|
326
|
-
case _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED:
|
327
|
-
return gesture.onTouchesCancelled;
|
328
|
-
}
|
329
|
-
}
|
330
|
-
|
331
|
-
function touchEventTypeToCallbackType(eventType) {
|
332
|
-
'worklet';
|
333
|
-
|
334
|
-
switch (eventType) {
|
335
|
-
case _TouchEventType.TouchEventType.TOUCHES_DOWN:
|
336
|
-
return _gesture.CALLBACK_TYPE.TOUCHES_DOWN;
|
337
|
-
|
338
|
-
case _TouchEventType.TouchEventType.TOUCHES_MOVE:
|
339
|
-
return _gesture.CALLBACK_TYPE.TOUCHES_MOVE;
|
340
|
-
|
341
|
-
case _TouchEventType.TouchEventType.TOUCHES_UP:
|
342
|
-
return _gesture.CALLBACK_TYPE.TOUCHES_UP;
|
343
|
-
|
344
|
-
case _TouchEventType.TouchEventType.TOUCHES_CANCELLED:
|
345
|
-
return _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED;
|
346
|
-
}
|
347
|
-
|
348
|
-
return _gesture.CALLBACK_TYPE.UNDEFINED;
|
349
|
-
}
|
350
|
-
|
351
|
-
function runWorklet(type, gesture, event, ...args) {
|
352
|
-
'worklet';
|
353
|
-
|
354
|
-
const handler = getHandler(type, gesture);
|
355
|
-
|
356
|
-
if (gesture.isWorklet[type]) {
|
357
|
-
// @ts-ignore Logic below makes sure the correct event is send to the
|
358
|
-
// correct handler.
|
359
|
-
handler === null || handler === void 0 ? void 0 : handler(event, ...args);
|
360
|
-
} else if (handler) {
|
361
|
-
console.warn((0, _utils.tagMessage)('Animated gesture callback must be a worklet'));
|
362
|
-
}
|
363
|
-
}
|
364
|
-
|
365
|
-
function useAnimatedGesture(preparedGesture, needsRebuild) {
|
366
|
-
if (!_reanimatedWrapper.Reanimated) {
|
367
|
-
return;
|
368
|
-
} // Hooks are called conditionally, but the condition is whether the
|
369
|
-
// react-native-reanimated is installed, which shouldn't change while running
|
370
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
371
|
-
|
372
|
-
|
373
|
-
const sharedHandlersCallbacks = _reanimatedWrapper.Reanimated.useSharedValue(null); // eslint-disable-next-line react-hooks/rules-of-hooks
|
374
|
-
|
375
|
-
|
376
|
-
const lastUpdateEvent = _reanimatedWrapper.Reanimated.useSharedValue([]); // not every gesture needs a state controller, init them lazily
|
377
|
-
|
378
|
-
|
379
|
-
const stateControllers = [];
|
380
|
-
|
381
|
-
const callback = event => {
|
382
|
-
'worklet';
|
383
|
-
|
384
|
-
const currentCallback = sharedHandlersCallbacks.value;
|
385
|
-
|
386
|
-
if (!currentCallback) {
|
387
|
-
return;
|
388
|
-
}
|
389
|
-
|
390
|
-
for (let i = 0; i < currentCallback.length; i++) {
|
391
|
-
const gesture = currentCallback[i];
|
392
|
-
|
393
|
-
if (event.handlerTag === gesture.handlerTag) {
|
394
|
-
if (isStateChangeEvent(event)) {
|
395
|
-
if (event.oldState === _State.State.UNDETERMINED && event.state === _State.State.BEGAN) {
|
396
|
-
runWorklet(_gesture.CALLBACK_TYPE.BEGAN, gesture, event);
|
397
|
-
} else if ((event.oldState === _State.State.BEGAN || event.oldState === _State.State.UNDETERMINED) && event.state === _State.State.ACTIVE) {
|
398
|
-
runWorklet(_gesture.CALLBACK_TYPE.START, gesture, event);
|
399
|
-
lastUpdateEvent.value[gesture.handlerTag] = undefined;
|
400
|
-
} else if (event.oldState !== event.state && event.state === _State.State.END) {
|
401
|
-
if (event.oldState === _State.State.ACTIVE) {
|
402
|
-
runWorklet(_gesture.CALLBACK_TYPE.END, gesture, event, true);
|
403
|
-
}
|
404
|
-
|
405
|
-
runWorklet(_gesture.CALLBACK_TYPE.FINALIZE, gesture, event, true);
|
406
|
-
} else if ((event.state === _State.State.FAILED || event.state === _State.State.CANCELLED) && event.state !== event.oldState) {
|
407
|
-
if (event.oldState === _State.State.ACTIVE) {
|
408
|
-
runWorklet(_gesture.CALLBACK_TYPE.END, gesture, event, false);
|
409
|
-
}
|
410
|
-
|
411
|
-
runWorklet(_gesture.CALLBACK_TYPE.FINALIZE, gesture, event, false);
|
412
|
-
}
|
413
|
-
} else if (isTouchEvent(event)) {
|
414
|
-
if (!stateControllers[i]) {
|
415
|
-
stateControllers[i] = _gestureStateManager.GestureStateManager.create(event.handlerTag);
|
416
|
-
}
|
417
|
-
|
418
|
-
if (event.eventType !== _TouchEventType.TouchEventType.UNDETERMINED) {
|
419
|
-
runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
|
420
|
-
}
|
421
|
-
} else {
|
422
|
-
runWorklet(_gesture.CALLBACK_TYPE.UPDATE, gesture, event);
|
423
|
-
|
424
|
-
if (gesture.onChange && gesture.changeEventCalculator) {
|
425
|
-
var _gesture$changeEventC;
|
426
|
-
|
427
|
-
runWorklet(_gesture.CALLBACK_TYPE.CHANGE, gesture, (_gesture$changeEventC = gesture.changeEventCalculator) === null || _gesture$changeEventC === void 0 ? void 0 : _gesture$changeEventC.call(gesture, event, lastUpdateEvent.value[gesture.handlerTag]));
|
428
|
-
lastUpdateEvent.value[gesture.handlerTag] = event;
|
429
|
-
}
|
430
|
-
}
|
431
|
-
}
|
432
|
-
}
|
433
|
-
}; // eslint-disable-next-line react-hooks/rules-of-hooks
|
434
|
-
|
435
|
-
|
436
|
-
const event = _reanimatedWrapper.Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
|
437
|
-
|
438
|
-
preparedGesture.animatedEventHandler = event;
|
439
|
-
preparedGesture.animatedHandlers = sharedHandlersCallbacks;
|
440
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
441
|
-
|
442
|
-
|
443
|
-
function validateDetectorChildren(ref) {
|
444
|
-
// finds the first native view under the Wrap component and traverses the fiber tree upwards
|
445
|
-
// to check whether there is more than one native view as a pseudo-direct child of GestureDetector
|
446
|
-
// i.e. this is not ok:
|
447
|
-
// Wrap
|
448
|
-
// |
|
449
|
-
// / \
|
450
|
-
// / \
|
451
|
-
// / \
|
452
|
-
// / \
|
453
|
-
// NativeView NativeView
|
454
|
-
//
|
455
|
-
// but this is fine:
|
456
|
-
// Wrap
|
457
|
-
// |
|
458
|
-
// NativeView
|
459
|
-
// |
|
460
|
-
// / \
|
461
|
-
// / \
|
462
|
-
// / \
|
463
|
-
// / \
|
464
|
-
// NativeView NativeView
|
465
|
-
if (__DEV__ && _reactNative.Platform.OS !== 'web') {
|
466
|
-
const REACT_NATIVE_VERSION = (0, _getReactNativeVersion.getReactNativeVersion)(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
467
|
-
|
468
|
-
const wrapType = REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0 ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
469
|
-
ref._reactInternals.elementType : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
470
|
-
ref._reactInternalFiber.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
471
|
-
|
472
|
-
let instance = _RNRenderer.RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
473
|
-
|
474
|
-
|
475
|
-
while (instance && instance.elementType !== wrapType) {
|
476
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
477
|
-
if (instance.sibling) {
|
478
|
-
throw new Error('GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.');
|
479
|
-
} // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
480
|
-
|
481
|
-
|
482
|
-
instance = instance.return;
|
483
|
-
}
|
484
|
-
}
|
485
|
-
}
|
486
|
-
|
487
|
-
const applyUserSelectProp = (userSelect, gesture) => {
|
488
|
-
for (const g of gesture.toGestureArray()) {
|
489
|
-
g.config.userSelect = userSelect;
|
490
|
-
}
|
491
|
-
};
|
492
|
-
|
493
|
-
const applyEnableContextMenuProp = (enableContextMenu, gesture) => {
|
494
|
-
for (const g of gesture.toGestureArray()) {
|
495
|
-
g.config.enableContextMenu = enableContextMenu;
|
496
|
-
}
|
497
|
-
};
|
498
|
-
|
499
|
-
const applyTouchActionProp = (touchAction, gesture) => {
|
500
|
-
for (const g of gesture.toGestureArray()) {
|
501
|
-
g.config.touchAction = touchAction;
|
502
|
-
}
|
503
|
-
};
|
504
|
-
|
505
|
-
/**
|
506
|
-
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
|
507
|
-
*
|
508
|
-
* ### Props
|
509
|
-
* - `gesture`
|
510
|
-
* - `userSelect` (**Web only**)
|
511
|
-
* - `enableContextMenu` (**Web only**)
|
512
|
-
* - `touchAction` (**Web only**)
|
513
|
-
*
|
514
|
-
* ### Remarks
|
515
|
-
* - 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.
|
516
|
-
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
|
517
|
-
*
|
518
|
-
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
|
519
|
-
*/
|
520
|
-
const GestureDetector = props => {
|
521
|
-
const rootViewContext = (0, _react.useContext)(_GestureHandlerRootViewContext.default);
|
522
|
-
|
523
|
-
if (__DEV__ && !rootViewContext && !(0, _utils.isJestEnv)() && _reactNative.Platform.OS !== 'web') {
|
524
|
-
throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
|
525
|
-
}
|
526
|
-
|
527
|
-
const gestureConfig = props.gesture;
|
528
|
-
|
529
|
-
if (props.userSelect) {
|
530
|
-
applyUserSelectProp(props.userSelect, gestureConfig);
|
531
|
-
}
|
532
|
-
|
533
|
-
if (props.enableContextMenu !== undefined) {
|
534
|
-
applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
|
535
|
-
}
|
536
|
-
|
537
|
-
if (props.touchAction !== undefined) {
|
538
|
-
applyTouchActionProp(props.touchAction, gestureConfig);
|
539
|
-
}
|
540
|
-
|
541
|
-
const gesture = gestureConfig.toGestureArray();
|
542
|
-
const useReanimatedHook = gesture.some(g => g.shouldUseReanimated); // store state in ref to prevent unnecessary renders
|
543
|
-
|
544
|
-
const state = (0, _react.useRef)({
|
545
|
-
firstRender: true,
|
546
|
-
viewRef: null,
|
547
|
-
previousViewTag: -1,
|
548
|
-
forceReattach: false
|
549
|
-
}).current;
|
550
|
-
const mountedRef = (0, _react.useRef)(false);
|
551
|
-
const webEventHandlersRef = (0, _react.useRef)({
|
552
|
-
onGestureHandlerEvent: e => {
|
553
|
-
(0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
|
554
|
-
},
|
555
|
-
onGestureHandlerStateChange: (0, _EnableNewWebImplementation.isNewWebImplementationEnabled)() ? e => {
|
556
|
-
(0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
|
557
|
-
} : undefined
|
558
|
-
});
|
559
|
-
const [renderState, setRenderState] = (0, _react.useState)(false);
|
560
|
-
|
561
|
-
function forceRender() {
|
562
|
-
setRenderState(!renderState);
|
563
|
-
}
|
564
|
-
|
565
|
-
const preparedGesture = _react.default.useRef({
|
566
|
-
config: gesture,
|
567
|
-
animatedEventHandler: null,
|
568
|
-
animatedHandlers: null,
|
569
|
-
firstExecution: true,
|
570
|
-
useReanimatedHook: useReanimatedHook
|
571
|
-
}).current;
|
572
|
-
|
573
|
-
if (useReanimatedHook !== preparedGesture.useReanimatedHook) {
|
574
|
-
throw new Error((0, _utils.tagMessage)('You cannot change the thread the callbacks are ran on while the app is running'));
|
575
|
-
}
|
576
|
-
|
577
|
-
function onHandlersUpdate(skipConfigUpdate) {
|
578
|
-
// if the underlying view has changed we need to reattach handlers to the new view
|
579
|
-
const viewTag = (0, _gestureHandlerCommon.findNodeHandle)(state.viewRef);
|
580
|
-
const forceReattach = viewTag !== state.previousViewTag;
|
581
|
-
|
582
|
-
if (forceReattach || needsToReattach(preparedGesture, gesture)) {
|
583
|
-
validateDetectorChildren(state.viewRef);
|
584
|
-
dropHandlers(preparedGesture);
|
585
|
-
attachHandlers({
|
586
|
-
preparedGesture,
|
587
|
-
gestureConfig,
|
588
|
-
gesture,
|
589
|
-
webEventHandlersRef,
|
590
|
-
viewTag,
|
591
|
-
mountedRef
|
592
|
-
});
|
593
|
-
state.previousViewTag = viewTag;
|
594
|
-
state.forceReattach = forceReattach;
|
595
|
-
|
596
|
-
if (forceReattach) {
|
597
|
-
forceRender();
|
598
|
-
}
|
599
|
-
} else if (!skipConfigUpdate) {
|
600
|
-
updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);
|
601
|
-
}
|
602
|
-
} // Reanimated event should be rebuilt only when gestures are reattached, otherwise
|
603
|
-
// config update will be enough as all necessary items are stored in shared values anyway
|
604
|
-
|
605
|
-
|
606
|
-
const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture) || state.forceReattach;
|
607
|
-
state.forceReattach = false;
|
608
|
-
|
609
|
-
if (preparedGesture.firstExecution) {
|
610
|
-
gestureConfig.initialize();
|
611
|
-
}
|
612
|
-
|
613
|
-
if (useReanimatedHook) {
|
614
|
-
// Whether animatedGesture or gesture is used shouldn't change while the app is running
|
615
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
616
|
-
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
|
617
|
-
}
|
618
|
-
|
619
|
-
(0, _react.useEffect)(() => {
|
620
|
-
const viewTag = (0, _gestureHandlerCommon.findNodeHandle)(state.viewRef);
|
621
|
-
state.firstRender = true;
|
622
|
-
mountedRef.current = true;
|
623
|
-
validateDetectorChildren(state.viewRef);
|
624
|
-
attachHandlers({
|
625
|
-
preparedGesture,
|
626
|
-
gestureConfig,
|
627
|
-
gesture,
|
628
|
-
webEventHandlersRef,
|
629
|
-
viewTag,
|
630
|
-
mountedRef
|
631
|
-
});
|
632
|
-
return () => {
|
633
|
-
mountedRef.current = false;
|
634
|
-
dropHandlers(preparedGesture);
|
635
|
-
};
|
636
|
-
}, []);
|
637
|
-
(0, _react.useEffect)(() => {
|
638
|
-
if (!state.firstRender) {
|
639
|
-
onHandlersUpdate();
|
640
|
-
} else {
|
641
|
-
state.firstRender = false;
|
642
|
-
}
|
643
|
-
}, [props]);
|
644
|
-
|
645
|
-
const refFunction = ref => {
|
646
|
-
if (ref !== null) {
|
647
|
-
// @ts-ignore Just setting the view ref
|
648
|
-
state.viewRef = ref; // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
|
649
|
-
|
650
|
-
if (state.previousViewTag === -1) {
|
651
|
-
state.previousViewTag = (0, _gestureHandlerCommon.findNodeHandle)(state.viewRef);
|
652
|
-
} // pass true as `skipConfigUpdate`, here we only want to trigger the eventual reattaching of handlers
|
653
|
-
// in case the view has changed, while config update would be handled be the `useEffect` above
|
654
|
-
|
655
|
-
|
656
|
-
onHandlersUpdate(true);
|
657
|
-
|
658
|
-
if ((0, _utils.isFabric)() && global.isFormsStackingContext) {
|
659
|
-
const node = (0, _getShadowNodeFromRef.getShadowNodeFromRef)(ref);
|
660
|
-
|
661
|
-
if (global.isFormsStackingContext(node) === false) {
|
662
|
-
console.error((0, _utils.tagMessage)('GestureDetector has received a child that may get view-flattened. ' + '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
|
663
|
-
}
|
664
|
-
}
|
665
|
-
}
|
666
|
-
};
|
667
|
-
|
668
|
-
if (useReanimatedHook) {
|
669
|
-
return /*#__PURE__*/_react.default.createElement(AnimatedWrap, {
|
670
|
-
ref: refFunction,
|
671
|
-
onGestureHandlerEvent: preparedGesture.animatedEventHandler
|
672
|
-
}, props.children);
|
673
|
-
} else {
|
674
|
-
return /*#__PURE__*/_react.default.createElement(Wrap, {
|
675
|
-
ref: refFunction
|
676
|
-
}, props.children);
|
677
|
-
}
|
678
|
-
};
|
679
|
-
|
680
|
-
exports.GestureDetector = GestureDetector;
|
681
|
-
|
682
|
-
class Wrap extends _react.default.Component {
|
683
|
-
render() {
|
684
|
-
try {
|
685
|
-
// I don't think that fighting with types over such a simple function is worth it
|
686
|
-
// The only thing it does is add 'collapsable: false' to the child component
|
687
|
-
// to make sure it is in the native view hierarchy so the detector can find
|
688
|
-
// correct viewTag to attach to.
|
689
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
690
|
-
const child = _react.default.Children.only(this.props.children);
|
691
|
-
|
692
|
-
return /*#__PURE__*/_react.default.cloneElement(child, {
|
693
|
-
collapsable: false
|
694
|
-
}, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
695
|
-
child.props.children);
|
696
|
-
} catch (e) {
|
697
|
-
throw new Error((0, _utils.tagMessage)(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
|
698
|
-
}
|
699
|
-
}
|
700
|
-
|
701
|
-
}
|
702
|
-
|
703
|
-
const AnimatedWrap = (_Reanimated$default$c = _reanimatedWrapper.Reanimated === null || _reanimatedWrapper.Reanimated === void 0 ? void 0 : (_Reanimated$default = _reanimatedWrapper.Reanimated.default) === null || _Reanimated$default === void 0 ? void 0 : _Reanimated$default.createAnimatedComponent(Wrap)) !== null && _Reanimated$default$c !== void 0 ? _Reanimated$default$c : Wrap;
|
704
|
-
//# sourceMappingURL=GestureDetector.js.map
|