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
|
@@ -9,7 +9,6 @@ import android.view.MotionEvent
|
|
|
9
9
|
import android.view.MotionEvent.PointerCoords
|
|
10
10
|
import android.view.MotionEvent.PointerProperties
|
|
11
11
|
import android.view.View
|
|
12
|
-
import androidx.core.view.isNotEmpty
|
|
13
12
|
import com.facebook.react.bridge.Arguments
|
|
14
13
|
import com.facebook.react.bridge.ReactContext
|
|
15
14
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -48,6 +47,26 @@ open class GestureHandler {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The view whose coordinate space should be used when reporting event positions to JS.
|
|
52
|
+
*
|
|
53
|
+
* Handlers attached via the V3 NativeDetector are registered against the DetectorView wrapper,
|
|
54
|
+
* which never carries user-applied transforms — those live on its child. When the detector has
|
|
55
|
+
* exactly one child we descend into it so reported coordinates match the visible (transformed)
|
|
56
|
+
* view, the same coordinate space V2 and the V3 VirtualGestureDetector report in. With
|
|
57
|
+
* multiple children there is no JS-side way to disambiguate which child caught the pointer,
|
|
58
|
+
* so we keep the detector itself as the reference frame.
|
|
59
|
+
*/
|
|
60
|
+
val coordinateView: View?
|
|
61
|
+
get() {
|
|
62
|
+
val v = view
|
|
63
|
+
return if (v is RNGestureHandlerDetectorView && v.childCount == 1) {
|
|
64
|
+
v.getChildAt(0)
|
|
65
|
+
} else {
|
|
66
|
+
v
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
var state = STATE_UNDETERMINED
|
|
52
71
|
private set
|
|
53
72
|
var x = 0f
|
|
@@ -83,6 +102,7 @@ open class GestureHandler {
|
|
|
83
102
|
var needsPointerData = false
|
|
84
103
|
var dispatchesAnimatedEvents = false
|
|
85
104
|
var dispatchesReanimatedEvents = false
|
|
105
|
+
var cancelsJSResponder = true
|
|
86
106
|
|
|
87
107
|
private var hitSlop: FloatArray? = null
|
|
88
108
|
var eventCoalescingKey: Short = 0
|
|
@@ -113,6 +133,11 @@ open class GestureHandler {
|
|
|
113
133
|
var isAwaiting = false
|
|
114
134
|
var shouldResetProgress = false
|
|
115
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Whether the handler represents a continuous gesture rather than a discrete one.
|
|
138
|
+
*/
|
|
139
|
+
open val isContinuous: Boolean = false
|
|
140
|
+
|
|
116
141
|
open fun dispatchStateChange(newState: Int, prevState: Int) {
|
|
117
142
|
onTouchEventListener?.onStateChange(this, newState, prevState)
|
|
118
143
|
}
|
|
@@ -137,6 +162,7 @@ open class GestureHandler {
|
|
|
137
162
|
mouseButton = DEFAULT_MOUSE_BUTTON
|
|
138
163
|
dispatchesAnimatedEvents = DEFAULT_DISPATCHES_ANIMATED_EVENTS
|
|
139
164
|
dispatchesReanimatedEvents = DEFAULT_DISPATCHES_REANIMATED_EVENTS
|
|
165
|
+
cancelsJSResponder = DEFAULT_CANCELS_JS_RESPONDER
|
|
140
166
|
}
|
|
141
167
|
|
|
142
168
|
fun hasCommonPointers(other: GestureHandler): Boolean {
|
|
@@ -387,42 +413,13 @@ open class GestureHandler {
|
|
|
387
413
|
|
|
388
414
|
numberOfPointers = adaptedTransformedEvent.pointerCount
|
|
389
415
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
for (i in 0 until detectorView.childCount) {
|
|
399
|
-
val child = detectorView.getChildAt(i)
|
|
400
|
-
GestureHandlerOrchestrator.transformPointToChildViewCoords(
|
|
401
|
-
adaptedTransformedEvent.x,
|
|
402
|
-
adaptedTransformedEvent.y,
|
|
403
|
-
detectorView,
|
|
404
|
-
child,
|
|
405
|
-
outPoint,
|
|
406
|
-
)
|
|
407
|
-
if (isWithinBounds(child, outPoint.x, outPoint.y)) {
|
|
408
|
-
x = outPoint.x
|
|
409
|
-
y = outPoint.y
|
|
410
|
-
isWithinBounds = true
|
|
411
|
-
foundChild = true
|
|
412
|
-
break
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (!foundChild) {
|
|
417
|
-
x = adaptedTransformedEvent.x
|
|
418
|
-
y = adaptedTransformedEvent.y
|
|
419
|
-
isWithinBounds = false
|
|
420
|
-
}
|
|
421
|
-
} else {
|
|
422
|
-
x = adaptedTransformedEvent.x
|
|
423
|
-
y = adaptedTransformedEvent.y
|
|
424
|
-
isWithinBounds = isWithinBounds(view, x, y)
|
|
425
|
-
}
|
|
416
|
+
x = adaptedTransformedEvent.x
|
|
417
|
+
y = adaptedTransformedEvent.y
|
|
418
|
+
// The orchestrator transforms incoming events into the coordinate space of the detector's
|
|
419
|
+
// child (when the handler is attached to a NativeDetector wrapper), so bounds-checking must
|
|
420
|
+
// also use that child rather than the wrapper, otherwise hit-testing would ignore the user's
|
|
421
|
+
// transforms applied to the visible view.
|
|
422
|
+
isWithinBounds = isWithinBounds(coordinateView, x, y)
|
|
426
423
|
|
|
427
424
|
if (shouldCancelWhenOutside) {
|
|
428
425
|
if (!isWithinBounds && (state == STATE_ACTIVE || state == STATE_BEGAN)) {
|
|
@@ -693,6 +690,8 @@ open class GestureHandler {
|
|
|
693
690
|
return interactionController?.shouldHandlerBeCancelledBy(this, handler) ?: false
|
|
694
691
|
}
|
|
695
692
|
|
|
693
|
+
open fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>): Boolean = true
|
|
694
|
+
|
|
696
695
|
fun isWithinBounds(view: View?, posX: Float, posY: Float): Boolean {
|
|
697
696
|
if (RNSVGHitTester.isSvgElement(view!!)) {
|
|
698
697
|
return RNSVGHitTester.hitTest(view, posX, posY)
|
|
@@ -870,7 +869,7 @@ open class GestureHandler {
|
|
|
870
869
|
* This method modifies and transforms the received point.
|
|
871
870
|
*/
|
|
872
871
|
protected fun transformPoint(point: PointF): PointF =
|
|
873
|
-
orchestrator?.transformPointToViewCoords(
|
|
872
|
+
orchestrator?.transformPointToViewCoords(coordinateView, point) ?: run {
|
|
874
873
|
point.x = Float.NaN
|
|
875
874
|
point.y = Float.NaN
|
|
876
875
|
point
|
|
@@ -961,6 +960,9 @@ open class GestureHandler {
|
|
|
961
960
|
if (config.hasKey(KEY_TEST_ID)) {
|
|
962
961
|
handler.testID = config.getString(KEY_TEST_ID)
|
|
963
962
|
}
|
|
963
|
+
if (config.hasKey(KEY_CANCELS_JS_RESPONDER)) {
|
|
964
|
+
handler.cancelsJSResponder = config.getBoolean(KEY_CANCELS_JS_RESPONDER)
|
|
965
|
+
}
|
|
964
966
|
}
|
|
965
967
|
|
|
966
968
|
abstract fun createEventBuilder(handler: T): GestureHandlerEventDataBuilder<T>
|
|
@@ -983,6 +985,7 @@ open class GestureHandler {
|
|
|
983
985
|
private const val KEY_HIT_SLOP_WIDTH = "width"
|
|
984
986
|
private const val KEY_HIT_SLOP_HEIGHT = "height"
|
|
985
987
|
private const val KEY_TEST_ID = "testID"
|
|
988
|
+
private const val KEY_CANCELS_JS_RESPONDER = "cancelsJSResponder"
|
|
986
989
|
|
|
987
990
|
private fun handleHitSlopProperty(handler: GestureHandler, config: ReadableMap) {
|
|
988
991
|
if (config.getType(KEY_HIT_SLOP) == ReadableType.Number) {
|
|
@@ -1046,6 +1049,7 @@ open class GestureHandler {
|
|
|
1046
1049
|
private const val DEFAULT_MOUSE_BUTTON = 0
|
|
1047
1050
|
private const val DEFAULT_DISPATCHES_ANIMATED_EVENTS = false
|
|
1048
1051
|
private const val DEFAULT_DISPATCHES_REANIMATED_EVENTS = false
|
|
1052
|
+
private const val DEFAULT_CANCELS_JS_RESPONDER = true
|
|
1049
1053
|
|
|
1050
1054
|
const val STATE_UNDETERMINED = 0
|
|
1051
1055
|
const val STATE_FAILED = 1
|
package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
CHANGED
|
@@ -19,6 +19,7 @@ class GestureHandlerOrchestrator(
|
|
|
19
19
|
private val handlerRegistry: GestureHandlerRegistry,
|
|
20
20
|
private val viewConfigHelper: ViewConfigurationHelper,
|
|
21
21
|
private val rootView: ViewGroup,
|
|
22
|
+
private val onJSResponderCancelListener: OnJSResponderCancelListener,
|
|
22
23
|
) {
|
|
23
24
|
/**
|
|
24
25
|
* Minimum alpha (value from 0 to 1) that should be set to a view so that it can be treated as a
|
|
@@ -143,6 +144,14 @@ class GestureHandlerOrchestrator(
|
|
|
143
144
|
/*package*/
|
|
144
145
|
fun onHandlerStateChange(handler: GestureHandler, newState: Int, prevState: Int) {
|
|
145
146
|
handlingChangeSemaphore += 1
|
|
147
|
+
|
|
148
|
+
if (isFinished(newState) && handler.isActive && handler.cancelsJSResponder) {
|
|
149
|
+
// Check if there are any other active handlers that still request the JS responder to be cancelled.
|
|
150
|
+
if (gestureHandlers.none { it !== handler && it.isActive && it.cancelsJSResponder }) {
|
|
151
|
+
onJSResponderCancelListener?.onCancelJSResponderReleased(handler)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
146
155
|
if (isFinished(newState)) {
|
|
147
156
|
// We have to loop through copy in order to avoid modifying collection
|
|
148
157
|
// while iterating over its elements
|
|
@@ -241,6 +250,10 @@ class GestureHandlerOrchestrator(
|
|
|
241
250
|
return
|
|
242
251
|
}
|
|
243
252
|
|
|
253
|
+
if (handler.cancelsJSResponder) {
|
|
254
|
+
onJSResponderCancelListener?.onCancelJSResponderRequested(handler)
|
|
255
|
+
}
|
|
256
|
+
|
|
244
257
|
handler.dispatchStateChange(GestureHandler.STATE_ACTIVE, GestureHandler.STATE_BEGAN)
|
|
245
258
|
|
|
246
259
|
if (currentState != GestureHandler.STATE_ACTIVE) {
|
|
@@ -297,7 +310,7 @@ class GestureHandlerOrchestrator(
|
|
|
297
310
|
}
|
|
298
311
|
|
|
299
312
|
val action = sourceEvent.actionMasked
|
|
300
|
-
val event = transformEventToViewCoords(handler.
|
|
313
|
+
val event = transformEventToViewCoords(handler.coordinateView, MotionEvent.obtain(sourceEvent))
|
|
301
314
|
|
|
302
315
|
if (handler.needsPointerData) {
|
|
303
316
|
handler.updatePointerData(event, sourceEvent)
|
|
@@ -349,11 +362,19 @@ class GestureHandlerOrchestrator(
|
|
|
349
362
|
if (view === wrapperView) {
|
|
350
363
|
return true
|
|
351
364
|
}
|
|
352
|
-
var
|
|
353
|
-
while (
|
|
354
|
-
parent =
|
|
365
|
+
var current: View = view
|
|
366
|
+
while (true) {
|
|
367
|
+
val parent = current.parent as? ViewGroup ?: return false
|
|
368
|
+
|
|
369
|
+
when {
|
|
370
|
+
// A disappearing child (kept drawable for an exit animation, e.g. RNScreens during a
|
|
371
|
+
// navigation transition) still has `parent` set but is gone from `mChildren`. Treat as
|
|
372
|
+
// detached - `cancelTouchTarget` already synthesized ACTION_CANCEL into this subtree.
|
|
373
|
+
parent.indexOfChild(current) < 0 -> return false
|
|
374
|
+
parent === wrapperView -> return true
|
|
375
|
+
else -> current = parent
|
|
376
|
+
}
|
|
355
377
|
}
|
|
356
|
-
return parent === wrapperView
|
|
357
378
|
}
|
|
358
379
|
|
|
359
380
|
fun isAnyHandlerActive() = gestureHandlers.any { it.state == GestureHandler.STATE_ACTIVE }
|
|
@@ -448,11 +469,16 @@ class GestureHandlerOrchestrator(
|
|
|
448
469
|
return
|
|
449
470
|
}
|
|
450
471
|
|
|
451
|
-
gestureHandlers.add(handler)
|
|
452
472
|
handler.isActive = false
|
|
453
473
|
handler.isAwaiting = false
|
|
454
474
|
handler.activationIndex = Int.MAX_VALUE
|
|
455
475
|
handler.prepare(view, this)
|
|
476
|
+
|
|
477
|
+
if (!handler.shouldBeginWithRecordedHandlers(gestureHandlers)) {
|
|
478
|
+
handler.cancel()
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
gestureHandlers.add(handler)
|
|
456
482
|
}
|
|
457
483
|
|
|
458
484
|
private fun isViewOverflowingParent(view: View): Boolean {
|
|
@@ -606,7 +632,7 @@ class GestureHandlerOrchestrator(
|
|
|
606
632
|
|
|
607
633
|
val childrenCount = viewGroup.childCount
|
|
608
634
|
for (i in childrenCount - 1 downTo 0) {
|
|
609
|
-
val child =
|
|
635
|
+
val child = viewGroup.getChildAt(i)
|
|
610
636
|
if (canReceiveEvents(child)) {
|
|
611
637
|
val childPoint = tempPoint
|
|
612
638
|
transformPointToChildViewCoords(coords[0], coords[1], viewGroup, child, childPoint)
|
|
@@ -659,7 +685,7 @@ class GestureHandlerOrchestrator(
|
|
|
659
685
|
is ViewGroup -> {
|
|
660
686
|
extractGestureHandlers(view, coords, pointerId, event).also { found ->
|
|
661
687
|
// A child view is handling touch, also extract handlers attached to this view
|
|
662
|
-
if (found) {
|
|
688
|
+
if (found || view is RNGestureHandlerDetectorView) {
|
|
663
689
|
recordViewHandlersForPointer(view, coords, pointerId, event)
|
|
664
690
|
}
|
|
665
691
|
}
|
|
@@ -7,10 +7,11 @@ import android.view.MotionEvent
|
|
|
7
7
|
import android.view.View
|
|
8
8
|
import android.view.ViewGroup
|
|
9
9
|
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
|
|
10
|
-
import com.swmansion.gesturehandler.react.RNViewConfigurationHelper
|
|
11
10
|
import com.swmansion.gesturehandler.react.events.eventbuilders.HoverGestureHandlerEventDataBuilder
|
|
12
11
|
|
|
13
12
|
class HoverGestureHandler : GestureHandler() {
|
|
13
|
+
override val isContinuous = true
|
|
14
|
+
|
|
14
15
|
private var handler: Handler? = null
|
|
15
16
|
private var finishRunnable = Runnable { finish() }
|
|
16
17
|
var stylusData: StylusData = StylusData()
|
|
@@ -42,7 +43,7 @@ class HoverGestureHandler : GestureHandler() {
|
|
|
42
43
|
|
|
43
44
|
if (rootView is ViewGroup) {
|
|
44
45
|
for (i in 0 until rootView.childCount) {
|
|
45
|
-
val child =
|
|
46
|
+
val child = rootView.getChildAt(i)
|
|
46
47
|
return isViewDisplayedOverAnother(view, other, child) ?: continue
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -143,8 +144,4 @@ class HoverGestureHandler : GestureHandler() {
|
|
|
143
144
|
|
|
144
145
|
override fun createEventBuilder(handler: HoverGestureHandler) = HoverGestureHandlerEventDataBuilder(handler)
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
companion object {
|
|
148
|
-
private val viewConfigHelper = RNViewConfigurationHelper()
|
|
149
|
-
}
|
|
150
147
|
}
|
|
@@ -5,6 +5,8 @@ import android.view.MotionEvent
|
|
|
5
5
|
import com.swmansion.gesturehandler.react.events.eventbuilders.ManualGestureHandlerEventDataBuilder
|
|
6
6
|
|
|
7
7
|
class ManualGestureHandler : GestureHandler() {
|
|
8
|
+
override val isContinuous = true
|
|
9
|
+
|
|
8
10
|
override fun onHandle(event: MotionEvent, sourceEvent: MotionEvent) {
|
|
9
11
|
if (state == STATE_UNDETERMINED) {
|
|
10
12
|
begin()
|
|
@@ -15,10 +15,13 @@ import com.facebook.react.views.text.ReactTextView
|
|
|
15
15
|
import com.facebook.react.views.textinput.ReactEditText
|
|
16
16
|
import com.facebook.react.views.view.ReactViewGroup
|
|
17
17
|
import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager
|
|
18
|
+
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
|
|
18
19
|
import com.swmansion.gesturehandler.react.events.eventbuilders.NativeGestureHandlerEventDataBuilder
|
|
19
20
|
import com.swmansion.gesturehandler.react.isScreenReaderOn
|
|
20
21
|
|
|
21
22
|
class NativeViewGestureHandler : GestureHandler() {
|
|
23
|
+
override val isContinuous = true
|
|
24
|
+
|
|
22
25
|
private var shouldActivateOnStart = false
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -29,8 +32,19 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
29
32
|
var disallowInterruption = false
|
|
30
33
|
private set
|
|
31
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Composes with [disallowInterruption]. When both are `true`, the handler still resists
|
|
37
|
+
* discrete gesture peers but yields to continuous peers. No-op when [disallowInterruption] is `false`.
|
|
38
|
+
*/
|
|
39
|
+
var yieldsToContinuousGestures = false
|
|
40
|
+
private set
|
|
41
|
+
|
|
32
42
|
private var hook: NativeViewGestureHandlerHook = defaultHook
|
|
33
43
|
|
|
44
|
+
private data class ActiveUpdateSnapshot(val pointerInside: Boolean, val numberOfPointers: Int, val pointerType: Int)
|
|
45
|
+
|
|
46
|
+
private var lastActiveUpdate: ActiveUpdateSnapshot? = null
|
|
47
|
+
|
|
34
48
|
init {
|
|
35
49
|
shouldCancelWhenOutside = true
|
|
36
50
|
}
|
|
@@ -39,6 +53,7 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
39
53
|
super.resetConfig()
|
|
40
54
|
shouldActivateOnStart = DEFAULT_SHOULD_ACTIVATE_ON_START
|
|
41
55
|
disallowInterruption = DEFAULT_DISALLOW_INTERRUPTION
|
|
56
|
+
yieldsToContinuousGestures = DEFAULT_YIELDS_TO_CONTINUOUS_GESTURES
|
|
42
57
|
shouldCancelWhenOutside = DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE
|
|
43
58
|
}
|
|
44
59
|
|
|
@@ -57,12 +72,15 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
57
72
|
// For the `disallowInterruption` to work correctly we need to check the property when
|
|
58
73
|
// accessed as a peer, because simultaneous recognizers can be set on either side of the
|
|
59
74
|
// connection.
|
|
60
|
-
if (handler.state == STATE_ACTIVE &&
|
|
75
|
+
if (handler.state == STATE_ACTIVE &&
|
|
76
|
+
handler.disallowInterruption &&
|
|
77
|
+
!handler.yieldsToContinuousGestures
|
|
78
|
+
) {
|
|
61
79
|
// other handler is active and it disallows interruption, we don't want to get into its way
|
|
62
80
|
return false
|
|
63
81
|
}
|
|
64
82
|
}
|
|
65
|
-
val canBeInterrupted =
|
|
83
|
+
val canBeInterrupted = canBeInterruptedBy(handler)
|
|
66
84
|
val otherState = handler.state
|
|
67
85
|
return if (state == STATE_ACTIVE && otherState == STATE_ACTIVE && canBeInterrupted) {
|
|
68
86
|
// if both handlers are active and the current handler can be interrupted it we return `false`
|
|
@@ -77,7 +95,17 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
77
95
|
// otherwise we can only return `true` if already in an active state
|
|
78
96
|
}
|
|
79
97
|
|
|
80
|
-
override fun shouldBeCancelledBy(handler: GestureHandler): Boolean =
|
|
98
|
+
override fun shouldBeCancelledBy(handler: GestureHandler): Boolean = canBeInterruptedBy(handler)
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Whether this handler permits [other] to take over the touch stream, given its
|
|
102
|
+
* `disallowInterruption` and `yieldsToContinuousGestures` configuration.
|
|
103
|
+
*/
|
|
104
|
+
fun canBeInterruptedBy(other: GestureHandler): Boolean = !disallowInterruption ||
|
|
105
|
+
(yieldsToContinuousGestures && other.isContinuous)
|
|
106
|
+
|
|
107
|
+
override fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>): Boolean =
|
|
108
|
+
hook.shouldBeginWithRecordedHandlers(recorded, this)
|
|
81
109
|
|
|
82
110
|
override fun onPrepare() {
|
|
83
111
|
when (val view = view) {
|
|
@@ -163,6 +191,21 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
163
191
|
|
|
164
192
|
override fun onReset() {
|
|
165
193
|
this.hook = defaultHook
|
|
194
|
+
lastActiveUpdate = null
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
override fun dispatchHandlerUpdate(event: MotionEvent) {
|
|
198
|
+
val snapshot = ActiveUpdateSnapshot(isWithinBounds, numberOfPointers, pointerType)
|
|
199
|
+
if (snapshot == lastActiveUpdate) {
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
lastActiveUpdate = snapshot
|
|
203
|
+
super.dispatchHandlerUpdate(event)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
override fun dispatchStateChange(newState: Int, prevState: Int) {
|
|
207
|
+
lastActiveUpdate = null
|
|
208
|
+
super.dispatchStateChange(newState, prevState)
|
|
166
209
|
}
|
|
167
210
|
|
|
168
211
|
override fun wantsToAttachDirectlyToView() = true
|
|
@@ -181,6 +224,9 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
181
224
|
if (config.hasKey(KEY_DISALLOW_INTERRUPTION)) {
|
|
182
225
|
handler.disallowInterruption = config.getBoolean(KEY_DISALLOW_INTERRUPTION)
|
|
183
226
|
}
|
|
227
|
+
if (config.hasKey(KEY_YIELDS_TO_CONTINUOUS_GESTURES)) {
|
|
228
|
+
handler.yieldsToContinuousGestures = config.getBoolean(KEY_YIELDS_TO_CONTINUOUS_GESTURES)
|
|
229
|
+
}
|
|
184
230
|
}
|
|
185
231
|
|
|
186
232
|
override fun createEventBuilder(handler: NativeViewGestureHandler) = NativeGestureHandlerEventDataBuilder(handler)
|
|
@@ -188,6 +234,7 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
188
234
|
companion object {
|
|
189
235
|
private const val KEY_SHOULD_ACTIVATE_ON_START = "shouldActivateOnStart"
|
|
190
236
|
private const val KEY_DISALLOW_INTERRUPTION = "disallowInterruption"
|
|
237
|
+
private const val KEY_YIELDS_TO_CONTINUOUS_GESTURES = "yieldsToContinuousGestures"
|
|
191
238
|
}
|
|
192
239
|
}
|
|
193
240
|
|
|
@@ -195,6 +242,7 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
195
242
|
private const val DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE = true
|
|
196
243
|
private const val DEFAULT_SHOULD_ACTIVATE_ON_START = false
|
|
197
244
|
private const val DEFAULT_DISALLOW_INTERRUPTION = false
|
|
245
|
+
private const val DEFAULT_YIELDS_TO_CONTINUOUS_GESTURES = false
|
|
198
246
|
|
|
199
247
|
private fun tryIntercept(view: View, event: MotionEvent) = view is ViewGroup && view.onInterceptTouchEvent(event)
|
|
200
248
|
|
|
@@ -252,6 +300,16 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
252
300
|
*/
|
|
253
301
|
fun shouldCancelRootViewGestureHandlerIfNecessary() = false
|
|
254
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Called when the handler is being recorded by the orchestrator, before any pointer events
|
|
305
|
+
* are delivered. Returning `false` cancels the handler immediately.
|
|
306
|
+
*
|
|
307
|
+
* @param recorded handlers already recorded for the current touch
|
|
308
|
+
* @param handler the handler being recorded
|
|
309
|
+
*/
|
|
310
|
+
fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>, handler: NativeViewGestureHandler): Boolean =
|
|
311
|
+
true
|
|
312
|
+
|
|
255
313
|
/**
|
|
256
314
|
* Passes the event down to the underlying view using the correct method.
|
|
257
315
|
*/
|
|
@@ -285,11 +343,14 @@ class NativeViewGestureHandler : GestureHandler() {
|
|
|
285
343
|
}
|
|
286
344
|
}
|
|
287
345
|
|
|
288
|
-
// recognize alongside every handler besides RootViewGestureHandler
|
|
289
|
-
// of RNGestureHandlerRootHelper so no explicit type checks, but its tag is always negative
|
|
346
|
+
// recognize alongside every handler besides RootViewGestureHandler;
|
|
290
347
|
// also if other handler is NativeViewGestureHandler then don't override the default implementation
|
|
291
|
-
override fun shouldRecognizeSimultaneously(handler: GestureHandler) =
|
|
292
|
-
|
|
348
|
+
override fun shouldRecognizeSimultaneously(handler: GestureHandler): Boolean? =
|
|
349
|
+
if (handler is NativeViewGestureHandler) {
|
|
350
|
+
null
|
|
351
|
+
} else {
|
|
352
|
+
handler !is RNGestureHandlerRootHelper.RootViewGestureHandler
|
|
353
|
+
}
|
|
293
354
|
|
|
294
355
|
override fun wantsToHandleEventBeforeActivation() = true
|
|
295
356
|
|
|
@@ -13,6 +13,8 @@ import com.swmansion.gesturehandler.core.GestureUtils.getLastPointerY
|
|
|
13
13
|
import com.swmansion.gesturehandler.react.events.eventbuilders.PanGestureHandlerEventDataBuilder
|
|
14
14
|
|
|
15
15
|
class PanGestureHandler(context: Context?) : GestureHandler() {
|
|
16
|
+
override val isContinuous = true
|
|
17
|
+
|
|
16
18
|
var velocityX = 0f
|
|
17
19
|
private set
|
|
18
20
|
var velocityY = 0f
|
|
@@ -8,6 +8,8 @@ import com.swmansion.gesturehandler.react.events.eventbuilders.PinchGestureHandl
|
|
|
8
8
|
import kotlin.math.abs
|
|
9
9
|
|
|
10
10
|
class PinchGestureHandler : GestureHandler() {
|
|
11
|
+
override val isContinuous = true
|
|
12
|
+
|
|
11
13
|
var scale = 0.0
|
|
12
14
|
private set
|
|
13
15
|
var velocity = 0.0
|
|
@@ -68,9 +70,17 @@ class PinchGestureHandler : GestureHandler() {
|
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
if (state == STATE_UNDETERMINED) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
when (sourceEvent.actionMasked) {
|
|
74
|
+
MotionEvent.ACTION_DOWN -> {
|
|
75
|
+
initialize(event, sourceEvent)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
MotionEvent.ACTION_POINTER_DOWN -> {
|
|
79
|
+
begin()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
73
82
|
}
|
|
83
|
+
|
|
74
84
|
scaleGestureDetector?.onTouchEvent(sourceEvent)
|
|
75
85
|
scaleGestureDetector?.let {
|
|
76
86
|
val point = transformPoint(PointF(it.focusX, it.focusY))
|
|
@@ -79,10 +89,10 @@ class PinchGestureHandler : GestureHandler() {
|
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fail()
|
|
92
|
+
when (state) {
|
|
93
|
+
STATE_UNDETERMINED -> cancel()
|
|
94
|
+
STATE_ACTIVE -> end()
|
|
95
|
+
else -> fail()
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
}
|
|
@@ -8,6 +8,8 @@ import com.swmansion.gesturehandler.react.events.eventbuilders.RotationGestureHa
|
|
|
8
8
|
import kotlin.math.abs
|
|
9
9
|
|
|
10
10
|
class RotationGestureHandler : GestureHandler() {
|
|
11
|
+
override val isContinuous = true
|
|
12
|
+
|
|
11
13
|
private var rotationGestureDetector: RotationGestureDetector? = null
|
|
12
14
|
var rotation = 0.0
|
|
13
15
|
private set
|
|
@@ -59,9 +61,17 @@ class RotationGestureHandler : GestureHandler() {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
if (state == STATE_UNDETERMINED) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
when (sourceEvent.actionMasked) {
|
|
65
|
+
MotionEvent.ACTION_DOWN -> {
|
|
66
|
+
initialize(event, sourceEvent)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
MotionEvent.ACTION_POINTER_DOWN -> {
|
|
70
|
+
begin()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
}
|
|
74
|
+
|
|
65
75
|
rotationGestureDetector?.onTouchEvent(sourceEvent)
|
|
66
76
|
rotationGestureDetector?.let {
|
|
67
77
|
val point = transformPoint(PointF(it.anchorX, it.anchorY))
|
|
@@ -71,8 +81,11 @@ class RotationGestureHandler : GestureHandler() {
|
|
|
71
81
|
|
|
72
82
|
// ACTION_UP is already handled in rotationGestureDetector.onTouchEvent (and effectively in onRotationEnd)
|
|
73
83
|
// if more than one pointer was used
|
|
74
|
-
if (sourceEvent.actionMasked == MotionEvent.ACTION_UP
|
|
75
|
-
|
|
84
|
+
if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
|
|
85
|
+
when (state) {
|
|
86
|
+
STATE_UNDETERMINED -> cancel()
|
|
87
|
+
STATE_BEGAN -> fail()
|
|
88
|
+
}
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.swmansion.gesturehandler.react
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.view.Display
|
|
4
5
|
import android.view.MotionEvent
|
|
5
6
|
import android.view.accessibility.AccessibilityManager
|
|
6
7
|
import com.facebook.react.bridge.ReactContext
|
|
@@ -15,3 +16,23 @@ fun Context.isScreenReaderOn() =
|
|
|
15
16
|
fun MotionEvent.isHoverAction(): Boolean = action == MotionEvent.ACTION_HOVER_MOVE ||
|
|
16
17
|
action == MotionEvent.ACTION_HOVER_ENTER ||
|
|
17
18
|
action == MotionEvent.ACTION_HOVER_EXIT
|
|
19
|
+
|
|
20
|
+
val Display.minimumFrameTime: Float
|
|
21
|
+
get() {
|
|
22
|
+
val supportedModes = this.supportedModes
|
|
23
|
+
var maxRefreshRate = 0f
|
|
24
|
+
|
|
25
|
+
supportedModes.forEach { mode ->
|
|
26
|
+
if (mode.refreshRate > maxRefreshRate) {
|
|
27
|
+
maxRefreshRate = mode.refreshRate
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
val effectiveRefreshRate = when {
|
|
32
|
+
maxRefreshRate > 0f -> maxRefreshRate
|
|
33
|
+
refreshRate > 0f -> refreshRate
|
|
34
|
+
else -> 60f
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return 1000.0f / effectiveRefreshRate
|
|
38
|
+
}
|