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
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
CHANGED
|
@@ -16,61 +16,33 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerRootView
|
|
|
16
16
|
class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
17
17
|
private val reactContext: ThemedReactContext
|
|
18
18
|
get() = context as ThemedReactContext
|
|
19
|
-
private var handlersToAttach: List<Int
|
|
20
|
-
private var virtualChildrenToAttach: List<VirtualChildren
|
|
19
|
+
private var handlersToAttach: List<Int> = emptyList()
|
|
20
|
+
private var virtualChildrenToAttach: List<VirtualChildren> = emptyList()
|
|
21
21
|
private var nativeHandlers: MutableSet<Int> = mutableSetOf()
|
|
22
|
+
private var subscribedHandlers: MutableSet<Int> = mutableSetOf()
|
|
22
23
|
private var attachedHandlers: MutableSet<Int> = mutableSetOf()
|
|
23
|
-
private var
|
|
24
|
+
private var subscribedVirtualHandlers: MutableMap<Int, MutableSet<Int>> = mutableMapOf()
|
|
24
25
|
private var moduleId: Int = -1
|
|
25
26
|
|
|
26
27
|
data class VirtualChildren(val handlerTags: List<Int>, val viewTag: Int)
|
|
27
28
|
|
|
28
29
|
fun setHandlerTags(handlerTags: ReadableArray?) {
|
|
29
|
-
|
|
30
|
-
if (moduleId
|
|
31
|
-
|
|
32
|
-
// the handler ids and attach them after setting module id.
|
|
33
|
-
handlersToAttach = newHandlers
|
|
34
|
-
return
|
|
30
|
+
handlersToAttach = handlerTags?.toArrayList()?.map { (it as Double).toInt() } ?: emptyList()
|
|
31
|
+
if (moduleId != -1) {
|
|
32
|
+
attachHandlers(handlersToAttach)
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
attachHandlers(newHandlers)
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
override fun onAttachedToWindow() {
|
|
41
37
|
super.onAttachedToWindow()
|
|
42
|
-
|
|
43
38
|
if (moduleId != -1) {
|
|
44
|
-
handlersToAttach
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
virtualChildrenToAttach?.let {
|
|
49
|
-
attachVirtualChildren(it)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
handlersToAttach = null
|
|
53
|
-
virtualChildrenToAttach = null
|
|
39
|
+
attachHandlers(handlersToAttach)
|
|
40
|
+
attachVirtualChildren(virtualChildrenToAttach)
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
43
|
|
|
57
44
|
override fun onDetachedFromWindow() {
|
|
58
|
-
if (attachedHandlers.isNotEmpty()) {
|
|
59
|
-
handlersToAttach = attachedHandlers.toMutableList().also {
|
|
60
|
-
it.addAll(handlersToAttach ?: emptyList())
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (attachedVirtualHandlers.isNotEmpty()) {
|
|
65
|
-
virtualChildrenToAttach = attachedVirtualHandlers.map {
|
|
66
|
-
VirtualChildren(it.value.toList(), it.key)
|
|
67
|
-
}.toMutableList().also {
|
|
68
|
-
it.addAll(virtualChildrenToAttach ?: emptyList())
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
45
|
detachAllHandlers()
|
|
73
|
-
|
|
74
46
|
super.onDetachedFromWindow()
|
|
75
47
|
}
|
|
76
48
|
|
|
@@ -78,30 +50,15 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
78
50
|
assert(this.moduleId == -1) { "Tried to change moduleId of a native detector" }
|
|
79
51
|
|
|
80
52
|
this.moduleId = id
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.attachVirtualChildren(virtualChildrenToAttach ?: return)
|
|
84
|
-
virtualChildrenToAttach = null
|
|
53
|
+
attachHandlers(handlersToAttach)
|
|
54
|
+
attachVirtualChildren(virtualChildrenToAttach)
|
|
85
55
|
}
|
|
86
56
|
|
|
87
57
|
fun setVirtualChildren(newVirtualChildren: ReadableArray?) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// It's possible that handlerTags will be set before module id. In that case, store
|
|
92
|
-
// the handler ids and attach them after setting module id.
|
|
93
|
-
virtualChildrenToAttach = mappedChildren
|
|
94
|
-
return
|
|
58
|
+
virtualChildrenToAttach = newVirtualChildren?.mapVirtualChildren().orEmpty()
|
|
59
|
+
if (moduleId != -1) {
|
|
60
|
+
attachVirtualChildren(virtualChildrenToAttach)
|
|
95
61
|
}
|
|
96
|
-
|
|
97
|
-
attachVirtualChildren(mappedChildren)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private fun shouldAttachGestureToChildView(tag: Int): Boolean {
|
|
101
|
-
val registry = RNGestureHandlerModule.registries[moduleId]
|
|
102
|
-
?: throw Exception("Tried to access a non-existent registry")
|
|
103
|
-
|
|
104
|
-
return registry.getHandler(tag)?.wantsToAttachDirectlyToView() ?: false
|
|
105
62
|
}
|
|
106
63
|
|
|
107
64
|
// We override this `addView` because it is called inside `addView(child: View?, index: Int)`
|
|
@@ -127,49 +84,61 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
127
84
|
newHandlers: List<Int>,
|
|
128
85
|
viewTag: Int = this.id,
|
|
129
86
|
actionType: Int = GestureHandler.ACTION_TYPE_NATIVE_DETECTOR,
|
|
130
|
-
|
|
87
|
+
subscribedHandlers: MutableSet<Int> = this.subscribedHandlers,
|
|
131
88
|
) {
|
|
132
89
|
val registry = RNGestureHandlerModule.registries[moduleId]
|
|
133
90
|
?: throw Exception("Tried to access a non-existent registry")
|
|
134
91
|
|
|
135
|
-
val handlersToDetach =
|
|
92
|
+
val handlersToDetach = subscribedHandlers.toMutableSet()
|
|
136
93
|
|
|
137
94
|
for (tag in newHandlers) {
|
|
138
95
|
handlersToDetach.remove(tag)
|
|
139
|
-
if (!
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// attach `NativeViewGestureHandlers` here and we have to do it in `addView` method.
|
|
143
|
-
assert(childCount <= 1) {
|
|
144
|
-
"Cannot attach native gesture handlers when the detector has multiple children"
|
|
145
|
-
}
|
|
146
|
-
nativeHandlers.add(tag)
|
|
147
|
-
} else {
|
|
148
|
-
registry.attachHandlerToView(tag, viewTag, actionType, this)
|
|
149
|
-
if (actionType == GestureHandler.ACTION_TYPE_VIRTUAL_DETECTOR) {
|
|
150
|
-
registry.getHandler(tag)?.hostDetectorView = this
|
|
151
|
-
}
|
|
152
|
-
attachedHandlers.add(tag)
|
|
96
|
+
if (!subscribedHandlers.contains(tag)) {
|
|
97
|
+
registry.observeHandler(tag, this) { handler ->
|
|
98
|
+
attachReadyHandler(handler, actionType, viewTag)
|
|
153
99
|
}
|
|
100
|
+
subscribedHandlers.add(tag)
|
|
154
101
|
}
|
|
155
102
|
}
|
|
156
103
|
|
|
157
104
|
for (tag in handlersToDetach) {
|
|
158
|
-
registry.
|
|
105
|
+
registry.cancelObservation(tag, this)
|
|
106
|
+
if (attachedHandlers.contains(tag)) {
|
|
107
|
+
registry.detachHandlerFromHostDetector(tag, this)
|
|
108
|
+
attachedHandlers.remove(tag)
|
|
109
|
+
}
|
|
110
|
+
subscribedHandlers.remove(tag)
|
|
159
111
|
nativeHandlers.remove(tag)
|
|
160
|
-
attachedHandlers.remove(tag)
|
|
161
112
|
}
|
|
113
|
+
}
|
|
162
114
|
|
|
163
|
-
|
|
115
|
+
// Invoked from the registry's `observeHandler` callback once the handler is known to exist.
|
|
116
|
+
// Branches on handler kind + actionType to pick the right binding flow. May be called multiple
|
|
117
|
+
// times for the same tag (handler re-registration), so each branch must be idempotent.
|
|
118
|
+
private fun attachReadyHandler(handler: GestureHandler, actionType: Int, viewTag: Int) {
|
|
119
|
+
val registry = RNGestureHandlerModule.registries[moduleId]
|
|
120
|
+
?: throw Exception("Tried to access a non-existent registry")
|
|
164
121
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
122
|
+
if (handler.wantsToAttachDirectlyToView() && actionType == GestureHandler.ACTION_TYPE_NATIVE_DETECTOR) {
|
|
123
|
+
assert(childCount <= 1) {
|
|
124
|
+
"Cannot attach native gesture handlers when the detector has multiple children"
|
|
125
|
+
}
|
|
126
|
+
nativeHandlers.add(handler.tag)
|
|
127
|
+
if (childCount != 0) {
|
|
128
|
+
tryAttachNativeHandlersToChildView(getChildAt(0))
|
|
129
|
+
}
|
|
130
|
+
return
|
|
168
131
|
}
|
|
132
|
+
|
|
133
|
+
registry.attachHandlerToView(handler.tag, viewTag, actionType, this)
|
|
134
|
+
if (actionType == GestureHandler.ACTION_TYPE_VIRTUAL_DETECTOR) {
|
|
135
|
+
handler.hostDetectorView = this
|
|
136
|
+
}
|
|
137
|
+
attachedHandlers.add(handler.tag)
|
|
169
138
|
}
|
|
170
139
|
|
|
171
140
|
private fun attachVirtualChildren(virtualChildrenToAttach: List<VirtualChildren>) {
|
|
172
|
-
val virtualChildrenToDetach =
|
|
141
|
+
val virtualChildrenToDetach = subscribedVirtualHandlers.keys.toMutableSet()
|
|
173
142
|
|
|
174
143
|
for (child in virtualChildrenToAttach) {
|
|
175
144
|
virtualChildrenToDetach.remove(child.viewTag)
|
|
@@ -179,22 +148,26 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
179
148
|
?: throw Exception("Tried to access a non-existent registry")
|
|
180
149
|
|
|
181
150
|
for (child in virtualChildrenToDetach) {
|
|
182
|
-
for (tag in
|
|
183
|
-
registry.
|
|
151
|
+
for (tag in subscribedVirtualHandlers[child]!!) {
|
|
152
|
+
registry.cancelObservation(tag, this)
|
|
153
|
+
if (attachedHandlers.contains(tag)) {
|
|
154
|
+
registry.detachHandlerFromHostDetector(tag, this)
|
|
155
|
+
attachedHandlers.remove(tag)
|
|
156
|
+
}
|
|
184
157
|
}
|
|
185
|
-
|
|
158
|
+
subscribedVirtualHandlers.remove(child)
|
|
186
159
|
}
|
|
187
160
|
|
|
188
161
|
for (child in virtualChildrenToAttach) {
|
|
189
|
-
if (!
|
|
190
|
-
|
|
162
|
+
if (!subscribedVirtualHandlers.containsKey(child.viewTag)) {
|
|
163
|
+
subscribedVirtualHandlers[child.viewTag] = mutableSetOf()
|
|
191
164
|
}
|
|
192
165
|
|
|
193
166
|
attachHandlers(
|
|
194
167
|
child.handlerTags,
|
|
195
168
|
child.viewTag,
|
|
196
169
|
GestureHandler.ACTION_TYPE_VIRTUAL_DETECTOR,
|
|
197
|
-
|
|
170
|
+
subscribedVirtualHandlers[child.viewTag]!!,
|
|
198
171
|
)
|
|
199
172
|
}
|
|
200
173
|
}
|
|
@@ -225,8 +198,13 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
225
198
|
}
|
|
226
199
|
|
|
227
200
|
for (tag in nativeHandlers) {
|
|
201
|
+
// Defensive: a tag may be in `nativeHandlers` from an earlier ready callback but the
|
|
202
|
+
// underlying handler may have been dropped since. Skip; a re-registration will fire the
|
|
203
|
+
// observation again.
|
|
204
|
+
if (registry.getHandler(tag) == null) {
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
228
207
|
registry.attachHandlerToView(tag, id, GestureHandler.ACTION_TYPE_NATIVE_DETECTOR, this)
|
|
229
|
-
|
|
230
208
|
attachedHandlers.add(tag)
|
|
231
209
|
}
|
|
232
210
|
}
|
|
@@ -236,6 +214,9 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
236
214
|
?: throw Exception("Tried to access a non-existent registry")
|
|
237
215
|
|
|
238
216
|
for (tag in nativeHandlers) {
|
|
217
|
+
if (!attachedHandlers.contains(tag)) {
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
239
220
|
registry.detachHandlerFromHostDetector(tag, this)
|
|
240
221
|
attachedHandlers.remove(tag)
|
|
241
222
|
}
|
|
@@ -247,20 +228,16 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
|
|
|
247
228
|
}
|
|
248
229
|
|
|
249
230
|
fun detachAllHandlers() {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
for (tag in attachedHandlers.toMutableSet()) {
|
|
254
|
-
registry.detachHandlerFromHostDetector(tag, this)
|
|
255
|
-
attachedHandlers.remove(tag)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
for (child in attachedVirtualHandlers) {
|
|
259
|
-
for (tag in child.value) {
|
|
231
|
+
RNGestureHandlerModule.registries[moduleId]?.let { registry ->
|
|
232
|
+
registry.cancelAllObservationsForOwner(this)
|
|
233
|
+
for (tag in attachedHandlers) {
|
|
260
234
|
registry.detachHandlerFromHostDetector(tag, this)
|
|
261
235
|
}
|
|
262
|
-
child.value.clear()
|
|
263
236
|
}
|
|
237
|
+
attachedHandlers.clear()
|
|
238
|
+
subscribedVirtualHandlers.clear()
|
|
239
|
+
subscribedHandlers.clear()
|
|
240
|
+
nativeHandlers.clear()
|
|
264
241
|
}
|
|
265
242
|
|
|
266
243
|
fun recordHandlerIfNotPresent(handler: GestureHandler) {
|
|
@@ -50,7 +50,7 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
|
|
50
50
|
|
|
51
51
|
override fun shouldHandlerBeCancelledBy(handler: GestureHandler, otherHandler: GestureHandler): Boolean {
|
|
52
52
|
if (otherHandler is NativeViewGestureHandler) {
|
|
53
|
-
return otherHandler.
|
|
53
|
+
return !otherHandler.canBeInterruptedBy(handler)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (otherHandler is RNGestureHandlerRootHelper.RootViewGestureHandler) {
|
|
@@ -28,7 +28,6 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
|
28
28
|
@DoNotStrip
|
|
29
29
|
@Suppress("unused")
|
|
30
30
|
private var mHybridData: HybridData = initHybrid()
|
|
31
|
-
private var isReanimatedAvailable = false
|
|
32
31
|
private var uiRuntimeDecorated = false
|
|
33
32
|
private val registry: RNGestureHandlerRegistry
|
|
34
33
|
get() = registries[moduleId]!!
|
|
@@ -61,16 +60,10 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
@ReactMethod
|
|
64
|
-
override fun createGestureHandler(handlerName: String, handlerTagDouble: Double, config: ReadableMap)
|
|
65
|
-
if (isReanimatedAvailable && !uiRuntimeDecorated) {
|
|
66
|
-
uiRuntimeDecorated = decorateUIRuntime()
|
|
67
|
-
}
|
|
68
|
-
|
|
63
|
+
override fun createGestureHandler(handlerName: String, handlerTagDouble: Double, config: ReadableMap) {
|
|
69
64
|
val handlerTag = handlerTagDouble.toInt()
|
|
70
65
|
|
|
71
66
|
createGestureHandlerHelper<GestureHandler>(handlerName, handlerTag, config)
|
|
72
|
-
|
|
73
|
-
return true
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
@ReactMethod
|
|
@@ -125,8 +118,12 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
|
125
118
|
override fun flushOperations() = Unit
|
|
126
119
|
|
|
127
120
|
@ReactMethod
|
|
128
|
-
override fun
|
|
129
|
-
|
|
121
|
+
override fun installUIRuntimeBindings(): Boolean {
|
|
122
|
+
if (!uiRuntimeDecorated) {
|
|
123
|
+
uiRuntimeDecorated = decorateUIRuntime()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return uiRuntimeDecorated
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
@DoNotStrip
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt
CHANGED
|
@@ -11,10 +11,72 @@ class RNGestureHandlerRegistry : GestureHandlerRegistry {
|
|
|
11
11
|
private val handlers = SparseArray<GestureHandler>()
|
|
12
12
|
private val attachedTo = SparseArray<Int?>()
|
|
13
13
|
private val handlersForView = SparseArray<ArrayList<GestureHandler>>()
|
|
14
|
+
private val observers = mutableMapOf<Int, MutableMap<Any, (GestureHandler) -> Unit>>()
|
|
14
15
|
|
|
15
|
-
@Synchronized
|
|
16
16
|
fun registerHandler(handler: GestureHandler) {
|
|
17
|
-
|
|
17
|
+
val hasObservers = synchronized(this) {
|
|
18
|
+
handlers.put(handler.tag, handler)
|
|
19
|
+
observers[handler.tag]?.isNotEmpty() == true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!hasObservers) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// `createGestureHandler` runs on the JS thread, but observer callbacks read detector
|
|
27
|
+
// view state (childCount, getChildAt) and may attach native handlers, so they must run
|
|
28
|
+
// on the UI thread. Re-resolve the observer list on the UI thread so a cancellation that
|
|
29
|
+
// happens between this post and `notify` running (e.g. detector detach) actually prevents
|
|
30
|
+
// the callback.
|
|
31
|
+
val notify = {
|
|
32
|
+
val callbacks = synchronized(this) {
|
|
33
|
+
observers[handler.tag]?.values?.toList().orEmpty()
|
|
34
|
+
}
|
|
35
|
+
for (callback in callbacks) {
|
|
36
|
+
callback(handler)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (UiThreadUtil.isOnUiThread()) {
|
|
41
|
+
notify()
|
|
42
|
+
} else {
|
|
43
|
+
UiThreadUtil.runOnUiThread(notify)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Invokes `block` every time a handler with `tag` is registered, and synchronously once now if
|
|
48
|
+
// the handler already exists. The observation persists until explicitly cancelled: the registry
|
|
49
|
+
// holds both `owner` and `block` strongly, so callers MUST call `cancelObservation` or
|
|
50
|
+
// `cancelAllObservationsForOwner` when the owner is going away (typically in detach / dispose
|
|
51
|
+
// paths) to avoid leaking the owner. Observing the same tag twice with the same `owner` replaces
|
|
52
|
+
// the previous block.
|
|
53
|
+
fun observeHandler(tag: Int, owner: Any, block: (GestureHandler) -> Unit) {
|
|
54
|
+
val existing = synchronized(this) {
|
|
55
|
+
observers.getOrPut(tag) { mutableMapOf() }[owner] = block
|
|
56
|
+
handlers[tag]
|
|
57
|
+
}
|
|
58
|
+
existing?.let { block(it) }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Synchronized
|
|
62
|
+
fun cancelObservation(tag: Int, owner: Any) {
|
|
63
|
+
val observersForTag = observers[tag] ?: return
|
|
64
|
+
observersForTag.remove(owner)
|
|
65
|
+
if (observersForTag.isEmpty()) {
|
|
66
|
+
observers.remove(tag)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Synchronized
|
|
71
|
+
fun cancelAllObservationsForOwner(owner: Any) {
|
|
72
|
+
val iterator = observers.entries.iterator()
|
|
73
|
+
while (iterator.hasNext()) {
|
|
74
|
+
val entry = iterator.next()
|
|
75
|
+
entry.value.remove(owner)
|
|
76
|
+
if (entry.value.isEmpty()) {
|
|
77
|
+
iterator.remove()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
18
80
|
}
|
|
19
81
|
|
|
20
82
|
@Synchronized
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
CHANGED
|
@@ -13,6 +13,7 @@ import com.facebook.react.uimanager.RootView
|
|
|
13
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
14
14
|
import com.swmansion.gesturehandler.core.GestureHandler
|
|
15
15
|
import com.swmansion.gesturehandler.core.GestureHandlerOrchestrator
|
|
16
|
+
import com.swmansion.gesturehandler.core.OnJSResponderCancelListener
|
|
16
17
|
|
|
17
18
|
class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView: ViewGroup, private val moduleId: Int) {
|
|
18
19
|
private val orchestrator: GestureHandlerOrchestrator?
|
|
@@ -34,11 +35,26 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
|
34
35
|
ReactConstants.TAG,
|
|
35
36
|
"[GESTURE HANDLER] Initialize gesture handler for root view $rootView",
|
|
36
37
|
)
|
|
38
|
+
val onJSResponderCancelListener = object : OnJSResponderCancelListener {
|
|
39
|
+
override fun onCancelJSResponderRequested(handler: GestureHandler) {
|
|
40
|
+
val time = SystemClock.uptimeMillis()
|
|
41
|
+
val event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0f, 0f, 0)
|
|
42
|
+
if (rootView is RootView) {
|
|
43
|
+
rootView.onChildStartedNativeGesture(rootView, event)
|
|
44
|
+
}
|
|
45
|
+
event.recycle()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun onCancelJSResponderReleased(handler: GestureHandler) {
|
|
49
|
+
shouldIntercept = false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
orchestrator = GestureHandlerOrchestrator(
|
|
38
53
|
wrappedView,
|
|
39
54
|
registry,
|
|
40
55
|
RNViewConfigurationHelper(),
|
|
41
56
|
rootView,
|
|
57
|
+
onJSResponderCancelListener,
|
|
42
58
|
).apply {
|
|
43
59
|
minimumAlphaForTraversal = MIN_ALPHA_FOR_TOUCH
|
|
44
60
|
}
|
|
@@ -66,6 +82,8 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
internal inner class RootViewGestureHandler(handlerTag: Int) : GestureHandler() {
|
|
85
|
+
override val isContinuous = true
|
|
86
|
+
|
|
69
87
|
init {
|
|
70
88
|
this.tag = handlerTag
|
|
71
89
|
}
|
|
@@ -95,14 +113,6 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
|
95
113
|
|
|
96
114
|
override fun onCancel() {
|
|
97
115
|
shouldIntercept = true
|
|
98
|
-
val time = SystemClock.uptimeMillis()
|
|
99
|
-
val event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0f, 0f, 0).apply {
|
|
100
|
-
action = MotionEvent.ACTION_CANCEL
|
|
101
|
-
}
|
|
102
|
-
if (rootView is RootView) {
|
|
103
|
-
rootView.onChildStartedNativeGesture(rootView, event)
|
|
104
|
-
}
|
|
105
|
-
event.recycle()
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt
CHANGED
|
@@ -45,10 +45,21 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
|
|
|
45
45
|
rootHelper?.recordHandlerIfNotPresent(handler)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
override fun dispatchTouchEvent(event: MotionEvent)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
|
49
|
+
// When starting a new event stream, dispatch CANCEL event so the subtree
|
|
50
|
+
// can clean up its internal state that may be stale due to Gesture Handler
|
|
51
|
+
// starting to intercept events mid-stream.
|
|
52
|
+
if (rootViewEnabled && event.actionMasked == MotionEvent.ACTION_DOWN) {
|
|
53
|
+
val cancelEvent = MotionEvent.obtain(event).apply { action = MotionEvent.ACTION_CANCEL }
|
|
54
|
+
super.dispatchTouchEvent(cancelEvent)
|
|
55
|
+
cancelEvent.recycle()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(event)) {
|
|
59
|
+
true
|
|
60
|
+
} else {
|
|
61
|
+
super.dispatchTouchEvent(event)
|
|
62
|
+
}
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
override fun dispatchGenericMotionEvent(ev: MotionEvent) =
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt
CHANGED
|
@@ -38,12 +38,6 @@ class RNViewConfigurationHelper : ViewConfigurationHelper {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
override fun getChildInDrawingOrderAtIndex(parent: ViewGroup, index: Int): View = if (parent is ReactViewGroup) {
|
|
42
|
-
parent.getChildAt(parent.getZIndexMappedChildIndex(index))
|
|
43
|
-
} else {
|
|
44
|
-
parent.getChildAt(index)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
41
|
override fun isViewClippingChildren(view: ViewGroup) = when {
|
|
48
42
|
view.clipChildren -> true
|
|
49
43
|
view is ReactScrollView -> view.overflow != "visible"
|
|
@@ -170,7 +170,7 @@ static const BOOL defaultFeedbackOnActivation = NO;
|
|
|
170
170
|
- (RNGestureHandlerEventExtraData *)eventExtraData:(RNForceTouchGestureRecognizer *)recognizer
|
|
171
171
|
{
|
|
172
172
|
return [RNGestureHandlerEventExtraData forForce:recognizer.force
|
|
173
|
-
forPosition:[recognizer locationInView:
|
|
173
|
+
forPosition:[recognizer locationInView:self.coordinateView]
|
|
174
174
|
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
|
|
175
175
|
withNumberOfTouches:recognizer.numberOfTouches
|
|
176
176
|
withPointerType:_pointerType];
|
|
@@ -56,16 +56,6 @@ API_AVAILABLE(ios(13.4))
|
|
|
56
56
|
[_gestureHandler handleGesture:self];
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
- (void)triggerAction
|
|
60
|
-
{
|
|
61
|
-
[_gestureHandler handleGesture:self fromReset:NO fromManualStateChange:NO];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
- (void)cancel
|
|
65
|
-
{
|
|
66
|
-
self.enabled = NO;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
59
|
- (void)reset
|
|
70
60
|
{
|
|
71
61
|
[super reset];
|
|
@@ -177,11 +167,16 @@ API_AVAILABLE(ios(13.4))
|
|
|
177
167
|
|
|
178
168
|
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recognizer
|
|
179
169
|
{
|
|
180
|
-
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:
|
|
170
|
+
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:self.coordinateView]
|
|
181
171
|
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
|
|
182
172
|
withPointerType:_pointerType];
|
|
183
173
|
}
|
|
184
174
|
|
|
175
|
+
- (BOOL)isContinuous
|
|
176
|
+
{
|
|
177
|
+
return YES;
|
|
178
|
+
}
|
|
179
|
+
|
|
185
180
|
@end
|
|
186
181
|
|
|
187
182
|
#else
|
|
@@ -201,6 +196,11 @@ API_AVAILABLE(ios(13.4))
|
|
|
201
196
|
return self;
|
|
202
197
|
}
|
|
203
198
|
|
|
199
|
+
- (BOOL)isContinuous
|
|
200
|
+
{
|
|
201
|
+
return YES;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
204
|
- (void)bindToView:(RNGHUIView *)view
|
|
205
205
|
{
|
|
206
206
|
_view = view;
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
|
|
288
288
|
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recognizer
|
|
289
289
|
{
|
|
290
|
-
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:
|
|
290
|
+
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:self.coordinateView]
|
|
291
291
|
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
|
|
292
292
|
withNumberOfTouches:recognizer.numberOfTouches
|
|
293
293
|
withDuration:[(RNBetterLongPressGestureRecognizer *)recognizer getDuration]
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
|
|
299
299
|
- (RNGestureHandlerEventExtraData *)eventExtraData:(NSGestureRecognizer *)recognizer
|
|
300
300
|
{
|
|
301
|
-
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:
|
|
301
|
+
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:self.coordinateView]
|
|
302
302
|
withAbsolutePosition:[recognizer locationInView:recognizer.view.window.contentView]
|
|
303
303
|
withNumberOfTouches:1
|
|
304
304
|
withDuration:[(RNBetterLongPressGestureRecognizer *)recognizer getDuration]
|