react-native-gesture-handler 2.27.1 → 2.27.2
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/ReanimatedSwipeable/package.json +4 -4
- package/android/build.gradle +8 -1
- 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/apple/RNGestureHandler.h +4 -0
- package/apple/RNGestureHandler.mm +41 -6
- 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/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 +1 -0
- package/lib/commonjs/web/handlers/GestureHandler.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/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 +1 -0
- package/lib/module/web/handlers/GestureHandler.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 +1 -0
- 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/InteractionManager.d.ts +1 -0
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +1 -0
- 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 +1 -1
- 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/mocks/Pressable.tsx +1 -0
- package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
- package/src/web/handlers/GestureHandler.ts +1 -0
- 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,119 +0,0 @@
|
|
1
|
-
/* eslint-disable @eslint-community/eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import Hammer from '@egjs/hammerjs';
|
4
|
-
import { Direction } from './constants';
|
5
|
-
import { GesturePropError } from './Errors';
|
6
|
-
import DraggingGestureHandler from './DraggingGestureHandler';
|
7
|
-
import { isnan } from './utils';
|
8
|
-
class FlingGestureHandler extends DraggingGestureHandler {
|
9
|
-
get name() {
|
10
|
-
return 'swipe';
|
11
|
-
}
|
12
|
-
get NativeGestureClass() {
|
13
|
-
return Hammer.Swipe;
|
14
|
-
}
|
15
|
-
onGestureActivated(event) {
|
16
|
-
this.sendEvent({
|
17
|
-
...event,
|
18
|
-
eventType: Hammer.INPUT_MOVE,
|
19
|
-
isFinal: false,
|
20
|
-
isFirst: true,
|
21
|
-
});
|
22
|
-
this.isGestureRunning = false;
|
23
|
-
this.hasGestureFailed = false;
|
24
|
-
this.sendEvent({
|
25
|
-
...event,
|
26
|
-
eventType: Hammer.INPUT_END,
|
27
|
-
isFinal: true,
|
28
|
-
});
|
29
|
-
}
|
30
|
-
onRawEvent(ev) {
|
31
|
-
super.onRawEvent(ev);
|
32
|
-
if (this.hasGestureFailed) {
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
// Hammer doesn't send a `cancel` event for taps.
|
36
|
-
// Manually fail the event.
|
37
|
-
if (ev.isFinal) {
|
38
|
-
setTimeout(() => {
|
39
|
-
if (this.isGestureRunning) {
|
40
|
-
this.cancelEvent(ev);
|
41
|
-
}
|
42
|
-
});
|
43
|
-
}
|
44
|
-
else if (!this.hasGestureFailed && !this.isGestureRunning) {
|
45
|
-
// Tap Gesture start event
|
46
|
-
const gesture = this.hammer.get(this.name);
|
47
|
-
// @ts-ignore FIXME(TS)
|
48
|
-
if (gesture.options.enable(gesture, ev)) {
|
49
|
-
this.onStart(ev);
|
50
|
-
this.sendEvent(ev);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
getHammerConfig() {
|
55
|
-
return {
|
56
|
-
// @ts-ignore FIXME(TS)
|
57
|
-
pointers: this.config.numberOfPointers,
|
58
|
-
direction: this.getDirection(),
|
59
|
-
};
|
60
|
-
}
|
61
|
-
getTargetDirections(direction) {
|
62
|
-
const directions = [];
|
63
|
-
if (direction & Direction.RIGHT) {
|
64
|
-
directions.push(Hammer.DIRECTION_RIGHT);
|
65
|
-
}
|
66
|
-
if (direction & Direction.LEFT) {
|
67
|
-
directions.push(Hammer.DIRECTION_LEFT);
|
68
|
-
}
|
69
|
-
if (direction & Direction.UP) {
|
70
|
-
directions.push(Hammer.DIRECTION_UP);
|
71
|
-
}
|
72
|
-
if (direction & Direction.DOWN) {
|
73
|
-
directions.push(Hammer.DIRECTION_DOWN);
|
74
|
-
}
|
75
|
-
// const hammerDirection = directions.reduce((a, b) => a | b, 0);
|
76
|
-
return directions;
|
77
|
-
}
|
78
|
-
getDirection() {
|
79
|
-
// @ts-ignore FIXME(TS)
|
80
|
-
const { direction } = this.getConfig();
|
81
|
-
let directions = [];
|
82
|
-
if (direction & Direction.RIGHT) {
|
83
|
-
directions.push(Hammer.DIRECTION_HORIZONTAL);
|
84
|
-
}
|
85
|
-
if (direction & Direction.LEFT) {
|
86
|
-
directions.push(Hammer.DIRECTION_HORIZONTAL);
|
87
|
-
}
|
88
|
-
if (direction & Direction.UP) {
|
89
|
-
directions.push(Hammer.DIRECTION_VERTICAL);
|
90
|
-
}
|
91
|
-
if (direction & Direction.DOWN) {
|
92
|
-
directions.push(Hammer.DIRECTION_VERTICAL);
|
93
|
-
}
|
94
|
-
directions = [...new Set(directions)];
|
95
|
-
if (directions.length === 0)
|
96
|
-
return Hammer.DIRECTION_NONE;
|
97
|
-
if (directions.length === 1)
|
98
|
-
return directions[0];
|
99
|
-
return Hammer.DIRECTION_ALL;
|
100
|
-
}
|
101
|
-
isGestureEnabledForEvent({ numberOfPointers }, _recognizer, { maxPointers: pointerLength }) {
|
102
|
-
const validPointerCount = pointerLength === numberOfPointers;
|
103
|
-
if (!validPointerCount && this.isGestureRunning) {
|
104
|
-
return { failed: true };
|
105
|
-
}
|
106
|
-
return { success: validPointerCount };
|
107
|
-
}
|
108
|
-
updateGestureConfig({ numberOfPointers = 1, direction, ...props }) {
|
109
|
-
if (isnan(direction) || typeof direction !== 'number') {
|
110
|
-
throw new GesturePropError('direction', direction, 'number');
|
111
|
-
}
|
112
|
-
return super.updateGestureConfig({
|
113
|
-
numberOfPointers,
|
114
|
-
direction,
|
115
|
-
...props,
|
116
|
-
});
|
117
|
-
}
|
118
|
-
}
|
119
|
-
export default FlingGestureHandler;
|
@@ -1,469 +0,0 @@
|
|
1
|
-
/* eslint-disable @eslint-community/eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import Hammer from '@egjs/hammerjs';
|
4
|
-
import { findNodeHandle } from 'react-native';
|
5
|
-
import { State } from '../State';
|
6
|
-
import { EventMap } from './constants';
|
7
|
-
import * as NodeManager from './NodeManager';
|
8
|
-
import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
9
|
-
let gestureInstances = 0;
|
10
|
-
class GestureHandler {
|
11
|
-
handlerTag;
|
12
|
-
isGestureRunning = false;
|
13
|
-
view = null;
|
14
|
-
hasCustomActivationCriteria;
|
15
|
-
hasGestureFailed = false;
|
16
|
-
hammer = null;
|
17
|
-
initialRotation = null;
|
18
|
-
__initialX;
|
19
|
-
__initialY;
|
20
|
-
config = {};
|
21
|
-
previousState = State.UNDETERMINED;
|
22
|
-
pendingGestures = {};
|
23
|
-
oldState = State.UNDETERMINED;
|
24
|
-
lastSentState = null;
|
25
|
-
gestureInstance;
|
26
|
-
_stillWaiting;
|
27
|
-
propsRef;
|
28
|
-
ref;
|
29
|
-
get id() {
|
30
|
-
return `${this.name}${this.gestureInstance}`;
|
31
|
-
}
|
32
|
-
// a simple way to check if GestureHandler is NativeViewGestureHandler, since importing it
|
33
|
-
// here to use instanceof would cause import cycle
|
34
|
-
get isNative() {
|
35
|
-
return false;
|
36
|
-
}
|
37
|
-
get isDiscrete() {
|
38
|
-
return false;
|
39
|
-
}
|
40
|
-
get shouldEnableGestureOnSetup() {
|
41
|
-
throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');
|
42
|
-
}
|
43
|
-
constructor() {
|
44
|
-
this.gestureInstance = gestureInstances++;
|
45
|
-
this.hasCustomActivationCriteria = false;
|
46
|
-
}
|
47
|
-
getConfig() {
|
48
|
-
return this.config;
|
49
|
-
}
|
50
|
-
onWaitingEnded(_gesture) { }
|
51
|
-
removePendingGesture(id) {
|
52
|
-
delete this.pendingGestures[id];
|
53
|
-
}
|
54
|
-
addPendingGesture(gesture) {
|
55
|
-
this.pendingGestures[gesture.id] = gesture;
|
56
|
-
}
|
57
|
-
isGestureEnabledForEvent(_config, _recognizer, _event) {
|
58
|
-
return { success: true };
|
59
|
-
}
|
60
|
-
get NativeGestureClass() {
|
61
|
-
throw new Error('Must override GestureHandler.NativeGestureClass');
|
62
|
-
}
|
63
|
-
updateHasCustomActivationCriteria(_config) {
|
64
|
-
return true;
|
65
|
-
}
|
66
|
-
clearSelfAsPending = () => {
|
67
|
-
if (Array.isArray(this.config.waitFor)) {
|
68
|
-
for (const gesture of this.config.waitFor) {
|
69
|
-
gesture.removePendingGesture(this.id);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
};
|
73
|
-
updateGestureConfig({ enabled = true, ...props }) {
|
74
|
-
this.clearSelfAsPending();
|
75
|
-
this.config = this.ensureConfig({ enabled, ...props });
|
76
|
-
this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(this.config);
|
77
|
-
if (Array.isArray(this.config.waitFor)) {
|
78
|
-
for (const gesture of this.config.waitFor) {
|
79
|
-
gesture.addPendingGesture(this);
|
80
|
-
}
|
81
|
-
}
|
82
|
-
if (this.hammer) {
|
83
|
-
this.sync();
|
84
|
-
}
|
85
|
-
return this.config;
|
86
|
-
}
|
87
|
-
destroy = () => {
|
88
|
-
this.clearSelfAsPending();
|
89
|
-
if (this.hammer) {
|
90
|
-
this.hammer.stop(false);
|
91
|
-
this.hammer.destroy();
|
92
|
-
}
|
93
|
-
this.hammer = null;
|
94
|
-
};
|
95
|
-
isPointInView = ({ x, y }) => {
|
96
|
-
// @ts-ignore FIXME(TS)
|
97
|
-
const rect = this.view.getBoundingClientRect();
|
98
|
-
const pointerInside = x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
99
|
-
return pointerInside;
|
100
|
-
};
|
101
|
-
getState(type) {
|
102
|
-
// @ts-ignore TODO(TS) check if this is needed
|
103
|
-
if (type == 0) {
|
104
|
-
return 0;
|
105
|
-
}
|
106
|
-
return EventMap[type];
|
107
|
-
}
|
108
|
-
transformEventData(event) {
|
109
|
-
const { eventType, maxPointers: numberOfPointers } = event;
|
110
|
-
// const direction = DirectionMap[ev.direction];
|
111
|
-
const changedTouch = event.changedPointers[0];
|
112
|
-
const pointerInside = this.isPointInView({
|
113
|
-
x: changedTouch.clientX,
|
114
|
-
y: changedTouch.clientY,
|
115
|
-
});
|
116
|
-
// TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.
|
117
|
-
const state = this.getState(eventType);
|
118
|
-
if (state !== this.previousState) {
|
119
|
-
this.oldState = this.previousState;
|
120
|
-
this.previousState = state;
|
121
|
-
}
|
122
|
-
return {
|
123
|
-
nativeEvent: {
|
124
|
-
numberOfPointers,
|
125
|
-
state,
|
126
|
-
pointerInside,
|
127
|
-
...this.transformNativeEvent(event),
|
128
|
-
// onHandlerStateChange only
|
129
|
-
handlerTag: this.handlerTag,
|
130
|
-
target: this.ref,
|
131
|
-
// send oldState only when the state was changed, or is different than ACTIVE
|
132
|
-
// GestureDetector relies on the presence of `oldState` to differentiate between
|
133
|
-
// update events and state change events
|
134
|
-
oldState: state !== this.previousState || state != 4
|
135
|
-
? this.oldState
|
136
|
-
: undefined,
|
137
|
-
},
|
138
|
-
timeStamp: Date.now(),
|
139
|
-
};
|
140
|
-
}
|
141
|
-
transformNativeEvent(_event) {
|
142
|
-
return {};
|
143
|
-
}
|
144
|
-
sendEvent = (nativeEvent) => {
|
145
|
-
const { onGestureHandlerEvent, onGestureHandlerStateChange } = this.propsRef.current;
|
146
|
-
const event = this.transformEventData(nativeEvent);
|
147
|
-
invokeNullableMethod(onGestureHandlerEvent, event);
|
148
|
-
if (this.lastSentState !== event.nativeEvent.state) {
|
149
|
-
this.lastSentState = event.nativeEvent.state;
|
150
|
-
invokeNullableMethod(onGestureHandlerStateChange, event);
|
151
|
-
}
|
152
|
-
};
|
153
|
-
cancelPendingGestures(event) {
|
154
|
-
for (const gesture of Object.values(this.pendingGestures)) {
|
155
|
-
if (gesture && gesture.isGestureRunning) {
|
156
|
-
gesture.hasGestureFailed = true;
|
157
|
-
gesture.cancelEvent(event);
|
158
|
-
}
|
159
|
-
}
|
160
|
-
}
|
161
|
-
notifyPendingGestures() {
|
162
|
-
for (const gesture of Object.values(this.pendingGestures)) {
|
163
|
-
if (gesture) {
|
164
|
-
gesture.onWaitingEnded(this);
|
165
|
-
}
|
166
|
-
}
|
167
|
-
}
|
168
|
-
// FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input
|
169
|
-
onGestureEnded(event) {
|
170
|
-
this.isGestureRunning = false;
|
171
|
-
this.cancelPendingGestures(event);
|
172
|
-
}
|
173
|
-
forceInvalidate(event) {
|
174
|
-
if (this.isGestureRunning) {
|
175
|
-
this.hasGestureFailed = true;
|
176
|
-
this.cancelEvent(event);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
cancelEvent(event) {
|
180
|
-
this.notifyPendingGestures();
|
181
|
-
this.sendEvent({
|
182
|
-
...event,
|
183
|
-
eventType: Hammer.INPUT_CANCEL,
|
184
|
-
isFinal: true,
|
185
|
-
});
|
186
|
-
this.onGestureEnded(event);
|
187
|
-
}
|
188
|
-
onRawEvent({ isFirst }) {
|
189
|
-
if (isFirst) {
|
190
|
-
this.hasGestureFailed = false;
|
191
|
-
}
|
192
|
-
}
|
193
|
-
shouldUseTouchEvents(config) {
|
194
|
-
return (config.simultaneousHandlers?.some((handler) => handler.isNative) ?? false);
|
195
|
-
}
|
196
|
-
setView(ref, propsRef) {
|
197
|
-
if (ref == null) {
|
198
|
-
this.destroy();
|
199
|
-
this.view = null;
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
// @ts-ignore window doesn't exist on global type as we don't want to use Node types
|
203
|
-
const SUPPORTS_TOUCH = 'ontouchstart' in window;
|
204
|
-
this.propsRef = propsRef;
|
205
|
-
this.ref = ref;
|
206
|
-
// @ts-ignore
|
207
|
-
this.view = findNodeHandle(ref);
|
208
|
-
// When the browser starts handling the gesture (e.g. scrolling), it sends a pointercancel event and stops
|
209
|
-
// sending additional pointer events. This is not the case with touch events, so if the gesture is simultaneous
|
210
|
-
// with a NativeGestureHandler, we need to check if touch events are supported and use them if possible.
|
211
|
-
this.hammer =
|
212
|
-
SUPPORTS_TOUCH && this.shouldUseTouchEvents(this.config)
|
213
|
-
? new Hammer.Manager(this.view, {
|
214
|
-
inputClass: Hammer.TouchInput,
|
215
|
-
})
|
216
|
-
: new Hammer.Manager(this.view);
|
217
|
-
this.oldState = State.UNDETERMINED;
|
218
|
-
this.previousState = State.UNDETERMINED;
|
219
|
-
this.lastSentState = null;
|
220
|
-
const { NativeGestureClass } = this;
|
221
|
-
// @ts-ignore TODO(TS)
|
222
|
-
const gesture = new NativeGestureClass(this.getHammerConfig());
|
223
|
-
this.hammer.add(gesture);
|
224
|
-
this.hammer.on('hammer.input', (ev) => {
|
225
|
-
if (!this.config.enabled) {
|
226
|
-
this.hasGestureFailed = false;
|
227
|
-
this.isGestureRunning = false;
|
228
|
-
return;
|
229
|
-
}
|
230
|
-
this.onRawEvent(ev);
|
231
|
-
// TODO: Bacon: Check against something other than null
|
232
|
-
// The isFirst value is not called when the first rotation is calculated.
|
233
|
-
if (this.initialRotation === null && ev.rotation !== 0) {
|
234
|
-
this.initialRotation = ev.rotation;
|
235
|
-
}
|
236
|
-
if (ev.isFinal) {
|
237
|
-
// in favor of a willFail otherwise the last frame of the gesture will be captured.
|
238
|
-
setTimeout(() => {
|
239
|
-
this.initialRotation = null;
|
240
|
-
this.hasGestureFailed = false;
|
241
|
-
});
|
242
|
-
}
|
243
|
-
});
|
244
|
-
this.setupEvents();
|
245
|
-
this.sync();
|
246
|
-
}
|
247
|
-
setupEvents() {
|
248
|
-
// TODO(TS) Hammer types aren't exactly that what we get in runtime
|
249
|
-
if (!this.isDiscrete) {
|
250
|
-
this.hammer.on(`${this.name}start`, (event) => this.onStart(event));
|
251
|
-
this.hammer.on(`${this.name}end ${this.name}cancel`, (event) => {
|
252
|
-
this.onGestureEnded(event);
|
253
|
-
});
|
254
|
-
}
|
255
|
-
this.hammer.on(this.name, (ev) => this.onGestureActivated(ev)); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged
|
256
|
-
}
|
257
|
-
onStart({ deltaX, deltaY, rotation }) {
|
258
|
-
// Reset the state for the next gesture
|
259
|
-
this.oldState = State.UNDETERMINED;
|
260
|
-
this.previousState = State.UNDETERMINED;
|
261
|
-
this.lastSentState = null;
|
262
|
-
this.isGestureRunning = true;
|
263
|
-
this.__initialX = deltaX;
|
264
|
-
this.__initialY = deltaY;
|
265
|
-
this.initialRotation = rotation;
|
266
|
-
}
|
267
|
-
onGestureActivated(ev) {
|
268
|
-
this.sendEvent(ev);
|
269
|
-
}
|
270
|
-
onSuccess() { }
|
271
|
-
_getPendingGestures() {
|
272
|
-
if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {
|
273
|
-
// Get the list of gestures that this gesture is still waiting for.
|
274
|
-
// Use `=== false` in case a ref that isn't a gesture handler is used.
|
275
|
-
const stillWaiting = this.config.waitFor.filter(({ hasGestureFailed }) => hasGestureFailed === false);
|
276
|
-
return stillWaiting;
|
277
|
-
}
|
278
|
-
return [];
|
279
|
-
}
|
280
|
-
getHammerConfig() {
|
281
|
-
const pointers = this.config.minPointers === this.config.maxPointers
|
282
|
-
? this.config.minPointers
|
283
|
-
: 0;
|
284
|
-
return {
|
285
|
-
pointers,
|
286
|
-
};
|
287
|
-
}
|
288
|
-
sync = () => {
|
289
|
-
const gesture = this.hammer.get(this.name);
|
290
|
-
if (!gesture)
|
291
|
-
return;
|
292
|
-
const enable = (recognizer, inputData) => {
|
293
|
-
if (!this.config.enabled) {
|
294
|
-
this.isGestureRunning = false;
|
295
|
-
this.hasGestureFailed = false;
|
296
|
-
return false;
|
297
|
-
}
|
298
|
-
// Prevent events before the system is ready.
|
299
|
-
if (!inputData ||
|
300
|
-
!recognizer.options ||
|
301
|
-
typeof inputData.maxPointers === 'undefined') {
|
302
|
-
return this.shouldEnableGestureOnSetup;
|
303
|
-
}
|
304
|
-
if (this.hasGestureFailed) {
|
305
|
-
return false;
|
306
|
-
}
|
307
|
-
if (!this.isDiscrete) {
|
308
|
-
if (this.isGestureRunning) {
|
309
|
-
return true;
|
310
|
-
}
|
311
|
-
// The built-in hammer.js "waitFor" doesn't work across multiple views.
|
312
|
-
// Only process if there are views to wait for.
|
313
|
-
this._stillWaiting = this._getPendingGestures();
|
314
|
-
// This gesture should continue waiting.
|
315
|
-
if (this._stillWaiting.length) {
|
316
|
-
// Check to see if one of the gestures you're waiting for has started.
|
317
|
-
// If it has then the gesture should fail.
|
318
|
-
for (const gesture of this._stillWaiting) {
|
319
|
-
// When the target gesture has started, this gesture must force fail.
|
320
|
-
if (!gesture.isDiscrete && gesture.isGestureRunning) {
|
321
|
-
this.hasGestureFailed = true;
|
322
|
-
this.isGestureRunning = false;
|
323
|
-
return false;
|
324
|
-
}
|
325
|
-
}
|
326
|
-
// This gesture shouldn't start until the others have finished.
|
327
|
-
return false;
|
328
|
-
}
|
329
|
-
}
|
330
|
-
// Use default behaviour
|
331
|
-
if (!this.hasCustomActivationCriteria) {
|
332
|
-
return true;
|
333
|
-
}
|
334
|
-
const deltaRotation = this.initialRotation == null
|
335
|
-
? 0
|
336
|
-
: inputData.rotation - this.initialRotation;
|
337
|
-
// @ts-ignore FIXME(TS)
|
338
|
-
const { success, failed } = this.isGestureEnabledForEvent(this.getConfig(), recognizer, {
|
339
|
-
...inputData,
|
340
|
-
deltaRotation,
|
341
|
-
});
|
342
|
-
if (failed) {
|
343
|
-
this.simulateCancelEvent(inputData);
|
344
|
-
this.hasGestureFailed = true;
|
345
|
-
}
|
346
|
-
return success;
|
347
|
-
};
|
348
|
-
const params = this.getHammerConfig();
|
349
|
-
// @ts-ignore FIXME(TS)
|
350
|
-
gesture.set({ ...params, enable });
|
351
|
-
};
|
352
|
-
simulateCancelEvent(_inputData) { }
|
353
|
-
// Validate the props
|
354
|
-
ensureConfig(config) {
|
355
|
-
const props = { ...config };
|
356
|
-
// TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)
|
357
|
-
if ('minDist' in config) {
|
358
|
-
props.minDist = config.minDist;
|
359
|
-
props.minDistSq = props.minDist * props.minDist;
|
360
|
-
}
|
361
|
-
if ('minVelocity' in config) {
|
362
|
-
props.minVelocity = config.minVelocity;
|
363
|
-
props.minVelocitySq = props.minVelocity * props.minVelocity;
|
364
|
-
}
|
365
|
-
if ('maxDist' in config) {
|
366
|
-
props.maxDist = config.maxDist;
|
367
|
-
props.maxDistSq = config.maxDist * config.maxDist;
|
368
|
-
}
|
369
|
-
if ('waitFor' in config) {
|
370
|
-
props.waitFor = asArray(config.waitFor)
|
371
|
-
.map(({ handlerTag }) => NodeManager.getHandler(handlerTag))
|
372
|
-
.filter((v) => v);
|
373
|
-
}
|
374
|
-
else {
|
375
|
-
props.waitFor = null;
|
376
|
-
}
|
377
|
-
if ('simultaneousHandlers' in config) {
|
378
|
-
const shouldUseTouchEvents = this.shouldUseTouchEvents(this.config);
|
379
|
-
props.simultaneousHandlers = asArray(config.simultaneousHandlers)
|
380
|
-
.map((handler) => {
|
381
|
-
if (typeof handler === 'number') {
|
382
|
-
return NodeManager.getHandler(handler);
|
383
|
-
}
|
384
|
-
else {
|
385
|
-
return NodeManager.getHandler(handler.handlerTag);
|
386
|
-
}
|
387
|
-
})
|
388
|
-
.filter((v) => v);
|
389
|
-
if (shouldUseTouchEvents !== this.shouldUseTouchEvents(props)) {
|
390
|
-
ghQueueMicrotask(() => {
|
391
|
-
// if the undelying event API needs to be changed, we need to unmount and mount
|
392
|
-
// the hammer instance again.
|
393
|
-
this.destroy();
|
394
|
-
this.setView(this.ref, this.propsRef);
|
395
|
-
});
|
396
|
-
}
|
397
|
-
}
|
398
|
-
else {
|
399
|
-
props.simultaneousHandlers = null;
|
400
|
-
}
|
401
|
-
const configProps = [
|
402
|
-
'minPointers',
|
403
|
-
'maxPointers',
|
404
|
-
'minDist',
|
405
|
-
'maxDist',
|
406
|
-
'maxDistSq',
|
407
|
-
'minVelocitySq',
|
408
|
-
'minDistSq',
|
409
|
-
'minVelocity',
|
410
|
-
'failOffsetXStart',
|
411
|
-
'failOffsetYStart',
|
412
|
-
'failOffsetXEnd',
|
413
|
-
'failOffsetYEnd',
|
414
|
-
'activeOffsetXStart',
|
415
|
-
'activeOffsetXEnd',
|
416
|
-
'activeOffsetYStart',
|
417
|
-
'activeOffsetYEnd',
|
418
|
-
];
|
419
|
-
configProps.forEach((prop) => {
|
420
|
-
if (typeof props[prop] === 'undefined') {
|
421
|
-
props[prop] = Number.NaN;
|
422
|
-
}
|
423
|
-
});
|
424
|
-
return props; // TODO(TS) how to convince TS that props are filled?
|
425
|
-
}
|
426
|
-
}
|
427
|
-
// TODO(TS) investigate this method
|
428
|
-
// Used for sending data to a callback or AnimatedEvent
|
429
|
-
function invokeNullableMethod(method, event) {
|
430
|
-
if (method) {
|
431
|
-
if (typeof method === 'function') {
|
432
|
-
method(event);
|
433
|
-
}
|
434
|
-
else {
|
435
|
-
// For use with reanimated's AnimatedEvent
|
436
|
-
if ('__getHandler' in method &&
|
437
|
-
typeof method.__getHandler === 'function') {
|
438
|
-
const handler = method.__getHandler();
|
439
|
-
invokeNullableMethod(handler, event);
|
440
|
-
}
|
441
|
-
else {
|
442
|
-
if ('__nodeConfig' in method) {
|
443
|
-
const { argMapping } = method.__nodeConfig;
|
444
|
-
if (Array.isArray(argMapping)) {
|
445
|
-
for (const [index, [key, value]] of argMapping.entries()) {
|
446
|
-
if (key in event.nativeEvent) {
|
447
|
-
// @ts-ignore fix method type
|
448
|
-
const nativeValue = event.nativeEvent[key];
|
449
|
-
if (value && value.setValue) {
|
450
|
-
// Reanimated API
|
451
|
-
value.setValue(nativeValue);
|
452
|
-
}
|
453
|
-
else {
|
454
|
-
// RN Animated API
|
455
|
-
method.__nodeConfig.argMapping[index] = [key, nativeValue];
|
456
|
-
}
|
457
|
-
}
|
458
|
-
}
|
459
|
-
}
|
460
|
-
}
|
461
|
-
}
|
462
|
-
}
|
463
|
-
}
|
464
|
-
}
|
465
|
-
function asArray(value) {
|
466
|
-
// TODO(TS) use config.waitFor type
|
467
|
-
return value == null ? [] : Array.isArray(value) ? value : [value];
|
468
|
-
}
|
469
|
-
export default GestureHandler;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import GestureHandler from './GestureHandler';
|
2
|
-
/**
|
3
|
-
* The base class for **Rotation** and **Pinch** gesture handlers.
|
4
|
-
*/
|
5
|
-
class IndiscreteGestureHandler extends GestureHandler {
|
6
|
-
get shouldEnableGestureOnSetup() {
|
7
|
-
return false;
|
8
|
-
}
|
9
|
-
updateGestureConfig({ minPointers = 2, maxPointers = 2, ...props }) {
|
10
|
-
return super.updateGestureConfig({
|
11
|
-
minPointers,
|
12
|
-
maxPointers,
|
13
|
-
...props,
|
14
|
-
});
|
15
|
-
}
|
16
|
-
isGestureEnabledForEvent({ minPointers, maxPointers }, _recognizer, { maxPointers: pointerLength }) {
|
17
|
-
if (pointerLength > maxPointers) {
|
18
|
-
return { failed: true };
|
19
|
-
}
|
20
|
-
const validPointerCount = pointerLength >= minPointers;
|
21
|
-
return {
|
22
|
-
success: validPointerCount,
|
23
|
-
};
|
24
|
-
}
|
25
|
-
}
|
26
|
-
export default IndiscreteGestureHandler;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/* eslint-disable @eslint-community/eslint-comments/no-unlimited-disable */
|
2
|
-
/* eslint-disable */
|
3
|
-
import Hammer from '@egjs/hammerjs';
|
4
|
-
import { State } from '../State';
|
5
|
-
import PressGestureHandler from './PressGestureHandler';
|
6
|
-
import { isnan, isValidNumber } from './utils';
|
7
|
-
class LongPressGestureHandler extends PressGestureHandler {
|
8
|
-
get minDurationMs() {
|
9
|
-
// @ts-ignore FIXNE(TS)
|
10
|
-
return isnan(this.config.minDurationMs) ? 251 : this.config.minDurationMs;
|
11
|
-
}
|
12
|
-
get maxDist() {
|
13
|
-
// @ts-ignore FIXNE(TS)
|
14
|
-
return isnan(this.config.maxDist) ? 9 : this.config.maxDist;
|
15
|
-
}
|
16
|
-
updateHasCustomActivationCriteria({ maxDistSq }) {
|
17
|
-
return !isValidNumber(maxDistSq);
|
18
|
-
}
|
19
|
-
getConfig() {
|
20
|
-
if (!this.hasCustomActivationCriteria) {
|
21
|
-
// Default config
|
22
|
-
// If no params have been defined then this config should emulate the native gesture as closely as possible.
|
23
|
-
return {
|
24
|
-
shouldCancelWhenOutside: true,
|
25
|
-
maxDistSq: 10,
|
26
|
-
};
|
27
|
-
}
|
28
|
-
return this.config;
|
29
|
-
}
|
30
|
-
getHammerConfig() {
|
31
|
-
return {
|
32
|
-
...super.getHammerConfig(),
|
33
|
-
// threshold: this.maxDist,
|
34
|
-
time: this.minDurationMs,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
getState(type) {
|
38
|
-
return {
|
39
|
-
[Hammer.INPUT_START]: State.ACTIVE,
|
40
|
-
[Hammer.INPUT_MOVE]: State.ACTIVE,
|
41
|
-
[Hammer.INPUT_END]: State.END,
|
42
|
-
[Hammer.INPUT_CANCEL]: State.FAILED,
|
43
|
-
}[type];
|
44
|
-
}
|
45
|
-
}
|
46
|
-
export default LongPressGestureHandler;
|