react-native-gesture-handler 2.27.1 → 2.28.0
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/RNGestureHandler.podspec +3 -2
- package/ReanimatedSwipeable/package.json +4 -4
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +14 -8
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +10 -5
- package/android/src/main/jni/CMakeLists.txt +5 -0
- package/android/src/main/jni/cpp-adapter.cpp +6 -0
- package/apple/RNGestureHandler.h +4 -0
- package/apple/RNGestureHandler.mm +41 -6
- package/apple/RNGestureHandlerModule.mm +5 -0
- package/jestSetup.js +22 -3
- package/lib/commonjs/components/Pressable/Pressable.js +12 -21
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
- package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
- package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
- package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
- package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
- package/lib/commonjs/components/gestureHandlerRootHOC.js +4 -1
- package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +1 -1
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/mocks/Pressable.js +13 -0
- package/lib/commonjs/mocks/Pressable.js.map +1 -0
- package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
- package/lib/commonjs/mocks/mocks.js.map +1 -0
- package/lib/commonjs/web/handlers/GestureHandler.js +5 -2
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -5
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/KeyboardEventManager.js +34 -8
- package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +14 -23
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/StateMachine.js +8 -2
- package/lib/module/components/Pressable/StateMachine.js.map +1 -1
- package/lib/module/components/Pressable/stateDefinitions.js +21 -22
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
- package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
- package/lib/module/components/gestureHandlerRootHOC.js +5 -0
- package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/handlers/createHandler.js +1 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/mocks/Pressable.js +4 -0
- package/lib/module/mocks/Pressable.js.map +1 -0
- package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
- package/lib/module/mocks/mocks.js.map +1 -0
- package/lib/module/web/handlers/GestureHandler.js +5 -2
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -5
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/KeyboardEventManager.js +34 -8
- package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +1 -0
- package/lib/typescript/Directions.d.ts +1 -0
- package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
- package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
- package/lib/typescript/PlatformConstants.d.ts +1 -0
- package/lib/typescript/PlatformConstants.web.d.ts +1 -0
- package/lib/typescript/PointerType.d.ts +1 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
- package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
- package/lib/typescript/RNRenderer.d.ts +1 -0
- package/lib/typescript/RNRenderer.web.d.ts +1 -0
- package/lib/typescript/State.d.ts +1 -0
- package/lib/typescript/TouchEventType.d.ts +1 -0
- package/lib/typescript/components/DrawerLayout.d.ts +1 -0
- package/lib/typescript/components/GestureButtons.d.ts +1 -0
- package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
- package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
- package/lib/typescript/components/GestureComponents.d.ts +1 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
- package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
- package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
- package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
- package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/index.d.ts +1 -0
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/utils.d.ts +1 -0
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
- package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
- package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
- package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
- package/lib/typescript/components/Swipeable.d.ts +1 -0
- package/lib/typescript/components/Text.d.ts +1 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts +5 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts.map +1 -1
- package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
- package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
- package/lib/typescript/components/touchables/index.d.ts +1 -0
- package/lib/typescript/components/utils.d.ts +1 -0
- package/lib/typescript/findNodeHandle.d.ts +1 -0
- package/lib/typescript/findNodeHandle.web.d.ts +1 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
- package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/createHandler.d.ts +1 -0
- package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
- package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
- package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
- package/lib/typescript/handlers/utils.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/jestUtils/index.d.ts +1 -0
- package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
- package/lib/typescript/mocks/Pressable.d.ts +2 -0
- package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
- package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
- package/lib/typescript/mocks/mocks.d.ts.map +1 -0
- package/lib/typescript/mountRegistry.d.ts +1 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
- package/lib/typescript/typeUtils.d.ts +1 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/Gestures.d.ts +1 -0
- package/lib/typescript/web/constants.d.ts +1 -0
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
- package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
- package/lib/typescript/web/tools/EventManager.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts.map +1 -1
- package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +7 -3
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts.map +1 -1
- package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
- package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
- package/lib/typescript/web/tools/Vector.d.ts +1 -0
- package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
- package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
- package/lib/typescript/web/utils.d.ts +1 -0
- package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/Errors.d.ts +1 -0
- package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
- package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/web_hammer/constants.d.ts +1 -0
- package/lib/typescript/web_hammer/utils.d.ts +1 -0
- package/package.json +4 -3
- package/scripts/gesture_handler_utils.rb +25 -0
- package/src/components/GestureButtonsProps.ts +10 -0
- package/src/components/Pressable/Pressable.tsx +20 -31
- package/src/components/Pressable/PressableProps.tsx +2 -4
- package/src/components/Pressable/StateMachine.tsx +12 -4
- package/src/components/Pressable/stateDefinitions.ts +23 -23
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
- package/src/components/ReanimatedSwipeable/index.ts +6 -0
- package/src/components/gestureHandlerRootHOC.tsx +4 -0
- package/src/handlers/createHandler.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
- package/src/mocks/Pressable.tsx +1 -0
- package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
- package/src/web/handlers/GestureHandler.ts +8 -3
- package/src/web/tools/GestureHandlerWebDelegate.ts +0 -5
- package/src/web/tools/KeyboardEventManager.ts +50 -8
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
- package/lib/commonjs/mocks.js.map +0 -1
- package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
- package/lib/module/mocks.js.map +0 -1
- package/lib/typescript/ActionType.js +0 -6
- package/lib/typescript/Directions.js +0 -18
- package/lib/typescript/EnableNewWebImplementation.js +0 -30
- package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
- package/lib/typescript/PlatformConstants.js +0 -3
- package/lib/typescript/PlatformConstants.web.js +0 -5
- package/lib/typescript/PointerType.js +0 -8
- package/lib/typescript/RNGestureHandlerModule.js +0 -4
- package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
- package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
- package/lib/typescript/RNRenderer.js +0 -3
- package/lib/typescript/RNRenderer.web.js +0 -3
- package/lib/typescript/State.js +0 -9
- package/lib/typescript/TouchEventType.js +0 -7
- package/lib/typescript/components/DrawerLayout.js +0 -417
- package/lib/typescript/components/GestureButtons.js +0 -165
- package/lib/typescript/components/GestureButtonsProps.js +0 -1
- package/lib/typescript/components/GestureComponents.js +0 -67
- package/lib/typescript/components/GestureComponents.web.js +0 -21
- package/lib/typescript/components/GestureHandlerButton.js +0 -2
- package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
- package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
- package/lib/typescript/components/GestureHandlerRootView.js +0 -16
- package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
- package/lib/typescript/components/Pressable/Pressable.js +0 -231
- package/lib/typescript/components/Pressable/PressableProps.js +0 -1
- package/lib/typescript/components/Pressable/StateMachine.js +0 -34
- package/lib/typescript/components/Pressable/index.js +0 -1
- package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
- package/lib/typescript/components/Pressable/utils.js +0 -80
- package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
- package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
- package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
- package/lib/typescript/components/Swipeable.js +0 -287
- package/lib/typescript/components/Text.js +0 -38
- package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
- package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
- package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
- package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
- package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
- package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
- package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
- package/lib/typescript/components/touchables/index.js +0 -4
- package/lib/typescript/components/utils.js +0 -11
- package/lib/typescript/findNodeHandle.js +0 -2
- package/lib/typescript/findNodeHandle.web.js +0 -31
- package/lib/typescript/getShadowNodeFromRef.js +0 -45
- package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
- package/lib/typescript/ghQueueMicrotask.js +0 -7
- package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
- package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
- package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
- package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
- package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
- package/lib/typescript/handlers/PanGestureHandler.js +0 -128
- package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
- package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
- package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
- package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
- package/lib/typescript/handlers/TapGestureHandler.js +0 -26
- package/lib/typescript/handlers/createHandler.js +0 -375
- package/lib/typescript/handlers/createNativeWrapper.js +0 -67
- package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
- package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
- package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
- package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
- package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
- package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
- package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
- package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
- package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
- package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
- package/lib/typescript/handlers/gestures/gesture.js +0 -303
- package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
- package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
- package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
- package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
- package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
- package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
- package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
- package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
- package/lib/typescript/handlers/gestures/panGesture.js +0 -181
- package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
- package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
- package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
- package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
- package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
- package/lib/typescript/handlers/handlersRegistry.js +0 -36
- package/lib/typescript/handlers/utils.js +0 -58
- package/lib/typescript/index.js +0 -28
- package/lib/typescript/init.js +0 -15
- package/lib/typescript/jestUtils/index.js +0 -1
- package/lib/typescript/jestUtils/jestUtils.js +0 -290
- package/lib/typescript/mocks.d.ts.map +0 -1
- package/lib/typescript/mocks.js +0 -59
- package/lib/typescript/mountRegistry.js +0 -29
- package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
- package/lib/typescript/typeUtils.js +0 -1
- package/lib/typescript/utils.js +0 -80
- package/lib/typescript/web/Gestures.js +0 -38
- package/lib/typescript/web/constants.js +0 -2
- package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
- package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
- package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
- package/lib/typescript/web/handlers/GestureHandler.js +0 -656
- package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
- package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
- package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
- package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
- package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
- package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
- package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
- package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
- package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
- package/lib/typescript/web/interfaces.js +0 -25
- package/lib/typescript/web/tools/CircularBuffer.js +0 -37
- package/lib/typescript/web/tools/EventManager.js +0 -85
- package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
- package/lib/typescript/web/tools/InteractionManager.js +0 -91
- package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
- package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
- package/lib/typescript/web/tools/NodeManager.js +0 -28
- package/lib/typescript/web/tools/PointerEventManager.js +0 -179
- package/lib/typescript/web/tools/PointerTracker.js +0 -161
- package/lib/typescript/web/tools/Vector.js +0 -43
- package/lib/typescript/web/tools/VelocityTracker.js +0 -76
- package/lib/typescript/web/tools/WheelEventManager.js +0 -40
- package/lib/typescript/web/utils.js +0 -233
- package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
- package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
- package/lib/typescript/web_hammer/Errors.js +0 -5
- package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
- package/lib/typescript/web_hammer/GestureHandler.js +0 -469
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
- package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
- package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
- package/lib/typescript/web_hammer/NodeManager.js +0 -28
- package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
- package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
- package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
- package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
- package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
- package/lib/typescript/web_hammer/constants.js +0 -42
- package/lib/typescript/web_hammer/utils.js +0 -15
- package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,67 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { useImperativeHandle, useRef } from 'react';
|
3
|
-
import { NativeViewGestureHandler, nativeViewProps, } from './NativeViewGestureHandler';
|
4
|
-
/*
|
5
|
-
* This array should consist of:
|
6
|
-
* - All keys in propTypes from NativeGestureHandler
|
7
|
-
* (and all keys in GestureHandlerPropTypes)
|
8
|
-
* - 'onGestureHandlerEvent'
|
9
|
-
* - 'onGestureHandlerStateChange'
|
10
|
-
*/
|
11
|
-
const NATIVE_WRAPPER_PROPS_FILTER = [
|
12
|
-
...nativeViewProps,
|
13
|
-
'onGestureHandlerEvent',
|
14
|
-
'onGestureHandlerStateChange',
|
15
|
-
];
|
16
|
-
export default function createNativeWrapper(Component, config = {}) {
|
17
|
-
const ComponentWrapper = React.forwardRef((props, ref) => {
|
18
|
-
// Filter out props that should be passed to gesture handler wrapper
|
19
|
-
const { gestureHandlerProps, childProps } = Object.keys(props).reduce((res, key) => {
|
20
|
-
// TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info
|
21
|
-
const allowedKeys = NATIVE_WRAPPER_PROPS_FILTER;
|
22
|
-
if (allowedKeys.includes(key)) {
|
23
|
-
// @ts-ignore FIXME(TS)
|
24
|
-
res.gestureHandlerProps[key] = props[key];
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
// @ts-ignore FIXME(TS)
|
28
|
-
res.childProps[key] = props[key];
|
29
|
-
}
|
30
|
-
return res;
|
31
|
-
}, {
|
32
|
-
gestureHandlerProps: { ...config }, // Watch out not to modify config
|
33
|
-
childProps: {
|
34
|
-
enabled: props.enabled,
|
35
|
-
hitSlop: props.hitSlop,
|
36
|
-
testID: props.testID,
|
37
|
-
},
|
38
|
-
});
|
39
|
-
const _ref = useRef(null);
|
40
|
-
const _gestureHandlerRef = useRef(null);
|
41
|
-
useImperativeHandle(ref,
|
42
|
-
// @ts-ignore TODO(TS) decide how nulls work in this context
|
43
|
-
() => {
|
44
|
-
const node = _gestureHandlerRef.current;
|
45
|
-
// Add handlerTag for relations config
|
46
|
-
if (_ref.current && node) {
|
47
|
-
// @ts-ignore FIXME(TS) think about createHandler return type
|
48
|
-
_ref.current.handlerTag = node.handlerTag;
|
49
|
-
return _ref.current;
|
50
|
-
}
|
51
|
-
return null;
|
52
|
-
}, [_ref, _gestureHandlerRef]);
|
53
|
-
return (<NativeViewGestureHandler {...gestureHandlerProps}
|
54
|
-
// @ts-ignore TODO(TS)
|
55
|
-
ref={_gestureHandlerRef}>
|
56
|
-
<Component {...childProps} ref={_ref}/>
|
57
|
-
</NativeViewGestureHandler>);
|
58
|
-
});
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
60
|
-
ComponentWrapper.displayName =
|
61
|
-
Component?.displayName ||
|
62
|
-
// @ts-ignore if render doesn't exist it will return undefined and go further
|
63
|
-
Component?.render?.name ||
|
64
|
-
(typeof Component === 'string' && Component) ||
|
65
|
-
'ComponentWrapper';
|
66
|
-
return ComponentWrapper;
|
67
|
-
}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
const commonProps = [
|
2
|
-
'id',
|
3
|
-
'enabled',
|
4
|
-
'shouldCancelWhenOutside',
|
5
|
-
'hitSlop',
|
6
|
-
'cancelsTouchesInView',
|
7
|
-
'userSelect',
|
8
|
-
'activeCursor',
|
9
|
-
'mouseButton',
|
10
|
-
'enableContextMenu',
|
11
|
-
'touchAction',
|
12
|
-
];
|
13
|
-
const componentInteractionProps = [
|
14
|
-
'waitFor',
|
15
|
-
'simultaneousHandlers',
|
16
|
-
'blocksHandlers',
|
17
|
-
];
|
18
|
-
export const baseGestureHandlerProps = [
|
19
|
-
...commonProps,
|
20
|
-
...componentInteractionProps,
|
21
|
-
'onBegan',
|
22
|
-
'onFailed',
|
23
|
-
'onCancelled',
|
24
|
-
'onActivated',
|
25
|
-
'onEnded',
|
26
|
-
'onGestureEvent',
|
27
|
-
'onHandlerStateChange',
|
28
|
-
];
|
29
|
-
export const baseGestureHandlerWithDetectorProps = [
|
30
|
-
...commonProps,
|
31
|
-
'needsPointerData',
|
32
|
-
'manualActivation',
|
33
|
-
];
|
34
|
-
export var MouseButton;
|
35
|
-
(function (MouseButton) {
|
36
|
-
MouseButton[MouseButton["LEFT"] = 1] = "LEFT";
|
37
|
-
MouseButton[MouseButton["RIGHT"] = 2] = "RIGHT";
|
38
|
-
MouseButton[MouseButton["MIDDLE"] = 4] = "MIDDLE";
|
39
|
-
MouseButton[MouseButton["BUTTON_4"] = 8] = "BUTTON_4";
|
40
|
-
MouseButton[MouseButton["BUTTON_5"] = 16] = "BUTTON_5";
|
41
|
-
MouseButton[MouseButton["ALL"] = 31] = "ALL";
|
42
|
-
})(MouseButton || (MouseButton = {}));
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Reanimated } from '../reanimatedWrapper';
|
3
|
-
import { tagMessage } from '../../../utils';
|
4
|
-
export class Wrap extends React.Component {
|
5
|
-
render() {
|
6
|
-
try {
|
7
|
-
// I don't think that fighting with types over such a simple function is worth it
|
8
|
-
// The only thing it does is add 'collapsable: false' to the child component
|
9
|
-
// to make sure it is in the native view hierarchy so the detector can find
|
10
|
-
// correct viewTag to attach to.
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
12
|
-
const child = React.Children.only(this.props.children);
|
13
|
-
return React.cloneElement(child, { collapsable: false },
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
15
|
-
child.props.children);
|
16
|
-
}
|
17
|
-
catch (e) {
|
18
|
-
throw new Error(tagMessage(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
export const AnimatedWrap = Reanimated?.default?.createAnimatedComponent(Wrap) ?? Wrap;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import React, { forwardRef } from 'react';
|
2
|
-
import { tagMessage } from '../../../utils';
|
3
|
-
import { isRNSVGNode } from '../../../web/utils';
|
4
|
-
export const Wrap = forwardRef(({ children }, ref) => {
|
5
|
-
try {
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
|
-
const child = React.Children.only(children);
|
8
|
-
if (isRNSVGNode(child)) {
|
9
|
-
const clone = React.cloneElement(child, { ref },
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
11
|
-
child.props.children);
|
12
|
-
return clone;
|
13
|
-
}
|
14
|
-
return (<div ref={ref} style={{ display: 'contents' }}>
|
15
|
-
{child}
|
16
|
-
</div>);
|
17
|
-
}
|
18
|
-
catch (e) {
|
19
|
-
throw new Error(tagMessage(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
|
20
|
-
}
|
21
|
-
});
|
22
|
-
// On web we never take a path with Reanimated,
|
23
|
-
// therefore we can simply export Wrap
|
24
|
-
export const AnimatedWrap = Wrap;
|
@@ -1,55 +0,0 @@
|
|
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
|
-
}
|
@@ -1,12 +0,0 @@
|
|
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
|
-
}
|
@@ -1,114 +0,0 @@
|
|
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
|
-
};
|
@@ -1,18 +0,0 @@
|
|
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
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,54 +0,0 @@
|
|
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
|
-
}
|
@@ -1,137 +0,0 @@
|
|
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
|
-
}
|
@@ -1,48 +0,0 @@
|
|
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
|
-
}
|
@@ -1,35 +0,0 @@
|
|
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
|
-
}
|