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,25 +9,26 @@ import {
|
|
|
9
9
|
isComposedGesture,
|
|
10
10
|
prepareRelations,
|
|
11
11
|
} from '../hooks/utils/relationUtils';
|
|
12
|
-
import {
|
|
13
|
-
import type { Gesture } from '../types';
|
|
12
|
+
import type { Gesture, GestureRelations } from '../types';
|
|
14
13
|
import { ComposedGestureName } from '../types';
|
|
15
14
|
|
|
16
15
|
// The tree consists of ComposedGestures and NativeGestures. NativeGestures are always leaf nodes.
|
|
17
16
|
export const traverseAndConfigureRelations = (
|
|
18
17
|
node: Gesture,
|
|
18
|
+
relationsByTag: Map<number, GestureRelations>,
|
|
19
19
|
simultaneousHandlers: Set<number>,
|
|
20
20
|
waitFor: number[] = []
|
|
21
21
|
) => {
|
|
22
22
|
// If we are in the leaf node, we want to fill gesture relations arrays with current
|
|
23
|
-
// waitFor and simultaneousHandlers. We also want to
|
|
23
|
+
// waitFor and simultaneousHandlers. We also want to record the resulting relations for
|
|
24
|
+
// this handler so the caller can push them to the native side.
|
|
24
25
|
if (!isComposedGesture(node)) {
|
|
25
26
|
node.gestureRelations = prepareRelations(node.config, node.handlerTag);
|
|
26
27
|
|
|
27
28
|
node.gestureRelations.simultaneousHandlers.push(...simultaneousHandlers);
|
|
28
29
|
node.gestureRelations.waitFor.push(...waitFor);
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
relationsByTag.set(node.handlerTag, {
|
|
31
32
|
waitFor: node.gestureRelations.waitFor,
|
|
32
33
|
simultaneousHandlers: node.gestureRelations.simultaneousHandlers,
|
|
33
34
|
blocksHandlers: node.gestureRelations.blocksHandlers,
|
|
@@ -73,7 +74,12 @@ export const traverseAndConfigureRelations = (
|
|
|
73
74
|
const length = waitFor.length;
|
|
74
75
|
|
|
75
76
|
// We traverse the child, passing the current `waitFor` and `simultaneousHandlers`.
|
|
76
|
-
traverseAndConfigureRelations(
|
|
77
|
+
traverseAndConfigureRelations(
|
|
78
|
+
child,
|
|
79
|
+
relationsByTag,
|
|
80
|
+
simultaneousHandlers,
|
|
81
|
+
waitFor
|
|
82
|
+
);
|
|
77
83
|
|
|
78
84
|
// After traversing the child, we need to update `waitFor` and `simultaneousHandlers`
|
|
79
85
|
|
|
@@ -122,7 +128,12 @@ export const traverseAndConfigureRelations = (
|
|
|
122
128
|
// We don't want to mark gesture as simultaneous with itself, so we remove its tag from the set.
|
|
123
129
|
const hasRemovedTag = simultaneousHandlers.delete(child.handlerTag);
|
|
124
130
|
|
|
125
|
-
traverseAndConfigureRelations(
|
|
131
|
+
traverseAndConfigureRelations(
|
|
132
|
+
child,
|
|
133
|
+
relationsByTag,
|
|
134
|
+
simultaneousHandlers,
|
|
135
|
+
waitFor
|
|
136
|
+
);
|
|
126
137
|
|
|
127
138
|
if (hasRemovedTag) {
|
|
128
139
|
simultaneousHandlers.add(child.handlerTag);
|
|
@@ -138,7 +149,9 @@ export const traverseAndConfigureRelations = (
|
|
|
138
149
|
|
|
139
150
|
export function configureRelations<TConfig, THandlerData>(
|
|
140
151
|
gesture: Gesture<TConfig, THandlerData>
|
|
141
|
-
) {
|
|
152
|
+
): Map<number, GestureRelations> {
|
|
153
|
+
const relationsByTag = new Map<number, GestureRelations>();
|
|
154
|
+
|
|
142
155
|
if (isComposedGesture(gesture)) {
|
|
143
156
|
const simultaneousHandlers = new Set<number>(
|
|
144
157
|
gesture.externalSimultaneousHandlers
|
|
@@ -151,13 +164,16 @@ export function configureRelations<TConfig, THandlerData>(
|
|
|
151
164
|
);
|
|
152
165
|
}
|
|
153
166
|
|
|
154
|
-
traverseAndConfigureRelations(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
gesture.gestureRelations
|
|
167
|
+
traverseAndConfigureRelations(
|
|
168
|
+
gesture,
|
|
169
|
+
relationsByTag,
|
|
170
|
+
simultaneousHandlers
|
|
159
171
|
);
|
|
172
|
+
} else {
|
|
173
|
+
relationsByTag.set(gesture.handlerTag, gesture.gestureRelations);
|
|
160
174
|
}
|
|
175
|
+
|
|
176
|
+
return relationsByTag;
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
export function ensureNativeDetectorComponent(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { ReanimatedHandler } from '../../../handlers/gestures/reanimatedWrapper';
|
|
4
4
|
import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper';
|
|
@@ -10,6 +10,12 @@ import type {
|
|
|
10
10
|
} from '../../types';
|
|
11
11
|
import { eventHandler } from './eventHandler';
|
|
12
12
|
|
|
13
|
+
const REANIMATED_EVENT_NAMES = [
|
|
14
|
+
'onGestureHandlerReanimatedEvent',
|
|
15
|
+
'onGestureHandlerReanimatedStateChange',
|
|
16
|
+
'onGestureHandlerReanimatedTouchEvent',
|
|
17
|
+
];
|
|
18
|
+
|
|
13
19
|
const workletNOOP = () => {
|
|
14
20
|
'worklet';
|
|
15
21
|
// no-op
|
|
@@ -59,14 +65,24 @@ export function useReanimatedEventHandler<
|
|
|
59
65
|
);
|
|
60
66
|
};
|
|
61
67
|
|
|
68
|
+
// Fast Refresh invalidates `useMemo` caches but preserves `useRef`, so the
|
|
69
|
+
// `handlerTag` computed with `useMemo([])` in `useGesture` can regenerate
|
|
70
|
+
// on FR. Without forcing a rebuild, the registered worklet keeps the old
|
|
71
|
+
// `handlerTag` in its closure and `isEventForHandlerWithTag` rejects every
|
|
72
|
+
// event emitted by the freshly-created native handler.
|
|
73
|
+
const prevHandlerTagRef = useRef(handlerTag);
|
|
74
|
+
const handlerTagChanged = prevHandlerTagRef.current !== handlerTag;
|
|
75
|
+
|
|
76
|
+
// Write after commit so interrupted or re-invoked renders don't desync the
|
|
77
|
+
// ref from what was actually committed.
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
prevHandlerTagRef.current = handlerTag;
|
|
80
|
+
}, [handlerTag]);
|
|
81
|
+
|
|
62
82
|
const reanimatedEvent = Reanimated?.useEvent(
|
|
63
83
|
callback,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'onGestureHandlerReanimatedStateChange',
|
|
67
|
-
'onGestureHandlerReanimatedTouchEvent',
|
|
68
|
-
],
|
|
69
|
-
!!reanimatedHandler?.doDependenciesDiffer
|
|
84
|
+
REANIMATED_EVENT_NAMES,
|
|
85
|
+
handlerTagChanged || !!reanimatedHandler?.doDependenciesDiffer
|
|
70
86
|
);
|
|
71
87
|
|
|
72
88
|
return reanimatedEvent;
|
|
@@ -8,7 +8,11 @@ import type {
|
|
|
8
8
|
FlingHandlerData,
|
|
9
9
|
} from './FlingTypes';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const EMPTY_FLING_CONFIG: FlingGestureConfig = {};
|
|
12
|
+
|
|
13
|
+
export function useFlingGesture(
|
|
14
|
+
config: FlingGestureConfig = EMPTY_FLING_CONFIG
|
|
15
|
+
): FlingGesture {
|
|
12
16
|
const flingConfig = useClonedAndRemappedConfig<
|
|
13
17
|
FlingGestureProperties,
|
|
14
18
|
FlingHandlerData
|
|
@@ -44,7 +44,11 @@ function transformHoverProps(
|
|
|
44
44
|
|
|
45
45
|
const HoverPropsMapping = new Map<string, string>([['effect', 'hoverEffect']]);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const EMPTY_HOVER_CONFIG: HoverGestureConfig = {};
|
|
48
|
+
|
|
49
|
+
export function useHoverGesture(
|
|
50
|
+
config: HoverGestureConfig = EMPTY_HOVER_CONFIG
|
|
51
|
+
): HoverGesture {
|
|
48
52
|
const hoverConfig = useClonedAndRemappedConfig<
|
|
49
53
|
HoverGestureProperties,
|
|
50
54
|
HoverHandlerData,
|
|
@@ -28,8 +28,10 @@ function transformLongPressProps(
|
|
|
28
28
|
return config;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
const EMPTY_LONG_PRESS_CONFIG: LongPressGestureConfig = {};
|
|
32
|
+
|
|
31
33
|
export function useLongPressGesture(
|
|
32
|
-
config: LongPressGestureConfig
|
|
34
|
+
config: LongPressGestureConfig = EMPTY_LONG_PRESS_CONFIG
|
|
33
35
|
): LongPressGesture {
|
|
34
36
|
const longPressConfig = useClonedAndRemappedConfig<
|
|
35
37
|
LongPressGestureProperties,
|
|
@@ -8,7 +8,11 @@ import type {
|
|
|
8
8
|
ManualHandlerData,
|
|
9
9
|
} from './ManualTypes';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const EMPTY_MANUAL_CONFIG: ManualGestureConfig = {};
|
|
12
|
+
|
|
13
|
+
export function useManualGesture(
|
|
14
|
+
config: ManualGestureConfig = EMPTY_MANUAL_CONFIG
|
|
15
|
+
): ManualGesture {
|
|
12
16
|
const manualConfig = useClonedAndRemappedConfig<
|
|
13
17
|
ManualGestureProperties,
|
|
14
18
|
ManualHandlerData
|
|
@@ -20,11 +20,23 @@ export type NativeGestureNativeProperties = {
|
|
|
20
20
|
* `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
21
21
|
*/
|
|
22
22
|
disallowInterruption?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Composes with `disallowInterruption`. When both are `true`, the handler still
|
|
26
|
+
* resists discrete gestures but yields to continuous gestures, so a wrapping
|
|
27
|
+
* gesture can take over the touch stream. No-op when `disallowInterruption` is
|
|
28
|
+
* `false`.
|
|
29
|
+
*/
|
|
30
|
+
yieldsToContinuousGestures?: boolean;
|
|
23
31
|
};
|
|
24
32
|
|
|
25
33
|
export const NativeHandlerNativeProperties = new Set<
|
|
26
34
|
keyof NativeGestureNativeProperties
|
|
27
|
-
>([
|
|
35
|
+
>([
|
|
36
|
+
'shouldActivateOnStart',
|
|
37
|
+
'disallowInterruption',
|
|
38
|
+
'yieldsToContinuousGestures',
|
|
39
|
+
]);
|
|
28
40
|
|
|
29
41
|
export type NativeHandlerData = {
|
|
30
42
|
pointerInside: boolean;
|
|
@@ -8,7 +8,11 @@ import type {
|
|
|
8
8
|
NativeHandlerData,
|
|
9
9
|
} from './NativeTypes';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const EMPTY_NATIVE_CONFIG: NativeGestureConfig = {};
|
|
12
|
+
|
|
13
|
+
export function useNativeGesture(
|
|
14
|
+
config: NativeGestureConfig = EMPTY_NATIVE_CONFIG
|
|
15
|
+
): NativeGesture {
|
|
12
16
|
const nativeConfig = useClonedAndRemappedConfig<
|
|
13
17
|
NativeGestureProperties,
|
|
14
18
|
NativeHandlerData
|
|
@@ -139,7 +139,11 @@ function transformPanProps(
|
|
|
139
139
|
return config;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const EMPTY_PAN_CONFIG: PanGestureConfig = {};
|
|
143
|
+
|
|
144
|
+
export function usePanGesture(
|
|
145
|
+
config: PanGestureConfig = EMPTY_PAN_CONFIG
|
|
146
|
+
): PanGesture {
|
|
143
147
|
if (__DEV__) {
|
|
144
148
|
validatePanConfig(config);
|
|
145
149
|
}
|
|
@@ -40,7 +40,11 @@ function transformPinchProps(
|
|
|
40
40
|
|
|
41
41
|
const PinchPropsMapping = new Map<string, string>();
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const EMPTY_PINCH_CONFIG: PinchGestureConfig = {};
|
|
44
|
+
|
|
45
|
+
export function usePinchGesture(
|
|
46
|
+
config: PinchGestureConfig = EMPTY_PINCH_CONFIG
|
|
47
|
+
): PinchGesture {
|
|
44
48
|
const pinchConfig = useClonedAndRemappedConfig<
|
|
45
49
|
PinchGestureProperties,
|
|
46
50
|
PinchHandlerData,
|
|
@@ -42,8 +42,10 @@ function transformRotationProps(
|
|
|
42
42
|
|
|
43
43
|
const RotationPropsMapping = new Map<string, string>();
|
|
44
44
|
|
|
45
|
+
const EMPTY_ROTATION_CONFIG: RotationGestureConfig = {};
|
|
46
|
+
|
|
45
47
|
export function useRotationGesture(
|
|
46
|
-
config: RotationGestureConfig
|
|
48
|
+
config: RotationGestureConfig = EMPTY_ROTATION_CONFIG
|
|
47
49
|
): RotationGesture {
|
|
48
50
|
const rotationConfig = useClonedAndRemappedConfig<
|
|
49
51
|
RotationGestureProperties,
|
|
@@ -18,7 +18,11 @@ const TapPropsMapping = new Map<
|
|
|
18
18
|
['maxDelay', 'maxDelayMs'],
|
|
19
19
|
]);
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const EMPTY_TAP_CONFIG: TapGestureConfig = {};
|
|
22
|
+
|
|
23
|
+
export function useTapGesture(
|
|
24
|
+
config: TapGestureConfig = EMPTY_TAP_CONFIG
|
|
25
|
+
): TapGesture {
|
|
22
26
|
const tapConfig = useClonedAndRemappedConfig<
|
|
23
27
|
TapGestureProperties,
|
|
24
28
|
TapHandlerData,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { getNextHandlerTag } from '../../handlers/getNextHandlerTag';
|
|
4
4
|
import {
|
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
import { useGestureCallbacks } from './useGestureCallbacks';
|
|
17
17
|
import {
|
|
18
18
|
bindSharedValues,
|
|
19
|
-
prepareConfig,
|
|
20
19
|
prepareConfigForNativeSide,
|
|
21
20
|
prepareRelations,
|
|
22
21
|
unbindSharedValues,
|
|
@@ -41,9 +40,6 @@ export function useGesture<
|
|
|
41
40
|
);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
// This has to be done ASAP as other hooks depend `shouldUseReanimatedDetector`.
|
|
45
|
-
prepareConfig(config);
|
|
46
|
-
|
|
47
43
|
// TODO: Call only necessary hooks depending on which callbacks are defined (?)
|
|
48
44
|
const { jsEventHandler, reanimatedEventHandler, animatedEventHandler } =
|
|
49
45
|
useGestureCallbacks(handlerTag, config);
|
|
@@ -65,15 +61,6 @@ export function useGesture<
|
|
|
65
61
|
[handlerTag, config.simultaneousWith, config.requireToFail, config.block]
|
|
66
62
|
);
|
|
67
63
|
|
|
68
|
-
const currentGestureRef = useRef({ type: '', handlerTag: -1 });
|
|
69
|
-
if (
|
|
70
|
-
currentGestureRef.current.handlerTag !== handlerTag ||
|
|
71
|
-
currentGestureRef.current.type !== (type as string)
|
|
72
|
-
) {
|
|
73
|
-
currentGestureRef.current = { type, handlerTag };
|
|
74
|
-
NativeProxy.createGestureHandler(type, handlerTag, {});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
64
|
const gesture = useMemo(
|
|
78
65
|
() => ({
|
|
79
66
|
handlerTag,
|
|
@@ -98,11 +85,10 @@ export function useGesture<
|
|
|
98
85
|
);
|
|
99
86
|
|
|
100
87
|
useEffect(() => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
currentGestureRef.current = { type: '', handlerTag: -1 };
|
|
104
|
-
}
|
|
88
|
+
NativeProxy.createGestureHandler(type, handlerTag, {});
|
|
89
|
+
scheduleFlushOperations();
|
|
105
90
|
|
|
91
|
+
return () => {
|
|
106
92
|
NativeProxy.dropGestureHandler(handlerTag);
|
|
107
93
|
scheduleFlushOperations();
|
|
108
94
|
};
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from './propsWhiteList';
|
|
17
17
|
import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils';
|
|
18
18
|
|
|
19
|
-
export function
|
|
19
|
+
export function resolveInternalConfigProps<
|
|
20
20
|
TConfig extends object,
|
|
21
21
|
THandlerData,
|
|
22
22
|
TExtendedHandlerData extends THandlerData,
|
|
@@ -87,9 +87,8 @@ export function prepareConfigForNativeSide<
|
|
|
87
87
|
for (const [key, value] of Object.entries(config)) {
|
|
88
88
|
// @ts-ignore That's the point, we want to see if key exists in the whitelists
|
|
89
89
|
if (allowedNativeProps.has(key) || handlerPropsWhiteList.has(key)) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
90
|
+
(filteredConfig as Record<string, unknown>)[key] =
|
|
91
|
+
Reanimated?.isSharedValue(value) ? value.value : value;
|
|
93
92
|
} else if (PropsToFilter.has(key)) {
|
|
94
93
|
continue;
|
|
95
94
|
} else {
|
|
@@ -125,7 +124,7 @@ function remapProps<
|
|
|
125
124
|
TInternalConfig extends Record<string, unknown>,
|
|
126
125
|
>(
|
|
127
126
|
config: TConfig & TInternalConfig,
|
|
128
|
-
propsMapping:
|
|
127
|
+
propsMapping: ReadonlyMap<string, string>
|
|
129
128
|
): TInternalConfig {
|
|
130
129
|
type MergedConfig = TConfig & TInternalConfig;
|
|
131
130
|
|
|
@@ -142,6 +141,11 @@ function remapProps<
|
|
|
142
141
|
return config;
|
|
143
142
|
}
|
|
144
143
|
|
|
144
|
+
const DEFAULT_PROPS_MAPPING = new Map<string, string>();
|
|
145
|
+
const DEFAULT_PROPS_TRANSFORMER = <TConfig extends object>(
|
|
146
|
+
config: TConfig
|
|
147
|
+
): TConfig => config;
|
|
148
|
+
|
|
145
149
|
export function useClonedAndRemappedConfig<
|
|
146
150
|
TConfig extends Record<string, unknown>,
|
|
147
151
|
THandlerData,
|
|
@@ -151,8 +155,10 @@ export function useClonedAndRemappedConfig<
|
|
|
151
155
|
config: ExcludeInternalConfigProps<
|
|
152
156
|
BaseGestureConfig<TConfig, THandlerData, TExtendedHandlerData>
|
|
153
157
|
>,
|
|
154
|
-
propsMapping:
|
|
155
|
-
propsTransformer: (
|
|
158
|
+
propsMapping: ReadonlyMap<string, string> = DEFAULT_PROPS_MAPPING,
|
|
159
|
+
propsTransformer: (
|
|
160
|
+
config: TInternalConfig
|
|
161
|
+
) => TInternalConfig = DEFAULT_PROPS_TRANSFORMER
|
|
156
162
|
): BaseGestureConfig<TInternalConfig, THandlerData, TExtendedHandlerData> {
|
|
157
163
|
return useMemo(() => {
|
|
158
164
|
const clonedConfig = cloneConfig<
|
|
@@ -161,11 +167,15 @@ export function useClonedAndRemappedConfig<
|
|
|
161
167
|
TExtendedHandlerData
|
|
162
168
|
>(config);
|
|
163
169
|
|
|
164
|
-
|
|
170
|
+
const transformedConfig = propsTransformer(
|
|
165
171
|
remapProps<TConfig, TInternalConfig>(
|
|
166
172
|
clonedConfig as TConfig & TInternalConfig,
|
|
167
173
|
propsMapping
|
|
168
174
|
)
|
|
169
175
|
);
|
|
176
|
+
|
|
177
|
+
resolveInternalConfigProps(transformedConfig);
|
|
178
|
+
|
|
179
|
+
return transformedConfig;
|
|
170
180
|
}, [config, propsMapping, propsTransformer]);
|
|
171
181
|
}
|
|
@@ -16,38 +16,49 @@ export function useMemoizedGestureCallbacks<
|
|
|
16
16
|
>(
|
|
17
17
|
callbacks: GestureCallbacks<THandlerData, TExtendedHandlerData>
|
|
18
18
|
): GestureCallbacks<THandlerData, TExtendedHandlerData> {
|
|
19
|
-
return useMemo(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
callbacks.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
callbacks.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
callbacks.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
19
|
+
return useMemo(() => {
|
|
20
|
+
const memoized: GestureCallbacks<THandlerData, TExtendedHandlerData> = {};
|
|
21
|
+
|
|
22
|
+
if (callbacks.onBegin) {
|
|
23
|
+
memoized.onBegin = callbacks.onBegin;
|
|
24
|
+
}
|
|
25
|
+
if (callbacks.onActivate) {
|
|
26
|
+
memoized.onActivate = callbacks.onActivate;
|
|
27
|
+
}
|
|
28
|
+
if (callbacks.onDeactivate) {
|
|
29
|
+
memoized.onDeactivate = callbacks.onDeactivate;
|
|
30
|
+
}
|
|
31
|
+
if (callbacks.onFinalize) {
|
|
32
|
+
memoized.onFinalize = callbacks.onFinalize;
|
|
33
|
+
}
|
|
34
|
+
if (callbacks.onUpdate) {
|
|
35
|
+
memoized.onUpdate = callbacks.onUpdate;
|
|
36
|
+
}
|
|
37
|
+
if (callbacks.onTouchesDown) {
|
|
38
|
+
memoized.onTouchesDown = callbacks.onTouchesDown;
|
|
39
|
+
}
|
|
40
|
+
if (callbacks.onTouchesMove) {
|
|
41
|
+
memoized.onTouchesMove = callbacks.onTouchesMove;
|
|
42
|
+
}
|
|
43
|
+
if (callbacks.onTouchesUp) {
|
|
44
|
+
memoized.onTouchesUp = callbacks.onTouchesUp;
|
|
45
|
+
}
|
|
46
|
+
if (callbacks.onTouchesCancel) {
|
|
47
|
+
memoized.onTouchesCancel = callbacks.onTouchesCancel;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return memoized;
|
|
51
|
+
}, [
|
|
52
|
+
callbacks.onActivate,
|
|
53
|
+
callbacks.onBegin,
|
|
54
|
+
callbacks.onDeactivate,
|
|
55
|
+
callbacks.onFinalize,
|
|
56
|
+
callbacks.onTouchesCancel,
|
|
57
|
+
callbacks.onTouchesDown,
|
|
58
|
+
callbacks.onTouchesMove,
|
|
59
|
+
callbacks.onTouchesUp,
|
|
60
|
+
callbacks.onUpdate,
|
|
61
|
+
]);
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
function getHandler<THandlerData, TExtendedHandlerData extends THandlerData>(
|
|
@@ -2,7 +2,6 @@ import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper';
|
|
|
2
2
|
import { NativeProxy } from '../../NativeProxy';
|
|
3
3
|
import type {
|
|
4
4
|
BaseGestureConfig,
|
|
5
|
-
GestureCallbacks,
|
|
6
5
|
SharedValue,
|
|
7
6
|
SharedValueOrT,
|
|
8
7
|
} from '../../types';
|
|
@@ -21,7 +20,7 @@ function hash(str: string) {
|
|
|
21
20
|
return h >>> 0;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
const SHARED_VALUE_OFFSET = 1.618;
|
|
23
|
+
export const SHARED_VALUE_OFFSET = 1.618;
|
|
25
24
|
|
|
26
25
|
// Don't transfer entire NativeProxy to the UI thread
|
|
27
26
|
const { updateGestureHandlerConfig } = NativeProxy;
|
|
@@ -101,14 +100,15 @@ export function hasWorkletEventHandlers<
|
|
|
101
100
|
THandlerData,
|
|
102
101
|
TExtendedHandlerData extends THandlerData,
|
|
103
102
|
>(config: BaseGestureConfig<TConfig, THandlerData, TExtendedHandlerData>) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
for (const key of HandlerCallbacks) {
|
|
104
|
+
const value = config[key];
|
|
105
|
+
|
|
106
|
+
if (typeof value === 'function' && '__workletHash' in value) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return false;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function maybeUnpackValue<T>(
|
|
@@ -77,6 +77,7 @@ export type CommonGestureConfig = {
|
|
|
77
77
|
activeCursor?: ActiveCursor | undefined;
|
|
78
78
|
mouseButton?: MouseButton | undefined;
|
|
79
79
|
cancelsTouchesInView?: boolean | undefined;
|
|
80
|
+
cancelsJSResponder?: boolean | undefined;
|
|
80
81
|
manualActivation?: boolean | undefined;
|
|
81
82
|
},
|
|
82
83
|
ActiveCursor | MouseButton
|
package/src/web/constants.ts
CHANGED
|
@@ -84,15 +84,23 @@ export default class RotationGestureDetector
|
|
|
84
84
|
this.onRotationEnd(this);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
private setKeyPointers(tracker: PointerTracker): void {
|
|
87
|
+
private setKeyPointers(tracker: PointerTracker, excludeId?: number): void {
|
|
88
88
|
if (this.keyPointers[0] && this.keyPointers[1]) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
let assigned = 0;
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
for (const id of tracker.trackedPointers.keys()) {
|
|
95
|
+
if (id === excludeId) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this.keyPointers[assigned++] = id;
|
|
100
|
+
if (assigned === 2) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {
|
|
@@ -132,7 +140,13 @@ export default class RotationGestureDetector
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
if (this.keyPointers.indexOf(event.pointerId) >= 0) {
|
|
135
|
-
|
|
143
|
+
if (tracker.trackedPointersCount <= 2) {
|
|
144
|
+
this.reset();
|
|
145
|
+
} else {
|
|
146
|
+
this.keyPointers = [NaN, NaN];
|
|
147
|
+
this.setKeyPointers(tracker, event.pointerId);
|
|
148
|
+
this.previousAngle = NaN;
|
|
149
|
+
}
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
break;
|
|
@@ -44,10 +44,16 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
|
|
|
44
44
|
const action: EventTypes = event.eventType;
|
|
45
45
|
const numOfPointers = tracker.trackedPointersCount;
|
|
46
46
|
|
|
47
|
+
// When the last second pointer lifts (going down to 1), pause without
|
|
48
|
+
// touching span/time state so the gesture resumes cleanly on re-add.
|
|
49
|
+
// When 3+ → 2+ pointers, fall through so configChanged resets the span
|
|
50
|
+
// baseline to the remaining pointer set and avoids a scale jump.
|
|
51
|
+
if (action === EventTypes.ADDITIONAL_POINTER_UP && numOfPointers <= 2) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
const streamComplete: boolean =
|
|
48
|
-
action === EventTypes.UP ||
|
|
49
|
-
action === EventTypes.ADDITIONAL_POINTER_UP ||
|
|
50
|
-
action === EventTypes.CANCEL;
|
|
56
|
+
action === EventTypes.UP || action === EventTypes.CANCEL;
|
|
51
57
|
|
|
52
58
|
if (action === EventTypes.DOWN || streamComplete) {
|
|
53
59
|
if (this.inProgress) {
|