react-native-gesture-handler 2.26.0 → 2.27.1
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/README.md +69 -0
- package/android/src/main/jni/CMakeLists.txt +7 -26
- package/lib/commonjs/components/Pressable/Pressable.js +139 -188
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/StateMachine.js +38 -0
- package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js +88 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -0
- package/lib/commonjs/components/Pressable/utils.js +1 -1
- package/lib/commonjs/components/Pressable/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js +3 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +3 -0
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +3 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +6 -6
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +24 -33
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +15 -17
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +12 -11
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +1 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +141 -190
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/StateMachine.js +34 -0
- package/lib/module/components/Pressable/StateMachine.js.map +1 -0
- package/lib/module/components/Pressable/stateDefinitions.js +83 -0
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -0
- package/lib/module/components/Pressable/utils.js +1 -1
- package/lib/module/components/Pressable/utils.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +13 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +3 -1
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +3 -0
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +3 -0
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +6 -6
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +24 -33
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +15 -17
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +1 -1
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +12 -11
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/Vector.js +1 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +0 -1
- package/lib/typescript/ActionType.js +6 -0
- package/lib/typescript/Directions.d.ts +0 -1
- package/lib/typescript/Directions.js +18 -0
- package/lib/typescript/EnableNewWebImplementation.d.ts +0 -1
- package/lib/typescript/EnableNewWebImplementation.js +30 -0
- package/lib/typescript/GestureHandlerRootViewContext.d.ts +0 -1
- package/lib/typescript/GestureHandlerRootViewContext.js +2 -0
- package/lib/typescript/PlatformConstants.d.ts +0 -1
- package/lib/typescript/PlatformConstants.js +3 -0
- package/lib/typescript/PlatformConstants.web.d.ts +0 -1
- package/lib/typescript/PlatformConstants.web.js +5 -0
- package/lib/typescript/PointerType.d.ts +0 -1
- package/lib/typescript/PointerType.js +8 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.js +4 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.web.js +92 -0
- package/lib/typescript/RNGestureHandlerModule.windows.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.windows.js +47 -0
- package/lib/typescript/RNRenderer.d.ts +0 -1
- package/lib/typescript/RNRenderer.js +3 -0
- package/lib/typescript/RNRenderer.web.d.ts +0 -1
- package/lib/typescript/RNRenderer.web.js +3 -0
- package/lib/typescript/State.d.ts +0 -1
- package/lib/typescript/State.js +9 -0
- package/lib/typescript/TouchEventType.d.ts +0 -1
- package/lib/typescript/TouchEventType.js +7 -0
- package/lib/typescript/components/DrawerLayout.d.ts +0 -1
- package/lib/typescript/components/DrawerLayout.js +417 -0
- package/lib/typescript/components/GestureButtons.d.ts +0 -1
- package/lib/typescript/components/GestureButtons.js +165 -0
- package/lib/typescript/components/GestureButtonsProps.d.ts +0 -1
- package/lib/typescript/components/GestureButtonsProps.js +1 -0
- package/lib/typescript/components/GestureComponents.d.ts +0 -1
- package/lib/typescript/components/GestureComponents.js +67 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +0 -1
- package/lib/typescript/components/GestureComponents.web.js +21 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerButton.js +2 -0
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerButton.web.js +3 -0
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.android.js +17 -0
- package/lib/typescript/components/GestureHandlerRootView.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.js +16 -0
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.web.js +11 -0
- package/lib/typescript/components/Pressable/Pressable.d.ts +1 -3
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/Pressable.js +231 -0
- package/lib/typescript/components/Pressable/PressableProps.d.ts +15 -2
- package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/PressableProps.js +1 -0
- package/lib/typescript/components/Pressable/StateMachine.d.ts +14 -0
- package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -0
- package/lib/typescript/components/Pressable/StateMachine.js +34 -0
- package/lib/typescript/components/Pressable/index.d.ts +0 -1
- package/lib/typescript/components/Pressable/index.js +1 -0
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts +9 -0
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -0
- package/lib/typescript/components/Pressable/stateDefinitions.js +104 -0
- package/lib/typescript/components/Pressable/utils.d.ts +3 -7
- package/lib/typescript/components/Pressable/utils.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/utils.js +80 -0
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +0 -1
- package/lib/typescript/components/ReanimatedDrawerLayout.js +364 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +0 -1
- package/lib/typescript/components/ReanimatedSwipeable.js +400 -0
- package/lib/typescript/components/Swipeable.d.ts +0 -1
- package/lib/typescript/components/Swipeable.js +287 -0
- package/lib/typescript/components/Text.d.ts +0 -1
- package/lib/typescript/components/Text.js +38 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts +0 -1
- package/lib/typescript/components/gestureHandlerRootHOC.js +18 -0
- package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +0 -1
- package/lib/typescript/components/touchables/ExtraButtonProps.js +1 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -1
- package/lib/typescript/components/touchables/GenericTouchable.js +221 -0
- package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +0 -1
- package/lib/typescript/components/touchables/GenericTouchableProps.js +1 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableHighlight.js +75 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +65 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.js +6 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableOpacity.js +51 -0
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/typescript/components/touchables/index.d.ts +0 -1
- package/lib/typescript/components/touchables/index.js +4 -0
- package/lib/typescript/components/utils.d.ts +0 -1
- package/lib/typescript/components/utils.js +11 -0
- package/lib/typescript/findNodeHandle.d.ts +0 -1
- package/lib/typescript/findNodeHandle.js +2 -0
- package/lib/typescript/findNodeHandle.web.d.ts +0 -1
- package/lib/typescript/findNodeHandle.web.js +31 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.js +45 -0
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.web.js +7 -0
- package/lib/typescript/ghQueueMicrotask.d.ts +0 -1
- package/lib/typescript/ghQueueMicrotask.js +7 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/FlingGestureHandler.js +19 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/ForceTouchGestureHandler.js +37 -0
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +3 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts.map +1 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.js +1 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/LongPressGestureHandler.js +22 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/NativeViewGestureHandler.js +20 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/PanGestureHandler.js +128 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/PinchGestureHandler.js +12 -0
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.js +2 -0
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.web.js +4 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/RotationGestureHandler.js +12 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/TapGestureHandler.js +26 -0
- package/lib/typescript/handlers/createHandler.d.ts +0 -1
- package/lib/typescript/handlers/createHandler.js +375 -0
- package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -1
- package/lib/typescript/handlers/createNativeWrapper.js +67 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.js +2 -0
- package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.web.js +4 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -1
- package/lib/typescript/handlers/gestureHandlerCommon.js +42 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +9 -1
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts.map +1 -1
- package/lib/typescript/handlers/gestureHandlerTypesCompat.js +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +22 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +24 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +55 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
- package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/index.js +114 -0
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/types.js +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +54 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +137 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +48 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +35 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +32 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/utils.js +140 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +0 -1
- package/lib/typescript/handlers/gestures/eventReceiver.js +105 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/flingGesture.js +27 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +9 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.js +57 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gesture.js +303 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureComposition.js +78 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +3 -2
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureObjects.js +125 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.js +60 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.web.js +19 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/hoverGesture.js +45 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/longPressGesture.js +35 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/manualGesture.js +16 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/nativeGesture.js +24 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/panGesture.js +181 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/pinchGesture.js +27 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +0 -1
- package/lib/typescript/handlers/gestures/reanimatedWrapper.js +23 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/rotationGesture.js +27 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/tapGesture.js +72 -0
- package/lib/typescript/handlers/getNextHandlerTag.d.ts +0 -1
- package/lib/typescript/handlers/getNextHandlerTag.js +4 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +0 -1
- package/lib/typescript/handlers/handlersRegistry.js +36 -0
- package/lib/typescript/handlers/utils.d.ts +0 -1
- package/lib/typescript/handlers/utils.js +58 -0
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.js +28 -0
- package/lib/typescript/init.d.ts +0 -1
- package/lib/typescript/init.js +15 -0
- package/lib/typescript/jestUtils/index.d.ts +0 -1
- package/lib/typescript/jestUtils/index.js +1 -0
- package/lib/typescript/jestUtils/jestUtils.d.ts +0 -1
- package/lib/typescript/jestUtils/jestUtils.js +290 -0
- package/lib/typescript/mocks.d.ts +0 -1
- package/lib/typescript/mocks.js +59 -0
- package/lib/typescript/mountRegistry.d.ts +0 -1
- package/lib/typescript/mountRegistry.js +29 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +0 -1
- package/lib/typescript/specs/NativeRNGestureHandlerModule.js +2 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +0 -1
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +2 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +0 -1
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +2 -0
- package/lib/typescript/typeUtils.d.ts +0 -1
- package/lib/typescript/typeUtils.js +1 -0
- package/lib/typescript/utils.d.ts +0 -1
- package/lib/typescript/utils.js +80 -0
- package/lib/typescript/web/Gestures.d.ts +0 -1
- package/lib/typescript/web/Gestures.js +38 -0
- package/lib/typescript/web/constants.d.ts +0 -1
- package/lib/typescript/web/constants.js +2 -0
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +0 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.js +122 -0
- package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +0 -1
- package/lib/typescript/web/detectors/ScaleGestureDetector.js +117 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.js +133 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/GestureHandler.js +656 -0
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.js +37 -0
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/IGestureHandler.js +1 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/LongPressGestureHandler.js +136 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/ManualGestureHandler.js +29 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/NativeViewGestureHandler.js +133 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +2 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/PanGestureHandler.js +420 -0
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PinchGestureHandler.js +117 -0
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/RotationGestureHandler.js +122 -0
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -1
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/TapGestureHandler.js +202 -0
- package/lib/typescript/web/interfaces.d.ts +0 -1
- package/lib/typescript/web/interfaces.js +25 -0
- package/lib/typescript/web/tools/CircularBuffer.d.ts +0 -1
- package/lib/typescript/web/tools/CircularBuffer.js +37 -0
- package/lib/typescript/web/tools/EventManager.d.ts +0 -1
- package/lib/typescript/web/tools/EventManager.js +85 -0
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerDelegate.js +1 -0
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +273 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +169 -0
- package/lib/typescript/web/tools/InteractionManager.d.ts +0 -1
- package/lib/typescript/web/tools/InteractionManager.js +91 -0
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/KeyboardEventManager.js +73 -0
- package/lib/typescript/web/tools/LeastSquareSolver.d.ts +0 -1
- package/lib/typescript/web/tools/LeastSquareSolver.js +147 -0
- package/lib/typescript/web/tools/NodeManager.d.ts +0 -1
- package/lib/typescript/web/tools/NodeManager.js +28 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/PointerEventManager.js +179 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +3 -4
- package/lib/typescript/web/tools/PointerTracker.d.ts.map +1 -1
- package/lib/typescript/web/tools/PointerTracker.js +161 -0
- package/lib/typescript/web/tools/Vector.d.ts +1 -2
- package/lib/typescript/web/tools/Vector.js +43 -0
- package/lib/typescript/web/tools/VelocityTracker.d.ts +0 -1
- package/lib/typescript/web/tools/VelocityTracker.js +76 -0
- package/lib/typescript/web/tools/WheelEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/WheelEventManager.js +40 -0
- package/lib/typescript/web/utils.d.ts +0 -1
- package/lib/typescript/web/utils.js +233 -0
- package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/DiscreteGestureHandler.js +48 -0
- package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/DraggingGestureHandler.js +25 -0
- package/lib/typescript/web_hammer/Errors.d.ts +0 -1
- package/lib/typescript/web_hammer/Errors.js +5 -0
- package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/FlingGestureHandler.js +119 -0
- package/lib/typescript/web_hammer/GestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/GestureHandler.js +469 -0
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +26 -0
- package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/LongPressGestureHandler.js +46 -0
- package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/NativeViewGestureHandler.js +40 -0
- package/lib/typescript/web_hammer/NodeManager.d.ts +0 -1
- package/lib/typescript/web_hammer/NodeManager.js +28 -0
- package/lib/typescript/web_hammer/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PanGestureHandler.js +151 -0
- package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PinchGestureHandler.js +19 -0
- package/lib/typescript/web_hammer/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PressGestureHandler.js +133 -0
- package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/RotationGestureHandler.js +20 -0
- package/lib/typescript/web_hammer/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/TapGestureHandler.js +142 -0
- package/lib/typescript/web_hammer/constants.d.ts +0 -1
- package/lib/typescript/web_hammer/constants.js +42 -0
- package/lib/typescript/web_hammer/utils.d.ts +0 -1
- package/lib/typescript/web_hammer/utils.js +15 -0
- package/package.json +4 -2
- package/src/components/Pressable/Pressable.tsx +357 -445
- package/src/components/Pressable/PressableProps.tsx +15 -0
- package/src/components/Pressable/StateMachine.tsx +49 -0
- package/src/components/Pressable/stateDefinitions.ts +125 -0
- package/src/components/Pressable/utils.ts +11 -7
- package/src/handlers/GestureHandlerEventPayload.ts +3 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +9 -0
- package/src/handlers/gestures/forceTouchGesture.ts +9 -0
- package/src/handlers/gestures/gestureObjects.ts +3 -1
- package/src/web/detectors/RotationGestureDetector.ts +4 -0
- package/src/web/handlers/FlingGestureHandler.ts +4 -0
- package/src/web/handlers/GestureHandler.ts +9 -3
- package/src/web/handlers/PanGestureHandler.ts +25 -36
- package/src/web/handlers/TapGestureHandler.ts +14 -19
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -0
- package/src/web/tools/PointerEventManager.ts +1 -1
- package/src/web/tools/PointerTracker.ts +17 -15
- package/src/web/tools/Vector.ts +1 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
import { registerHandler } from '../../handlersRegistry';
|
2
|
+
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
3
|
+
import { filterConfig, scheduleFlushOperations } from '../../utils';
|
4
|
+
import { ActionType } from '../../../ActionType';
|
5
|
+
import { Platform } from 'react-native';
|
6
|
+
import { ghQueueMicrotask } from '../../../ghQueueMicrotask';
|
7
|
+
import { extractGestureRelations, checkGestureCallbacksForWorklets, ALLOWED_PROPS, } from './utils';
|
8
|
+
import { MountRegistry } from '../../../mountRegistry';
|
9
|
+
export function attachHandlers({ preparedGesture, gestureConfig, gesturesToAttach, viewTag, webEventHandlersRef, }) {
|
10
|
+
gestureConfig.initialize();
|
11
|
+
// Use queueMicrotask to extract handlerTags, because all refs should be initialized
|
12
|
+
// when it's ran
|
13
|
+
ghQueueMicrotask(() => {
|
14
|
+
if (!preparedGesture.isMounted) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
gestureConfig.prepare();
|
18
|
+
});
|
19
|
+
for (const handler of gesturesToAttach) {
|
20
|
+
checkGestureCallbacksForWorklets(handler);
|
21
|
+
RNGestureHandlerModule.createGestureHandler(handler.handlerName, handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS));
|
22
|
+
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
23
|
+
}
|
24
|
+
// Use queueMicrotask to extract handlerTags, because all refs should be initialized
|
25
|
+
// when it's ran
|
26
|
+
ghQueueMicrotask(() => {
|
27
|
+
if (!preparedGesture.isMounted) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
for (const handler of gesturesToAttach) {
|
31
|
+
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, extractGestureRelations(handler)));
|
32
|
+
}
|
33
|
+
scheduleFlushOperations();
|
34
|
+
});
|
35
|
+
for (const gesture of gesturesToAttach) {
|
36
|
+
const actionType = gesture.shouldUseReanimated
|
37
|
+
? ActionType.REANIMATED_WORKLET
|
38
|
+
: ActionType.JS_FUNCTION_NEW_API;
|
39
|
+
if (Platform.OS === 'web') {
|
40
|
+
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, ActionType.JS_FUNCTION_OLD_API, // Ignored on web
|
41
|
+
webEventHandlersRef);
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
|
45
|
+
}
|
46
|
+
MountRegistry.gestureWillMount(gesture);
|
47
|
+
}
|
48
|
+
preparedGesture.attachedGestures = gesturesToAttach;
|
49
|
+
if (preparedGesture.animatedHandlers) {
|
50
|
+
const isAnimatedGesture = (g) => g.shouldUseReanimated;
|
51
|
+
preparedGesture.animatedHandlers.value = gesturesToAttach
|
52
|
+
.filter(isAnimatedGesture)
|
53
|
+
.map((g) => g.handlers);
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { unregisterHandler } from '../../handlersRegistry';
|
2
|
+
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
3
|
+
import { scheduleFlushOperations } from '../../utils';
|
4
|
+
import { MountRegistry } from '../../../mountRegistry';
|
5
|
+
export function dropHandlers(preparedGesture) {
|
6
|
+
for (const handler of preparedGesture.attachedGestures) {
|
7
|
+
RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
|
8
|
+
unregisterHandler(handler.handlerTag, handler.config.testId);
|
9
|
+
MountRegistry.gestureWillUnmount(handler);
|
10
|
+
}
|
11
|
+
scheduleFlushOperations();
|
12
|
+
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
/* eslint-disable react/no-unused-prop-types */
|
2
|
+
import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
|
3
|
+
import { Platform } from 'react-native';
|
4
|
+
import findNodeHandle from '../../../findNodeHandle';
|
5
|
+
import { isTestEnv } from '../../../utils';
|
6
|
+
import GestureHandlerRootViewContext from '../../../GestureHandlerRootViewContext';
|
7
|
+
import { useAnimatedGesture } from './useAnimatedGesture';
|
8
|
+
import { attachHandlers } from './attachHandlers';
|
9
|
+
import { needsToReattach } from './needsToReattach';
|
10
|
+
import { dropHandlers } from './dropHandlers';
|
11
|
+
import { useWebEventHandlers } from './utils';
|
12
|
+
import { Wrap, AnimatedWrap } from './Wrap';
|
13
|
+
import { useDetectorUpdater } from './useDetectorUpdater';
|
14
|
+
import { useViewRefHandler } from './useViewRefHandler';
|
15
|
+
import { useMountReactions } from './useMountReactions';
|
16
|
+
function propagateDetectorConfig(props, gesture) {
|
17
|
+
const keysToPropagate = [
|
18
|
+
'userSelect',
|
19
|
+
'enableContextMenu',
|
20
|
+
'touchAction',
|
21
|
+
];
|
22
|
+
for (const key of keysToPropagate) {
|
23
|
+
const value = props[key];
|
24
|
+
if (value === undefined) {
|
25
|
+
continue;
|
26
|
+
}
|
27
|
+
for (const g of gesture.toGestureArray()) {
|
28
|
+
const config = g.config;
|
29
|
+
config[key] = value;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
|
35
|
+
*
|
36
|
+
* ### Props
|
37
|
+
* - `gesture`
|
38
|
+
* - `userSelect` (**Web only**)
|
39
|
+
* - `enableContextMenu` (**Web only**)
|
40
|
+
* - `touchAction` (**Web only**)
|
41
|
+
*
|
42
|
+
* ### Remarks
|
43
|
+
* - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
|
44
|
+
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
|
45
|
+
*
|
46
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
|
47
|
+
*/
|
48
|
+
export const GestureDetector = (props) => {
|
49
|
+
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
50
|
+
if (__DEV__ && !rootViewContext && !isTestEnv() && Platform.OS !== 'web') {
|
51
|
+
throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
|
52
|
+
}
|
53
|
+
// Gesture config should be wrapped with useMemo to prevent unnecessary re-renders
|
54
|
+
const gestureConfig = props.gesture;
|
55
|
+
propagateDetectorConfig(props, gestureConfig);
|
56
|
+
const gesturesToAttach = useMemo(() => gestureConfig.toGestureArray(), [gestureConfig]);
|
57
|
+
const shouldUseReanimated = gesturesToAttach.some((g) => g.shouldUseReanimated);
|
58
|
+
const webEventHandlersRef = useWebEventHandlers();
|
59
|
+
// Store state in ref to prevent unnecessary renders
|
60
|
+
const state = useRef({
|
61
|
+
firstRender: true,
|
62
|
+
viewRef: null,
|
63
|
+
previousViewTag: -1,
|
64
|
+
forceRebuildReanimatedEvent: false,
|
65
|
+
}).current;
|
66
|
+
const preparedGesture = React.useRef({
|
67
|
+
attachedGestures: [],
|
68
|
+
animatedEventHandler: null,
|
69
|
+
animatedHandlers: null,
|
70
|
+
shouldUseReanimated: shouldUseReanimated,
|
71
|
+
isMounted: false,
|
72
|
+
}).current;
|
73
|
+
const updateAttachedGestures = useDetectorUpdater(state, preparedGesture, gesturesToAttach, gestureConfig, webEventHandlersRef);
|
74
|
+
const refHandler = useViewRefHandler(state, updateAttachedGestures);
|
75
|
+
// Reanimated event should be rebuilt only when gestures are reattached, otherwise
|
76
|
+
// config update will be enough as all necessary items are stored in shared values anyway
|
77
|
+
const needsToRebuildReanimatedEvent = state.firstRender ||
|
78
|
+
state.forceRebuildReanimatedEvent ||
|
79
|
+
needsToReattach(preparedGesture, gesturesToAttach);
|
80
|
+
state.forceRebuildReanimatedEvent = false;
|
81
|
+
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
|
82
|
+
useLayoutEffect(() => {
|
83
|
+
const viewTag = findNodeHandle(state.viewRef);
|
84
|
+
preparedGesture.isMounted = true;
|
85
|
+
attachHandlers({
|
86
|
+
preparedGesture,
|
87
|
+
gestureConfig,
|
88
|
+
gesturesToAttach,
|
89
|
+
webEventHandlersRef,
|
90
|
+
viewTag,
|
91
|
+
});
|
92
|
+
return () => {
|
93
|
+
preparedGesture.isMounted = false;
|
94
|
+
dropHandlers(preparedGesture);
|
95
|
+
};
|
96
|
+
}, []);
|
97
|
+
useEffect(() => {
|
98
|
+
if (state.firstRender) {
|
99
|
+
state.firstRender = false;
|
100
|
+
}
|
101
|
+
else {
|
102
|
+
updateAttachedGestures();
|
103
|
+
}
|
104
|
+
}, [props]);
|
105
|
+
useMountReactions(updateAttachedGestures, preparedGesture);
|
106
|
+
if (shouldUseReanimated) {
|
107
|
+
return (<AnimatedWrap ref={refHandler} onGestureHandlerEvent={preparedGesture.animatedEventHandler}>
|
108
|
+
{props.children}
|
109
|
+
</AnimatedWrap>);
|
110
|
+
}
|
111
|
+
else {
|
112
|
+
return <Wrap ref={refHandler}>{props.children}</Wrap>;
|
113
|
+
}
|
114
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Checks whether the gesture should be reattached to the view, this will happen when:
|
2
|
+
// - The number of gestures in the preparedGesture is different than the number of gestures in the gesture
|
3
|
+
// - The handlerName is different in any of the gestures
|
4
|
+
// - At least one of the gestures changed the thread it runs on
|
5
|
+
export function needsToReattach(preparedGesture, newGestures) {
|
6
|
+
if (newGestures.length !== preparedGesture.attachedGestures.length) {
|
7
|
+
return true;
|
8
|
+
}
|
9
|
+
for (let i = 0; i < newGestures.length; i++) {
|
10
|
+
if (newGestures[i].handlerName !==
|
11
|
+
preparedGesture.attachedGestures[i].handlerName ||
|
12
|
+
newGestures[i].shouldUseReanimated !==
|
13
|
+
preparedGesture.attachedGestures[i].shouldUseReanimated) {
|
14
|
+
return true;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return false;
|
18
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -2,4 +2,3 @@ import { GestureType } from '../gesture';
|
|
2
2
|
import { ComposedGesture } from '../gestureComposition';
|
3
3
|
import { AttachedGestureState } from './types';
|
4
4
|
export declare function updateHandlers(preparedGesture: AttachedGestureState, gestureConfig: ComposedGesture | GestureType, newGestures: GestureType[]): void;
|
5
|
-
//# sourceMappingURL=updateHandlers.d.ts.map
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { registerHandler } from '../../handlersRegistry';
|
2
|
+
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
3
|
+
import { filterConfig, scheduleFlushOperations } from '../../utils';
|
4
|
+
import { ghQueueMicrotask } from '../../../ghQueueMicrotask';
|
5
|
+
import { extractGestureRelations, checkGestureCallbacksForWorklets, ALLOWED_PROPS, } from './utils';
|
6
|
+
export function updateHandlers(preparedGesture, gestureConfig, newGestures) {
|
7
|
+
gestureConfig.prepare();
|
8
|
+
for (let i = 0; i < newGestures.length; i++) {
|
9
|
+
const handler = preparedGesture.attachedGestures[i];
|
10
|
+
checkGestureCallbacksForWorklets(handler);
|
11
|
+
// Only update handlerTag when it's actually different, it may be the same
|
12
|
+
// if gesture config object is wrapped with useMemo
|
13
|
+
if (newGestures[i].handlerTag !== handler.handlerTag) {
|
14
|
+
newGestures[i].handlerTag = handler.handlerTag;
|
15
|
+
newGestures[i].handlers.handlerTag = handler.handlerTag;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
// Store attached gestures to avoid crash when gestures changed after queueing micro task
|
19
|
+
const attachedGestures = preparedGesture.attachedGestures;
|
20
|
+
// Use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
|
21
|
+
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
|
22
|
+
// in case of external relations)
|
23
|
+
ghQueueMicrotask(() => {
|
24
|
+
if (!preparedGesture.isMounted) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
// Stop if attached gestures changed after queueing micro task
|
28
|
+
if (attachedGestures !== preparedGesture.attachedGestures) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
// If amount of gesture configs changes, we need to update the callbacks in shared value
|
32
|
+
let shouldUpdateSharedValueIfUsed = attachedGestures.length !== newGestures.length;
|
33
|
+
for (let i = 0; i < newGestures.length; i++) {
|
34
|
+
const handler = attachedGestures[i];
|
35
|
+
// If the gestureId is different (gesture isn't wrapped with useMemo or its dependencies changed),
|
36
|
+
// we need to update the shared value, assuming the gesture runs on UI thread or the thread changed
|
37
|
+
if (handler.handlers.gestureId !== newGestures[i].handlers.gestureId &&
|
38
|
+
(newGestures[i].shouldUseReanimated || handler.shouldUseReanimated)) {
|
39
|
+
shouldUpdateSharedValueIfUsed = true;
|
40
|
+
}
|
41
|
+
handler.config = newGestures[i].config;
|
42
|
+
handler.handlers = newGestures[i].handlers;
|
43
|
+
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, extractGestureRelations(handler)));
|
44
|
+
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
45
|
+
}
|
46
|
+
if (preparedGesture.animatedHandlers && shouldUpdateSharedValueIfUsed) {
|
47
|
+
const newHandlersValue = attachedGestures
|
48
|
+
.filter((g) => g.shouldUseReanimated) // Ignore gestures that shouldn't run on UI
|
49
|
+
.map((g) => g.handlers);
|
50
|
+
preparedGesture.animatedHandlers.value = newHandlersValue;
|
51
|
+
}
|
52
|
+
scheduleFlushOperations();
|
53
|
+
});
|
54
|
+
}
|
@@ -0,0 +1,137 @@
|
|
1
|
+
import { CALLBACK_TYPE } from '../gesture';
|
2
|
+
import { Reanimated } from '../reanimatedWrapper';
|
3
|
+
import { GestureStateManager, } from '../gestureStateManager';
|
4
|
+
import { State } from '../../../State';
|
5
|
+
import { TouchEventType } from '../../../TouchEventType';
|
6
|
+
import { tagMessage } from '../../../utils';
|
7
|
+
function getHandler(type, gesture) {
|
8
|
+
'worklet';
|
9
|
+
switch (type) {
|
10
|
+
case CALLBACK_TYPE.BEGAN:
|
11
|
+
return gesture.onBegin;
|
12
|
+
case CALLBACK_TYPE.START:
|
13
|
+
return gesture.onStart;
|
14
|
+
case CALLBACK_TYPE.UPDATE:
|
15
|
+
return gesture.onUpdate;
|
16
|
+
case CALLBACK_TYPE.CHANGE:
|
17
|
+
return gesture.onChange;
|
18
|
+
case CALLBACK_TYPE.END:
|
19
|
+
return gesture.onEnd;
|
20
|
+
case CALLBACK_TYPE.FINALIZE:
|
21
|
+
return gesture.onFinalize;
|
22
|
+
case CALLBACK_TYPE.TOUCHES_DOWN:
|
23
|
+
return gesture.onTouchesDown;
|
24
|
+
case CALLBACK_TYPE.TOUCHES_MOVE:
|
25
|
+
return gesture.onTouchesMove;
|
26
|
+
case CALLBACK_TYPE.TOUCHES_UP:
|
27
|
+
return gesture.onTouchesUp;
|
28
|
+
case CALLBACK_TYPE.TOUCHES_CANCELLED:
|
29
|
+
return gesture.onTouchesCancelled;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
function touchEventTypeToCallbackType(eventType) {
|
33
|
+
'worklet';
|
34
|
+
switch (eventType) {
|
35
|
+
case TouchEventType.TOUCHES_DOWN:
|
36
|
+
return CALLBACK_TYPE.TOUCHES_DOWN;
|
37
|
+
case TouchEventType.TOUCHES_MOVE:
|
38
|
+
return CALLBACK_TYPE.TOUCHES_MOVE;
|
39
|
+
case TouchEventType.TOUCHES_UP:
|
40
|
+
return CALLBACK_TYPE.TOUCHES_UP;
|
41
|
+
case TouchEventType.TOUCHES_CANCELLED:
|
42
|
+
return CALLBACK_TYPE.TOUCHES_CANCELLED;
|
43
|
+
}
|
44
|
+
return CALLBACK_TYPE.UNDEFINED;
|
45
|
+
}
|
46
|
+
function runWorklet(type, gesture, event, ...args) {
|
47
|
+
'worklet';
|
48
|
+
const handler = getHandler(type, gesture);
|
49
|
+
if (gesture.isWorklet[type]) {
|
50
|
+
// @ts-ignore Logic below makes sure the correct event is send to the
|
51
|
+
// correct handler.
|
52
|
+
handler?.(event, ...args);
|
53
|
+
}
|
54
|
+
else if (handler) {
|
55
|
+
console.warn(tagMessage('Animated gesture callback must be a worklet'));
|
56
|
+
}
|
57
|
+
}
|
58
|
+
function isStateChangeEvent(event) {
|
59
|
+
'worklet';
|
60
|
+
// @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
|
61
|
+
return event.oldState != null;
|
62
|
+
}
|
63
|
+
function isTouchEvent(event) {
|
64
|
+
'worklet';
|
65
|
+
return event.eventType != null;
|
66
|
+
}
|
67
|
+
export function useAnimatedGesture(preparedGesture, needsRebuild) {
|
68
|
+
if (!Reanimated) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
// Hooks are called conditionally, but the condition is whether the
|
72
|
+
// react-native-reanimated is installed, which shouldn't change while running
|
73
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
74
|
+
const sharedHandlersCallbacks = Reanimated.useSharedValue(null);
|
75
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
76
|
+
const lastUpdateEvent = Reanimated.useSharedValue([]);
|
77
|
+
// not every gesture needs a state controller, init them lazily
|
78
|
+
const stateControllers = [];
|
79
|
+
const callback = (event) => {
|
80
|
+
'worklet';
|
81
|
+
const currentCallback = sharedHandlersCallbacks.value;
|
82
|
+
if (!currentCallback) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
for (let i = 0; i < currentCallback.length; i++) {
|
86
|
+
const gesture = currentCallback[i];
|
87
|
+
if (event.handlerTag !== gesture.handlerTag) {
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
if (isStateChangeEvent(event)) {
|
91
|
+
if (event.oldState === State.UNDETERMINED &&
|
92
|
+
event.state === State.BEGAN) {
|
93
|
+
runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);
|
94
|
+
}
|
95
|
+
else if ((event.oldState === State.BEGAN ||
|
96
|
+
event.oldState === State.UNDETERMINED) &&
|
97
|
+
event.state === State.ACTIVE) {
|
98
|
+
runWorklet(CALLBACK_TYPE.START, gesture, event);
|
99
|
+
lastUpdateEvent.value[gesture.handlerTag] = undefined;
|
100
|
+
}
|
101
|
+
else if (event.oldState !== event.state &&
|
102
|
+
event.state === State.END) {
|
103
|
+
if (event.oldState === State.ACTIVE) {
|
104
|
+
runWorklet(CALLBACK_TYPE.END, gesture, event, true);
|
105
|
+
}
|
106
|
+
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);
|
107
|
+
}
|
108
|
+
else if ((event.state === State.FAILED || event.state === State.CANCELLED) &&
|
109
|
+
event.state !== event.oldState) {
|
110
|
+
if (event.oldState === State.ACTIVE) {
|
111
|
+
runWorklet(CALLBACK_TYPE.END, gesture, event, false);
|
112
|
+
}
|
113
|
+
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
else if (isTouchEvent(event)) {
|
117
|
+
if (!stateControllers[i]) {
|
118
|
+
stateControllers[i] = GestureStateManager.create(event.handlerTag);
|
119
|
+
}
|
120
|
+
if (event.eventType !== TouchEventType.UNDETERMINED) {
|
121
|
+
runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);
|
126
|
+
if (gesture.onChange && gesture.changeEventCalculator) {
|
127
|
+
runWorklet(CALLBACK_TYPE.CHANGE, gesture, gesture.changeEventCalculator?.(event, lastUpdateEvent.value[gesture.handlerTag]));
|
128
|
+
lastUpdateEvent.value[gesture.handlerTag] = event;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
};
|
133
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
134
|
+
const event = Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
|
135
|
+
preparedGesture.animatedEventHandler = event;
|
136
|
+
preparedGesture.animatedHandlers = sharedHandlersCallbacks;
|
137
|
+
}
|
@@ -3,4 +3,3 @@ import { GestureType } from '../gesture';
|
|
3
3
|
import { ComposedGesture } from '../gestureComposition';
|
4
4
|
import { AttachedGestureState, GestureDetectorState, WebEventHandler } from './types';
|
5
5
|
export declare function useDetectorUpdater(state: GestureDetectorState, preparedGesture: AttachedGestureState, gesturesToAttach: GestureType[], gestureConfig: ComposedGesture | GestureType, webEventHandlersRef: React.RefObject<WebEventHandler>): (skipConfigUpdate?: boolean) => void;
|
6
|
-
//# sourceMappingURL=useDetectorUpdater.d.ts.map
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { useCallback } from 'react';
|
2
|
+
import { attachHandlers } from './attachHandlers';
|
3
|
+
import { updateHandlers } from './updateHandlers';
|
4
|
+
import { needsToReattach } from './needsToReattach';
|
5
|
+
import { dropHandlers } from './dropHandlers';
|
6
|
+
import { useForceRender, validateDetectorChildren } from './utils';
|
7
|
+
import findNodeHandle from '../../../findNodeHandle';
|
8
|
+
// Returns a function that's responsible for updating the attached gestures
|
9
|
+
// If the view has changed, it will reattach the handlers to the new view
|
10
|
+
// If the view remains the same, it will update the handlers with the new config
|
11
|
+
export function useDetectorUpdater(state, preparedGesture, gesturesToAttach, gestureConfig, webEventHandlersRef) {
|
12
|
+
const forceRender = useForceRender();
|
13
|
+
const updateAttachedGestures = useCallback(
|
14
|
+
// skipConfigUpdate is used to prevent unnecessary updates when only checking if the view has changed
|
15
|
+
(skipConfigUpdate) => {
|
16
|
+
// If the underlying view has changed we need to reattach handlers to the new view
|
17
|
+
const viewTag = findNodeHandle(state.viewRef);
|
18
|
+
const didUnderlyingViewChange = viewTag !== state.previousViewTag;
|
19
|
+
if (didUnderlyingViewChange ||
|
20
|
+
needsToReattach(preparedGesture, gesturesToAttach)) {
|
21
|
+
validateDetectorChildren(state.viewRef);
|
22
|
+
dropHandlers(preparedGesture);
|
23
|
+
attachHandlers({
|
24
|
+
preparedGesture,
|
25
|
+
gestureConfig,
|
26
|
+
gesturesToAttach,
|
27
|
+
webEventHandlersRef,
|
28
|
+
viewTag,
|
29
|
+
});
|
30
|
+
if (didUnderlyingViewChange) {
|
31
|
+
state.previousViewTag = viewTag;
|
32
|
+
state.forceRebuildReanimatedEvent = true;
|
33
|
+
forceRender();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
else if (!skipConfigUpdate) {
|
37
|
+
updateHandlers(preparedGesture, gestureConfig, gesturesToAttach);
|
38
|
+
}
|
39
|
+
}, [
|
40
|
+
forceRender,
|
41
|
+
gestureConfig,
|
42
|
+
gesturesToAttach,
|
43
|
+
preparedGesture,
|
44
|
+
state,
|
45
|
+
webEventHandlersRef,
|
46
|
+
]);
|
47
|
+
return updateAttachedGestures;
|
48
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { transformIntoHandlerTags } from '../../utils';
|
2
|
+
import { MountRegistry } from '../../../mountRegistry';
|
3
|
+
import { useEffect } from 'react';
|
4
|
+
function shouldUpdateDetector(relation, gesture) {
|
5
|
+
if (relation === undefined) {
|
6
|
+
return false;
|
7
|
+
}
|
8
|
+
for (const tag of transformIntoHandlerTags(relation)) {
|
9
|
+
if (tag === gesture.handlerTag) {
|
10
|
+
return true;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
export function useMountReactions(updateDetector, state) {
|
16
|
+
useEffect(() => {
|
17
|
+
return MountRegistry.addMountListener((gesture) => {
|
18
|
+
// At this point the ref in the gesture config should be updated, so we can check if one of the gestures
|
19
|
+
// set in a relation with the gesture got mounted. If so, we need to update the detector to propagate
|
20
|
+
// the changes to the native side.
|
21
|
+
for (const attachedGesture of state.attachedGestures) {
|
22
|
+
const blocksHandlers = attachedGesture.config.blocksHandlers;
|
23
|
+
const requireToFail = attachedGesture.config.requireToFail;
|
24
|
+
const simultaneousWith = attachedGesture.config.simultaneousWith;
|
25
|
+
if (shouldUpdateDetector(blocksHandlers, gesture) ||
|
26
|
+
shouldUpdateDetector(requireToFail, gesture) ||
|
27
|
+
shouldUpdateDetector(simultaneousWith, gesture)) {
|
28
|
+
updateDetector();
|
29
|
+
// We can safely return here, if any other gestures should be updated, they will be by the above call
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}, [updateDetector, state]);
|
35
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
1
|
import { GestureDetectorState } from './types';
|
2
2
|
import React from 'react';
|
3
3
|
export declare function useViewRefHandler(state: GestureDetectorState, updateAttachedGestures: (skipConfigUpdate?: boolean) => void): (ref: React.Component | null) => void;
|
4
|
-
//# sourceMappingURL=useViewRefHandler.d.ts.map
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { isFabric, tagMessage } from '../../../utils';
|
2
|
+
import { getShadowNodeFromRef } from '../../../getShadowNodeFromRef';
|
3
|
+
import { useCallback } from 'react';
|
4
|
+
import findNodeHandle from '../../../findNodeHandle';
|
5
|
+
// Ref handler for the Wrap component attached under the GestureDetector.
|
6
|
+
// It's responsible for setting the viewRef on the state and triggering the reattaching of handlers
|
7
|
+
// if the view has changed.
|
8
|
+
export function useViewRefHandler(state, updateAttachedGestures) {
|
9
|
+
const refHandler = useCallback((ref) => {
|
10
|
+
if (ref === null) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
state.viewRef = ref;
|
14
|
+
// if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
|
15
|
+
if (state.previousViewTag === -1) {
|
16
|
+
state.previousViewTag = findNodeHandle(state.viewRef);
|
17
|
+
}
|
18
|
+
// Pass true as `skipConfigUpdate`. Here we only want to trigger the eventual reattaching of handlers
|
19
|
+
// in case the view has changed. If the view doesn't change, the update will be handled by detector.
|
20
|
+
if (!state.firstRender) {
|
21
|
+
updateAttachedGestures(true);
|
22
|
+
}
|
23
|
+
if (__DEV__ && isFabric() && global.isViewFlatteningDisabled) {
|
24
|
+
const node = getShadowNodeFromRef(ref);
|
25
|
+
if (global.isViewFlatteningDisabled(node) === false) {
|
26
|
+
console.error(tagMessage('GestureDetector has received a child that may get view-flattened. ' +
|
27
|
+
'\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}, [state, updateAttachedGestures]);
|
31
|
+
return refHandler;
|
32
|
+
}
|
@@ -10,4 +10,3 @@ export declare function checkGestureCallbacksForWorklets(gesture: GestureType):
|
|
10
10
|
export declare function validateDetectorChildren(ref: any): void;
|
11
11
|
export declare function useForceRender(): () => void;
|
12
12
|
export declare function useWebEventHandlers(): import("react").RefObject<WebEventHandler>;
|
13
|
-
//# sourceMappingURL=utils.d.ts.map
|