react-native-gesture-handler 3.0.0-beta.3 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +42 -38
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +34 -8
- package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +3 -6
- package/android/src/main/java/com/swmansion/gesturehandler/core/ManualGestureHandler.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +68 -7
- package/android/src/main/java/com/swmansion/gesturehandler/core/OnJSResponderCancelListener.kt +6 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +16 -6
- package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureHandler.kt +17 -4
- package/android/src/main/java/com/swmansion/gesturehandler/core/ViewConfigurationHelper.kt +0 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +21 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +160 -55
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt +75 -98
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +7 -10
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +64 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +18 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +15 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +0 -6
- package/apple/Handlers/RNForceTouchHandler.m +1 -1
- package/apple/Handlers/RNHoverHandler.m +11 -11
- package/apple/Handlers/RNLongPressHandler.m +2 -2
- package/apple/Handlers/RNManualHandler.m +5 -0
- package/apple/Handlers/RNNativeViewHandler.mm +114 -53
- package/apple/Handlers/RNPanHandler.m +7 -3
- package/apple/Handlers/RNPinchHandler.m +9 -3
- package/apple/Handlers/RNRotationHandler.m +7 -2
- package/apple/Handlers/RNTapHandler.m +1 -1
- package/apple/RNGestureHandler.h +18 -0
- package/apple/RNGestureHandler.mm +82 -33
- package/apple/RNGestureHandlerButton.h +12 -2
- package/apple/RNGestureHandlerButton.mm +208 -38
- package/apple/RNGestureHandlerButtonComponentView.mm +102 -6
- package/apple/RNGestureHandlerDetector.mm +99 -75
- package/apple/RNGestureHandlerModule.mm +11 -14
- package/apple/RNGestureHandlerRegistry.h +14 -1
- package/apple/RNGestureHandlerRegistry.m +56 -0
- package/apple/RNRootViewGestureRecognizer.m +4 -15
- package/lib/module/RNGestureHandlerModule.web.js +5 -1
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/GestureButtons.js +23 -12
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.web.js +113 -31
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +2 -1
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/stateDefinitions.js +2 -0
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +38 -5
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -6
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -2
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +11 -48
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +8 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +3 -3
- package/lib/module/handlers/gestures/gesture.js +8 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureComposition.js +28 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +27 -1
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +9 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js +8 -0
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js +8 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/manualGesture.js +8 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +8 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +13 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js +13 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js +14 -2
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/handlers/gestures/rotationGesture.js +8 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js +8 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/mocks/module.js +3 -2
- package/lib/module/mocks/module.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
- package/lib/module/v3/NativeProxy.js +5 -3
- package/lib/module/v3/NativeProxy.js.map +1 -1
- package/lib/module/v3/NativeProxy.web.js +2 -2
- package/lib/module/v3/NativeProxy.web.js.map +1 -1
- package/lib/module/v3/components/GestureButtons.js +11 -6
- package/lib/module/v3/components/GestureButtons.js.map +1 -1
- package/lib/module/v3/components/Pressable.js +3 -2
- package/lib/module/v3/components/Pressable.js.map +1 -1
- package/lib/module/v3/components/Touchable/Touchable.js +119 -32
- package/lib/module/v3/components/Touchable/Touchable.js.map +1 -1
- package/lib/module/v3/detectors/HostGestureDetector.web.js +180 -59
- package/lib/module/v3/detectors/HostGestureDetector.web.js.map +1 -1
- package/lib/module/v3/detectors/NativeDetector.js +3 -2
- package/lib/module/v3/detectors/NativeDetector.js.map +1 -1
- package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js +3 -4
- package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js.map +1 -1
- package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js +4 -2
- package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js.map +1 -1
- package/lib/module/v3/detectors/useGestureRelationsUpdater.js +23 -0
- package/lib/module/v3/detectors/useGestureRelationsUpdater.js.map +1 -0
- package/lib/module/v3/detectors/useNativeGestureRole.js +6 -0
- package/lib/module/v3/detectors/useNativeGestureRole.js.map +1 -0
- package/lib/module/v3/detectors/useNativeGestureRole.web.js +27 -0
- package/lib/module/v3/detectors/useNativeGestureRole.web.js.map +1 -0
- package/lib/module/v3/detectors/utils.js +10 -8
- package/lib/module/v3/detectors/utils.js.map +1 -1
- package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js +17 -2
- package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js.map +1 -1
- package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/manual/useManualGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/manual/useManualGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/native/NativeTypes.js +1 -1
- package/lib/module/v3/hooks/gestures/native/NativeTypes.js.map +1 -1
- package/lib/module/v3/hooks/gestures/native/useNativeGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/native/useNativeGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/pan/usePanGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/pan/usePanGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js.map +1 -1
- package/lib/module/v3/hooks/gestures/tap/useTapGesture.js +2 -1
- package/lib/module/v3/hooks/gestures/tap/useTapGesture.js.map +1 -1
- package/lib/module/v3/hooks/useGesture.js +4 -22
- package/lib/module/v3/hooks/useGesture.js.map +1 -1
- package/lib/module/v3/hooks/utils/configUtils.js +8 -6
- package/lib/module/v3/hooks/utils/configUtils.js.map +1 -1
- package/lib/module/v3/hooks/utils/eventHandlersUtils.js +31 -29
- package/lib/module/v3/hooks/utils/eventHandlersUtils.js.map +1 -1
- package/lib/module/v3/hooks/utils/index.js +1 -1
- package/lib/module/v3/hooks/utils/index.js.map +1 -1
- package/lib/module/v3/hooks/utils/propsWhiteList.js +1 -1
- package/lib/module/v3/hooks/utils/propsWhiteList.js.map +1 -1
- package/lib/module/v3/hooks/utils/reanimatedUtils.js +8 -2
- package/lib/module/v3/hooks/utils/reanimatedUtils.js.map +1 -1
- package/lib/module/web/constants.js +1 -0
- package/lib/module/web/constants.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +18 -5
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +9 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +25 -5
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +1 -4
- package/lib/module/web/handlers/HoverGestureHandler.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 +65 -17
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +1 -0
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +4 -6
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +4 -3
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +6 -0
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +8 -2
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureLifecycleEvents.js +10 -0
- package/lib/module/web/tools/GestureLifecycleEvents.js.map +1 -0
- package/lib/module/web/tools/NodeManager.js +44 -0
- package/lib/module/web/tools/NodeManager.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +9 -0
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts.map +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +14 -6
- package/lib/typescript/components/GestureButtons.d.ts.map +1 -1
- package/lib/typescript/components/GestureHandlerButton.d.ts +62 -8
- package/lib/typescript/components/GestureHandlerButton.d.ts.map +1 -1
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +14 -3
- package/lib/typescript/components/GestureHandlerButton.web.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/PressableProps.d.ts +1 -1
- package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +16 -14
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts.map +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +2 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts +30 -34
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -1
- package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +3 -3
- package/lib/typescript/handlers/gestures/gesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +27 -1
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +6 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts.map +1 -1
- package/lib/typescript/mocks/module.d.ts +1 -1
- package/lib/typescript/mocks/module.d.ts.map +1 -1
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +2 -2
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -1
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +19 -11
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -1
- package/lib/typescript/v3/NativeProxy.d.ts +1 -1
- package/lib/typescript/v3/NativeProxy.d.ts.map +1 -1
- package/lib/typescript/v3/NativeProxy.web.d.ts +1 -1
- package/lib/typescript/v3/NativeProxy.web.d.ts.map +1 -1
- package/lib/typescript/v3/components/GestureButtons.d.ts +1 -37
- package/lib/typescript/v3/components/GestureButtons.d.ts.map +1 -1
- package/lib/typescript/v3/components/GestureButtonsProps.d.ts +1 -1
- package/lib/typescript/v3/components/GestureButtonsProps.d.ts.map +1 -1
- package/lib/typescript/v3/components/GestureComponents.d.ts +3 -0
- package/lib/typescript/v3/components/GestureComponents.d.ts.map +1 -1
- package/lib/typescript/v3/components/GestureComponents.web.d.ts +4 -0
- package/lib/typescript/v3/components/GestureComponents.web.d.ts.map +1 -1
- package/lib/typescript/v3/components/Pressable.d.ts.map +1 -1
- package/lib/typescript/v3/components/Touchable/Touchable.d.ts.map +1 -1
- package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts +48 -1
- package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts.map +1 -1
- package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts +1 -1
- package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts.map +1 -1
- package/lib/typescript/v3/detectors/NativeDetector.d.ts.map +1 -1
- package/lib/typescript/v3/detectors/VirtualDetector/InterceptingGestureDetector.d.ts.map +1 -1
- package/lib/typescript/v3/detectors/VirtualDetector/VirtualDetector.d.ts.map +1 -1
- package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts +3 -0
- package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts.map +1 -0
- package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts +3 -0
- package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts.map +1 -0
- package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts +3 -0
- package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts.map +1 -0
- package/lib/typescript/v3/detectors/utils.d.ts +3 -3
- package/lib/typescript/v3/detectors/utils.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/callbacks/useReanimatedEventHandler.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts +7 -0
- package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts +1 -1
- package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/useGesture.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/utils/configUtils.d.ts +2 -2
- package/lib/typescript/v3/hooks/utils/configUtils.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/utils/eventHandlersUtils.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/utils/index.d.ts +1 -1
- package/lib/typescript/v3/hooks/utils/index.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts +2 -2
- package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts.map +1 -1
- package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts +1 -0
- package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts.map +1 -1
- package/lib/typescript/v3/types/ConfigTypes.d.ts +1 -0
- package/lib/typescript/v3/types/ConfigTypes.d.ts.map +1 -1
- package/lib/typescript/web/constants.d.ts +1 -0
- package/lib/typescript/web/constants.d.ts.map +1 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
- package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts.map +1 -1
- package/lib/typescript/web/handlers/GestureHandler.d.ts +8 -2
- package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +2 -0
- package/lib/typescript/web/handlers/IGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +13 -3
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/interfaces.d.ts +6 -0
- package/lib/typescript/web/interfaces.d.ts.map +1 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
- package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts +7 -0
- package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts.map +1 -0
- package/lib/typescript/web/tools/NodeManager.d.ts +7 -0
- package/lib/typescript/web/tools/NodeManager.d.ts.map +1 -1
- package/lib/typescript/web/tools/PointerEventManager.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/RNGestureHandlerModule.web.ts +5 -1
- package/src/components/GestureButtons.tsx +33 -16
- package/src/components/GestureHandlerButton.tsx +70 -8
- package/src/components/GestureHandlerButton.web.tsx +184 -48
- package/src/components/Pressable/Pressable.tsx +3 -1
- package/src/components/Pressable/PressableProps.tsx +2 -1
- package/src/components/Pressable/stateDefinitions.ts +3 -0
- package/src/components/ReanimatedDrawerLayout.tsx +27 -23
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +51 -5
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +31 -39
- package/src/components/touchables/GenericTouchable.tsx +2 -5
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -2
- package/src/handlers/gestures/GestureDetector/utils.ts +11 -53
- package/src/handlers/gestures/flingGesture.ts +6 -0
- package/src/handlers/gestures/forceTouchGesture.ts +3 -3
- package/src/handlers/gestures/gesture.ts +6 -0
- package/src/handlers/gestures/gestureComposition.ts +21 -0
- package/src/handlers/gestures/gestureObjects.ts +27 -1
- package/src/handlers/gestures/gestureStateManager.ts +6 -0
- package/src/handlers/gestures/hoverGesture.ts +6 -0
- package/src/handlers/gestures/longPressGesture.ts +6 -0
- package/src/handlers/gestures/manualGesture.ts +6 -0
- package/src/handlers/gestures/nativeGesture.ts +6 -0
- package/src/handlers/gestures/panGesture.ts +9 -0
- package/src/handlers/gestures/pinchGesture.ts +9 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +20 -2
- package/src/handlers/gestures/rotationGesture.ts +6 -0
- package/src/handlers/gestures/tapGesture.ts +6 -0
- package/src/mocks/module.tsx +4 -2
- package/src/specs/NativeRNGestureHandlerModule.ts +2 -4
- package/src/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
- package/src/v3/NativeProxy.ts +9 -7
- package/src/v3/NativeProxy.web.ts +2 -2
- package/src/v3/components/GestureButtons.tsx +18 -10
- package/src/v3/components/GestureButtonsProps.ts +1 -0
- package/src/v3/components/Pressable.tsx +2 -1
- package/src/v3/components/Touchable/Touchable.tsx +144 -50
- package/src/v3/components/Touchable/TouchableProps.ts +64 -2
- package/src/v3/detectors/HostGestureDetector.web.tsx +268 -108
- package/src/v3/detectors/NativeDetector.tsx +3 -2
- package/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +3 -4
- package/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +5 -2
- package/src/v3/detectors/useGestureRelationsUpdater.ts +30 -0
- package/src/v3/detectors/useNativeGestureRole.ts +8 -0
- package/src/v3/detectors/useNativeGestureRole.web.ts +42 -0
- package/src/v3/detectors/utils.ts +28 -12
- package/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +23 -7
- package/src/v3/hooks/gestures/fling/useFlingGesture.ts +5 -1
- package/src/v3/hooks/gestures/hover/useHoverGesture.ts +5 -1
- package/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +3 -1
- package/src/v3/hooks/gestures/manual/useManualGesture.ts +5 -1
- package/src/v3/hooks/gestures/native/NativeTypes.ts +13 -1
- package/src/v3/hooks/gestures/native/useNativeGesture.ts +5 -1
- package/src/v3/hooks/gestures/pan/usePanGesture.ts +5 -1
- package/src/v3/hooks/gestures/pinch/usePinchGesture.ts +5 -1
- package/src/v3/hooks/gestures/rotation/useRotationGesture.ts +3 -1
- package/src/v3/hooks/gestures/tap/useTapGesture.ts +5 -1
- package/src/v3/hooks/useGesture.ts +4 -18
- package/src/v3/hooks/utils/configUtils.ts +18 -8
- package/src/v3/hooks/utils/eventHandlersUtils.ts +43 -32
- package/src/v3/hooks/utils/index.ts +0 -1
- package/src/v3/hooks/utils/propsWhiteList.ts +1 -0
- package/src/v3/hooks/utils/reanimatedUtils.ts +10 -10
- package/src/v3/types/ConfigTypes.ts +1 -0
- package/src/web/constants.ts +1 -0
- package/src/web/detectors/RotationGestureDetector.ts +19 -5
- package/src/web/detectors/ScaleGestureDetector.ts +9 -3
- package/src/web/handlers/GestureHandler.ts +36 -6
- package/src/web/handlers/HoverGestureHandler.ts +2 -5
- package/src/web/handlers/IGestureHandler.ts +2 -0
- package/src/web/handlers/ManualGestureHandler.ts +2 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +122 -19
- package/src/web/handlers/PanGestureHandler.ts +2 -0
- package/src/web/handlers/PinchGestureHandler.ts +5 -7
- package/src/web/handlers/RotationGestureHandler.ts +5 -5
- package/src/web/interfaces.ts +7 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +11 -3
- package/src/web/tools/GestureLifecycleEvents.ts +14 -0
- package/src/web/tools/NodeManager.ts +57 -0
- package/src/web/tools/PointerEventManager.ts +12 -0
- package/lib/module/RNRenderer.js +0 -6
- package/lib/module/RNRenderer.js.map +0 -1
- package/lib/module/RNRenderer.web.js +0 -6
- package/lib/module/RNRenderer.web.js.map +0 -1
- package/lib/typescript/RNRenderer.d.ts +0 -2
- package/lib/typescript/RNRenderer.d.ts.map +0 -1
- package/lib/typescript/RNRenderer.web.d.ts +0 -4
- package/lib/typescript/RNRenderer.web.d.ts.map +0 -1
- package/src/RNRenderer.ts +0 -3
- package/src/RNRenderer.web.ts +0 -3
|
@@ -17,13 +17,69 @@ type PressableAndroidRippleConfig = {
|
|
|
17
17
|
|
|
18
18
|
type RippleProps = 'rippleColor' | 'rippleRadius' | 'borderless' | 'foreground';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
type DurationProps =
|
|
21
|
+
| 'tapAnimationInDuration'
|
|
22
|
+
| 'tapAnimationOutDuration'
|
|
23
|
+
| 'longPressDuration'
|
|
24
|
+
| 'longPressAnimationOutDuration'
|
|
25
|
+
| 'hoverAnimationInDuration'
|
|
26
|
+
| 'hoverAnimationOutDuration';
|
|
27
|
+
|
|
28
|
+
type InOutDuration = { in: number; out: number };
|
|
29
|
+
type LongPressDuration = { out: number };
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for press / hover animation timing.
|
|
33
|
+
*
|
|
34
|
+
* - A single number applies to every phase of every category.
|
|
35
|
+
* - An object with top-level `in` / `out` sets the baseline; `tap` and
|
|
36
|
+
* `hover` may override either side or both — any field left out
|
|
37
|
+
* inherits the top-level value.
|
|
38
|
+
* - Alternatively, both categories may be specified in full without a
|
|
39
|
+
* top-level baseline.
|
|
40
|
+
*
|
|
41
|
+
* `longPress` optionally customizes the press-out duration once the
|
|
42
|
+
* press has been held past `delayLongPress`. If omitted, the long-press
|
|
43
|
+
* release falls back to the resolved tap-out timing.
|
|
44
|
+
*/
|
|
45
|
+
export type AnimationDuration =
|
|
46
|
+
| number
|
|
47
|
+
| (InOutDuration & {
|
|
48
|
+
tap?: Partial<InOutDuration>;
|
|
49
|
+
hover?: Partial<InOutDuration>;
|
|
50
|
+
longPress?: LongPressDuration;
|
|
51
|
+
})
|
|
52
|
+
| {
|
|
53
|
+
tap: InOutDuration;
|
|
54
|
+
hover: InOutDuration;
|
|
55
|
+
longPress?: LongPressDuration;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type TouchableProps = Omit<
|
|
59
|
+
ButtonProps,
|
|
60
|
+
RippleProps | 'enabled' | DurationProps
|
|
61
|
+
> &
|
|
62
|
+
Omit<
|
|
63
|
+
BaseButtonProps,
|
|
64
|
+
keyof RawButtonProps | 'onActiveStateChange' | 'onPress'
|
|
65
|
+
> & {
|
|
66
|
+
/**
|
|
67
|
+
* Press and hover animation durations, in milliseconds. Pass a single
|
|
68
|
+
* number to apply it to every phase, or an object to customize per phase
|
|
69
|
+
* and per category. Defaults to 50ms for the in phase and 100ms for the
|
|
70
|
+
* out phase.
|
|
71
|
+
*/
|
|
72
|
+
animationDuration?: AnimationDuration | undefined;
|
|
22
73
|
/**
|
|
23
74
|
* Configuration for the ripple effect on Android.
|
|
24
75
|
*/
|
|
25
76
|
androidRipple?: PressableAndroidRippleConfig | undefined;
|
|
26
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Called when the component gets pressed.
|
|
80
|
+
*/
|
|
81
|
+
onPress?: ((event: CallbackEventType) => void) | undefined;
|
|
82
|
+
|
|
27
83
|
/**
|
|
28
84
|
* Called when pointer touches the component.
|
|
29
85
|
*/
|
|
@@ -38,4 +94,10 @@ export type TouchableProps = Omit<ButtonProps, RippleProps | 'enabled'> &
|
|
|
38
94
|
* Whether the component should ignore touches. By default set to false.
|
|
39
95
|
*/
|
|
40
96
|
disabled?: boolean | undefined;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Whether the touch should be canceled when pointer leaves the component. By default set to true.
|
|
100
|
+
* On web this prop doesn't have any effect and behaves as if `true` was set.
|
|
101
|
+
*/
|
|
102
|
+
cancelOnLeave?: boolean | undefined;
|
|
41
103
|
};
|
|
@@ -9,7 +9,9 @@ import type {
|
|
|
9
9
|
} from '../../handlers/gestureHandlerCommon';
|
|
10
10
|
import RNGestureHandlerModule from '../../RNGestureHandlerModule.web';
|
|
11
11
|
import { tagMessage } from '../../utils';
|
|
12
|
-
import type
|
|
12
|
+
import { type PropsRef } from '../../web/interfaces';
|
|
13
|
+
import NodeManager from '../../web/tools/NodeManager';
|
|
14
|
+
import { useNativeGestureRole } from './useNativeGestureRole';
|
|
13
15
|
|
|
14
16
|
export interface GestureHandlerDetectorProps extends PropsRef {
|
|
15
17
|
handlerTags: number[];
|
|
@@ -30,7 +32,193 @@ export interface VirtualChildrenWeb {
|
|
|
30
32
|
enableContextMenu?: boolean | undefined;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
// Bundles all per-instance state passed to the standalone helpers below. Holding everything in
|
|
36
|
+
// one stable object keeps the helpers pure (no closures over component-render-scoped values),
|
|
37
|
+
// which means the useEffects don't need them in their deps lists.
|
|
38
|
+
type DetectorRefs = {
|
|
39
|
+
owner: object;
|
|
40
|
+
viewRef: RefObject<Element | null>;
|
|
41
|
+
propsRef: RefObject<GestureHandlerDetectorProps>;
|
|
42
|
+
// Tags observed for the detector view (top-level).
|
|
43
|
+
subscribedHandlers: Set<number>;
|
|
44
|
+
// Flat set of tags currently bound to *some* element (top-level or virtual). Mirrors iOS
|
|
45
|
+
// `_attachedHandlers` / Android `attachedHandlers`.
|
|
46
|
+
attachedHandlers: Set<number>;
|
|
47
|
+
// Tags whose handler asked to attach to the detector's child element rather than the detector
|
|
48
|
+
// itself (`shouldAttachGestureToChildView`). Kept here so we can (re)bind them as subviews
|
|
49
|
+
// appear.
|
|
50
|
+
nativeHandlers: Set<number>;
|
|
51
|
+
// For each virtual child's viewTag, the set of currently-observed handler tags.
|
|
52
|
+
subscribedVirtualHandlers: Map<number, Set<number>>;
|
|
53
|
+
// Latest snapshot of virtual children keyed by viewTag. The ready callback reads this so
|
|
54
|
+
// re-fires after a child's per-DOM props change use the up-to-date values.
|
|
55
|
+
virtualChildren: Map<number, VirtualChildrenWeb>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Invoked from `NodeManager.observeHandler` once the handler is known to exist. Branches on
|
|
59
|
+
// handler kind + actionType to pick the right binding flow. May be called multiple times for
|
|
60
|
+
// the same tag (handler re-registration), so each branch must be idempotent.
|
|
61
|
+
function attachReadyHandler(
|
|
62
|
+
refs: DetectorRefs,
|
|
63
|
+
tag: number,
|
|
64
|
+
actionType: ActionType,
|
|
65
|
+
virtualViewTag?: number
|
|
66
|
+
) {
|
|
67
|
+
const handler = RNGestureHandlerModule.getGestureHandlerNode(tag);
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
actionType === ActionType.NATIVE_DETECTOR &&
|
|
71
|
+
handler.shouldAttachGestureToChildView()
|
|
72
|
+
) {
|
|
73
|
+
refs.nativeHandlers.add(tag);
|
|
74
|
+
if (
|
|
75
|
+
refs.viewRef.current != null &&
|
|
76
|
+
refs.viewRef.current.childElementCount > 0
|
|
77
|
+
) {
|
|
78
|
+
tryAttachNativeHandlersToChildView(refs);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (actionType === ActionType.VIRTUAL_DETECTOR) {
|
|
84
|
+
const child =
|
|
85
|
+
virtualViewTag != null
|
|
86
|
+
? refs.virtualChildren.get(virtualViewTag)
|
|
87
|
+
: undefined;
|
|
88
|
+
if (child == null || child.viewRef.current == null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!refs.attachedHandlers.has(tag)) {
|
|
93
|
+
RNGestureHandlerModule.attachGestureHandler(
|
|
94
|
+
tag,
|
|
95
|
+
child.viewRef.current,
|
|
96
|
+
actionType,
|
|
97
|
+
refs.propsRef
|
|
98
|
+
);
|
|
99
|
+
refs.attachedHandlers.add(tag);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
RNGestureHandlerModule.updateGestureHandlerConfig(tag, {
|
|
103
|
+
userSelect: child.userSelect,
|
|
104
|
+
touchAction: child.touchAction,
|
|
105
|
+
enableContextMenu: child.enableContextMenu,
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (refs.viewRef.current == null) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!refs.attachedHandlers.has(tag)) {
|
|
115
|
+
RNGestureHandlerModule.attachGestureHandler(
|
|
116
|
+
tag,
|
|
117
|
+
refs.viewRef.current,
|
|
118
|
+
actionType,
|
|
119
|
+
refs.propsRef
|
|
120
|
+
);
|
|
121
|
+
refs.attachedHandlers.add(tag);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
RNGestureHandlerModule.updateGestureHandlerConfig(tag, {
|
|
125
|
+
userSelect: refs.propsRef.current.userSelect,
|
|
126
|
+
touchAction: refs.propsRef.current.touchAction,
|
|
127
|
+
enableContextMenu: refs.propsRef.current.enableContextMenu,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function tryAttachNativeHandlersToChildView(refs: DetectorRefs) {
|
|
132
|
+
if (refs.nativeHandlers.size === 0) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const view = refs.viewRef.current;
|
|
137
|
+
if (view == null) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (view.childElementCount > 1) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
tagMessage(
|
|
144
|
+
'Cannot have more than one child view when native gesture handlers are attached to the detector'
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const target = view.firstElementChild;
|
|
150
|
+
if (target == null) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
for (const tag of refs.nativeHandlers) {
|
|
155
|
+
// A tag may be in `nativeHandlers` from an earlier ready callback but the underlying
|
|
156
|
+
// handler may have been dropped since. Skip — a re-registration fires the observation again.
|
|
157
|
+
if (!NodeManager.hasHandler(tag)) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (refs.attachedHandlers.has(tag)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
RNGestureHandlerModule.attachGestureHandler(
|
|
164
|
+
tag,
|
|
165
|
+
target,
|
|
166
|
+
ActionType.NATIVE_DETECTOR,
|
|
167
|
+
refs.propsRef
|
|
168
|
+
);
|
|
169
|
+
refs.attachedHandlers.add(tag);
|
|
170
|
+
RNGestureHandlerModule.updateGestureHandlerConfig(tag, {
|
|
171
|
+
userSelect: refs.propsRef.current.userSelect,
|
|
172
|
+
touchAction: refs.propsRef.current.touchAction,
|
|
173
|
+
enableContextMenu: refs.propsRef.current.enableContextMenu,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Reconcile `subscribedSet` against `currentTags`: observe new tags, cancel observation and
|
|
179
|
+
// detach for tags no longer present. The ready callback set up here is responsible for actually
|
|
180
|
+
// binding the handler once it exists.
|
|
181
|
+
function syncSubscriptions(
|
|
182
|
+
refs: DetectorRefs,
|
|
183
|
+
currentTags: Iterable<number>,
|
|
184
|
+
subscribedSet: Set<number>,
|
|
185
|
+
actionType: ActionType,
|
|
186
|
+
virtualViewTag?: number
|
|
187
|
+
) {
|
|
188
|
+
const toUnsubscribe = new Set(subscribedSet);
|
|
189
|
+
for (const tag of currentTags) {
|
|
190
|
+
toUnsubscribe.delete(tag);
|
|
191
|
+
if (subscribedSet.has(tag)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
NodeManager.observeHandler(tag, refs.owner, () => {
|
|
195
|
+
attachReadyHandler(refs, tag, actionType, virtualViewTag);
|
|
196
|
+
});
|
|
197
|
+
subscribedSet.add(tag);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (const tag of toUnsubscribe) {
|
|
201
|
+
NodeManager.cancelObservation(tag, refs.owner);
|
|
202
|
+
if (refs.attachedHandlers.has(tag)) {
|
|
203
|
+
RNGestureHandlerModule.detachGestureHandler(tag);
|
|
204
|
+
refs.attachedHandlers.delete(tag);
|
|
205
|
+
}
|
|
206
|
+
subscribedSet.delete(tag);
|
|
207
|
+
refs.nativeHandlers.delete(tag);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function teardown(refs: DetectorRefs) {
|
|
212
|
+
NodeManager.cancelAllObservationsForOwner(refs.owner);
|
|
213
|
+
for (const tag of refs.attachedHandlers) {
|
|
214
|
+
RNGestureHandlerModule.detachGestureHandler(tag);
|
|
215
|
+
}
|
|
216
|
+
refs.attachedHandlers.clear();
|
|
217
|
+
refs.subscribedHandlers.clear();
|
|
218
|
+
refs.nativeHandlers.clear();
|
|
219
|
+
refs.subscribedVirtualHandlers.clear();
|
|
220
|
+
refs.virtualChildren.clear();
|
|
221
|
+
}
|
|
34
222
|
|
|
35
223
|
const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
|
|
36
224
|
const { handlerTags, children } = props;
|
|
@@ -39,70 +227,28 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
|
|
|
39
227
|
|
|
40
228
|
const viewRef = useRef<Element>(null);
|
|
41
229
|
const propsRef = useRef<GestureHandlerDetectorProps>(props);
|
|
42
|
-
const attachedHandlers = useRef<Set<number>>(new Set<number>());
|
|
43
|
-
const attachedNativeHandlers = useRef<Set<number>>(new Set<number>());
|
|
44
|
-
const attachedVirtualHandlers = useRef<Map<number, Set<number>>>(new Map());
|
|
45
|
-
|
|
46
|
-
const detachHandlers = (
|
|
47
|
-
currentHandlerTags: Set<number>,
|
|
48
|
-
attachedHandlerTags: Set<number>
|
|
49
|
-
) => {
|
|
50
|
-
const oldHandlerTags = attachedHandlerTags.difference(currentHandlerTags);
|
|
51
|
-
oldHandlerTags.forEach((tag) => {
|
|
52
|
-
RNGestureHandlerModule.detachGestureHandler(tag);
|
|
53
|
-
attachedHandlerTags.delete(tag);
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const attachHandlers = (
|
|
58
|
-
viewRef: RefObject<Element | null>,
|
|
59
|
-
propsRef: RefObject<GestureHandlerDetectorProps>,
|
|
60
|
-
currentHandlerTags: Set<number>,
|
|
61
|
-
attachedHandlerTags: Set<number>,
|
|
62
|
-
actionType: ActionType
|
|
63
|
-
) => {
|
|
64
|
-
const newHandlerTags = currentHandlerTags.difference(attachedHandlerTags);
|
|
65
|
-
|
|
66
|
-
newHandlerTags.forEach((tag) => {
|
|
67
|
-
if (
|
|
68
|
-
RNGestureHandlerModule.getGestureHandlerNode(
|
|
69
|
-
tag
|
|
70
|
-
).shouldAttachGestureToChildView() &&
|
|
71
|
-
actionType === ActionType.NATIVE_DETECTOR
|
|
72
|
-
) {
|
|
73
|
-
if (viewRef.current!.childElementCount > 1) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
tagMessage(
|
|
76
|
-
'Cannot have more than one child view when native gesture handlers are attached to the detector'
|
|
77
|
-
)
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
230
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
attachedHandlerTags.add(tag);
|
|
231
|
+
// Stable per-instance state
|
|
232
|
+
const refsRef = useRef<DetectorRefs | null>(null);
|
|
233
|
+
if (refsRef.current === null) {
|
|
234
|
+
refsRef.current = {
|
|
235
|
+
owner: {},
|
|
236
|
+
viewRef,
|
|
237
|
+
propsRef,
|
|
238
|
+
subscribedHandlers: new Set<number>(),
|
|
239
|
+
attachedHandlers: new Set<number>(),
|
|
240
|
+
nativeHandlers: new Set<number>(),
|
|
241
|
+
subscribedVirtualHandlers: new Map<number, Set<number>>(),
|
|
242
|
+
virtualChildren: new Map<number, VirtualChildrenWeb>(),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const refs = refsRef.current;
|
|
97
246
|
|
|
98
|
-
|
|
99
|
-
userSelect: props.userSelect,
|
|
100
|
-
touchAction: props.touchAction,
|
|
101
|
-
enableContextMenu: props.enableContextMenu,
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
247
|
+
useNativeGestureRole(viewRef, children);
|
|
105
248
|
|
|
249
|
+
// Keep propsRef in sync and re-apply detector-level DOM props to top-level attached handlers
|
|
250
|
+
// when they change. Virtual children get their own (potentially different) DOM props applied
|
|
251
|
+
// in the virtualChildren effect below, so we only touch top-level subscribers here.
|
|
106
252
|
useEffect(() => {
|
|
107
253
|
const shouldUpdateDOMProps =
|
|
108
254
|
propsRef.current.userSelect !== props.userSelect ||
|
|
@@ -112,7 +258,17 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
|
|
|
112
258
|
propsRef.current = props;
|
|
113
259
|
|
|
114
260
|
if (shouldUpdateDOMProps) {
|
|
115
|
-
|
|
261
|
+
// attachedHandlers ⊆ subscribedHandlers ⋃ subscribedVirtualHandlers, we want to ignore the
|
|
262
|
+
// handlers attached by the virtual detectors not to overwrite their DOM props.
|
|
263
|
+
const claimedByVirtual = Array.from(
|
|
264
|
+
refs.subscribedVirtualHandlers.values()
|
|
265
|
+
).reduce((acc, current) => acc.union(current), new Set<number>());
|
|
266
|
+
|
|
267
|
+
const handlersToUpdate = refs.subscribedHandlers
|
|
268
|
+
.intersection(refs.attachedHandlers)
|
|
269
|
+
.difference(claimedByVirtual);
|
|
270
|
+
|
|
271
|
+
for (const tag of handlersToUpdate) {
|
|
116
272
|
RNGestureHandlerModule.updateGestureHandlerConfig(tag, {
|
|
117
273
|
userSelect: props.userSelect,
|
|
118
274
|
touchAction: props.touchAction,
|
|
@@ -120,38 +276,38 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
|
|
|
120
276
|
});
|
|
121
277
|
}
|
|
122
278
|
}
|
|
123
|
-
}, [props]);
|
|
279
|
+
}, [props, refs]);
|
|
124
280
|
|
|
125
281
|
useEffect(() => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
attachHandlers(
|
|
129
|
-
viewRef,
|
|
130
|
-
propsRef,
|
|
282
|
+
syncSubscriptions(
|
|
283
|
+
refs,
|
|
131
284
|
handlerTagsSet,
|
|
132
|
-
|
|
285
|
+
refs.subscribedHandlers,
|
|
133
286
|
ActionType.NATIVE_DETECTOR
|
|
134
287
|
);
|
|
135
|
-
|
|
136
|
-
detachHandlers(EMPTY_HANDLERS, attachedHandlers.current);
|
|
137
|
-
attachedVirtualHandlers?.current.forEach((childHandlerTags) => {
|
|
138
|
-
detachHandlers(EMPTY_HANDLERS, childHandlerTags);
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
}, [handlerTagsSet, viewRef]);
|
|
288
|
+
}, [handlerTagsSet, refs]);
|
|
142
289
|
|
|
143
290
|
useEffect(() => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
291
|
+
// Refresh the snapshot used by the ready callback so re-fires read current child props.
|
|
292
|
+
refs.virtualChildren.clear();
|
|
293
|
+
props.virtualChildren?.forEach((child) => {
|
|
294
|
+
refs.virtualChildren.set(child.viewTag, child);
|
|
295
|
+
});
|
|
147
296
|
|
|
297
|
+
const virtualChildrenToDetach = new Set(
|
|
298
|
+
refs.subscribedVirtualHandlers.keys()
|
|
299
|
+
);
|
|
148
300
|
props.virtualChildren?.forEach((child) => {
|
|
149
301
|
virtualChildrenToDetach.delete(child.viewTag);
|
|
150
302
|
});
|
|
151
303
|
|
|
152
|
-
virtualChildrenToDetach
|
|
153
|
-
|
|
154
|
-
|
|
304
|
+
for (const viewTag of virtualChildrenToDetach) {
|
|
305
|
+
const tags = refs.subscribedVirtualHandlers.get(viewTag);
|
|
306
|
+
if (tags != null) {
|
|
307
|
+
syncSubscriptions(refs, [], tags, ActionType.VIRTUAL_DETECTOR, viewTag);
|
|
308
|
+
}
|
|
309
|
+
refs.subscribedVirtualHandlers.delete(viewTag);
|
|
310
|
+
}
|
|
155
311
|
|
|
156
312
|
props.virtualChildren?.forEach((child) => {
|
|
157
313
|
if (child.viewRef.current == null) {
|
|
@@ -159,33 +315,37 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
|
|
|
159
315
|
// switches its component based on whether animated/reanimated events should run.
|
|
160
316
|
return;
|
|
161
317
|
}
|
|
162
|
-
if (!attachedVirtualHandlers.current.has(child.viewTag)) {
|
|
163
|
-
attachedVirtualHandlers.current.set(child.viewTag, new Set());
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const currentHandlerTags = new Set(child.handlerTags);
|
|
167
|
-
detachHandlers(
|
|
168
|
-
currentHandlerTags,
|
|
169
|
-
attachedVirtualHandlers.current.get(child.viewTag)!
|
|
170
|
-
);
|
|
171
318
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
319
|
+
let subs = refs.subscribedVirtualHandlers.get(child.viewTag);
|
|
320
|
+
if (subs == null) {
|
|
321
|
+
subs = new Set();
|
|
322
|
+
refs.subscribedVirtualHandlers.set(child.viewTag, subs);
|
|
323
|
+
}
|
|
324
|
+
syncSubscriptions(
|
|
325
|
+
refs,
|
|
326
|
+
child.handlerTags,
|
|
327
|
+
subs,
|
|
328
|
+
ActionType.VIRTUAL_DETECTOR,
|
|
329
|
+
child.viewTag
|
|
178
330
|
);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
331
|
+
// Re-apply per-child DOM props on every run. Already-attached tags need this when only
|
|
332
|
+
// the child's props change; tags attached via a sync-fired observer already had it
|
|
333
|
+
// applied in `attachReadyHandler`, so this is a no-op for them.
|
|
334
|
+
for (const tag of subs) {
|
|
335
|
+
if (refs.attachedHandlers.has(tag)) {
|
|
336
|
+
RNGestureHandlerModule.updateGestureHandlerConfig(tag, {
|
|
337
|
+
userSelect: child.userSelect,
|
|
338
|
+
touchAction: child.touchAction,
|
|
339
|
+
enableContextMenu: child.enableContextMenu,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
187
343
|
});
|
|
188
|
-
}, [props.virtualChildren]);
|
|
344
|
+
}, [props.virtualChildren, refs]);
|
|
345
|
+
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
return () => teardown(refs);
|
|
348
|
+
}, [refs]);
|
|
189
349
|
|
|
190
350
|
return (
|
|
191
351
|
<View style={{ display: 'contents' }} ref={viewRef as Ref<View>}>
|
|
@@ -6,7 +6,8 @@ import type { NativeDetectorProps } from './common';
|
|
|
6
6
|
import { AnimatedNativeDetector, nativeDetectorStyles } from './common';
|
|
7
7
|
import HostGestureDetector from './HostGestureDetector';
|
|
8
8
|
import { ReanimatedNativeDetector } from './ReanimatedNativeDetector';
|
|
9
|
-
import {
|
|
9
|
+
import { useGestureRelationsUpdater } from './useGestureRelationsUpdater';
|
|
10
|
+
import { ensureNativeDetectorComponent } from './utils';
|
|
10
11
|
|
|
11
12
|
export function NativeDetector<
|
|
12
13
|
TConfig,
|
|
@@ -26,7 +27,7 @@ export function NativeDetector<
|
|
|
26
27
|
: HostGestureDetector;
|
|
27
28
|
|
|
28
29
|
ensureNativeDetectorComponent(NativeDetectorComponent);
|
|
29
|
-
|
|
30
|
+
useGestureRelationsUpdater(gesture);
|
|
30
31
|
|
|
31
32
|
const handlerTags = useMemo(() => {
|
|
32
33
|
return isComposedGesture(gesture)
|
|
@@ -18,7 +18,8 @@ import { AnimatedNativeDetector, nativeDetectorStyles } from '../common';
|
|
|
18
18
|
import HostGestureDetector from '../HostGestureDetector';
|
|
19
19
|
import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector';
|
|
20
20
|
import { useEnsureGestureHandlerRootView } from '../useEnsureGestureHandlerRootView';
|
|
21
|
-
import {
|
|
21
|
+
import { useGestureRelationsUpdater } from '../useGestureRelationsUpdater';
|
|
22
|
+
import { ensureNativeDetectorComponent } from '../utils';
|
|
22
23
|
import type { InterceptingDetectorContextValue } from './useInterceptingDetectorContext';
|
|
23
24
|
import {
|
|
24
25
|
InterceptingDetectorContext,
|
|
@@ -221,9 +222,7 @@ export function InterceptingGestureDetector<
|
|
|
221
222
|
|
|
222
223
|
ensureNativeDetectorComponent(NativeDetectorComponent);
|
|
223
224
|
|
|
224
|
-
|
|
225
|
-
configureRelations(gesture);
|
|
226
|
-
}
|
|
225
|
+
useGestureRelationsUpdater(gesture);
|
|
227
226
|
|
|
228
227
|
const handlerTags = useMemo(() => {
|
|
229
228
|
if (gesture) {
|
|
@@ -6,7 +6,8 @@ import { tagMessage } from '../../../utils';
|
|
|
6
6
|
import { isComposedGesture } from '../../hooks/utils/relationUtils';
|
|
7
7
|
import type { DetectorCallbacks, VirtualChild } from '../../types';
|
|
8
8
|
import type { VirtualDetectorProps } from '../common';
|
|
9
|
-
import {
|
|
9
|
+
import { useGestureRelationsUpdater } from '../useGestureRelationsUpdater';
|
|
10
|
+
import { useNativeGestureRole } from '../useNativeGestureRole';
|
|
10
11
|
import {
|
|
11
12
|
InterceptingDetectorMode,
|
|
12
13
|
useInterceptingDetectorContext,
|
|
@@ -54,6 +55,8 @@ export function VirtualDetector<
|
|
|
54
55
|
[props.children]
|
|
55
56
|
);
|
|
56
57
|
|
|
58
|
+
useNativeGestureRole(viewRef, props.children);
|
|
59
|
+
|
|
57
60
|
useEffect(() => {
|
|
58
61
|
if (viewTag === -1) {
|
|
59
62
|
return;
|
|
@@ -101,7 +104,7 @@ export function VirtualDetector<
|
|
|
101
104
|
setMode,
|
|
102
105
|
]);
|
|
103
106
|
|
|
104
|
-
|
|
107
|
+
useGestureRelationsUpdater(props.gesture);
|
|
105
108
|
|
|
106
109
|
return <Wrap ref={handleRef}>{props.children}</Wrap>;
|
|
107
110
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { NativeProxy } from '../NativeProxy';
|
|
4
|
+
import type { Gesture } from '../types';
|
|
5
|
+
import { configureRelations } from './utils';
|
|
6
|
+
|
|
7
|
+
export function useGestureRelationsUpdater<TConfig, THandlerData>(
|
|
8
|
+
gesture?: Gesture<TConfig, THandlerData>
|
|
9
|
+
) {
|
|
10
|
+
const relations = useMemo(
|
|
11
|
+
() => (gesture ? configureRelations(gesture) : null),
|
|
12
|
+
[gesture]
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!relations) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// React runs effects bottom-up, we need to ensure that relations are applied after all effects
|
|
21
|
+
// in the tree have run, so we defer to the next frame.
|
|
22
|
+
const frame = requestAnimationFrame(() => {
|
|
23
|
+
relations.forEach((rel, handlerTag) => {
|
|
24
|
+
NativeProxy.configureRelations(handlerTag, rel);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return () => cancelAnimationFrame(frame);
|
|
29
|
+
}, [relations]);
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
import { NATIVE_GESTURE_ROLE_ATTRIBUTE } from '../../web/constants';
|
|
5
|
+
import { NativeGestureRole } from '../../web/interfaces';
|
|
6
|
+
|
|
7
|
+
export function useNativeGestureRole(
|
|
8
|
+
viewRef: RefObject<Element | null>,
|
|
9
|
+
children: ReactNode
|
|
10
|
+
): void {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const child = viewRef.current?.firstChild;
|
|
13
|
+
|
|
14
|
+
if (!(child instanceof HTMLElement)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// @ts-ignore This exists on React.ReactNode
|
|
19
|
+
const displayName = children?.type?.displayName as string;
|
|
20
|
+
|
|
21
|
+
if (displayName === NativeGestureRole.ScrollView) {
|
|
22
|
+
child.setAttribute(
|
|
23
|
+
NATIVE_GESTURE_ROLE_ATTRIBUTE,
|
|
24
|
+
NativeGestureRole.ScrollView
|
|
25
|
+
);
|
|
26
|
+
} else if (displayName === NativeGestureRole.Switch) {
|
|
27
|
+
child.setAttribute(
|
|
28
|
+
NATIVE_GESTURE_ROLE_ATTRIBUTE,
|
|
29
|
+
NativeGestureRole.Switch
|
|
30
|
+
);
|
|
31
|
+
} else if (displayName === NativeGestureRole.Button) {
|
|
32
|
+
child.setAttribute(
|
|
33
|
+
NATIVE_GESTURE_ROLE_ATTRIBUTE,
|
|
34
|
+
NativeGestureRole.Button
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
child.removeAttribute(NATIVE_GESTURE_ROLE_ATTRIBUTE);
|
|
40
|
+
};
|
|
41
|
+
}, [children, viewRef]);
|
|
42
|
+
}
|