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,656 +0,0 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
2
|
-
import { State } from '../../State';
|
3
|
-
import { TouchEventType, EventTypes, } from '../interfaces';
|
4
|
-
import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator';
|
5
|
-
import InteractionManager from '../tools/InteractionManager';
|
6
|
-
import PointerTracker from '../tools/PointerTracker';
|
7
|
-
import { MouseButton } from '../../handlers/gestureHandlerCommon';
|
8
|
-
import { PointerType } from '../../PointerType';
|
9
|
-
export default class GestureHandler {
|
10
|
-
lastSentState = null;
|
11
|
-
_state = State.UNDETERMINED;
|
12
|
-
_shouldCancelWhenOutside = false;
|
13
|
-
hasCustomActivationCriteria = false;
|
14
|
-
_enabled = false;
|
15
|
-
viewRef;
|
16
|
-
propsRef;
|
17
|
-
_handlerTag;
|
18
|
-
_config = { enabled: false };
|
19
|
-
_tracker = new PointerTracker();
|
20
|
-
// Orchestrator properties
|
21
|
-
_activationIndex = 0;
|
22
|
-
_awaiting = false;
|
23
|
-
_active = false;
|
24
|
-
_shouldResetProgress = false;
|
25
|
-
_pointerType = PointerType.MOUSE;
|
26
|
-
_delegate;
|
27
|
-
constructor(delegate) {
|
28
|
-
this._delegate = delegate;
|
29
|
-
}
|
30
|
-
//
|
31
|
-
// Initializing handler
|
32
|
-
//
|
33
|
-
init(viewRef, propsRef) {
|
34
|
-
this.propsRef = propsRef;
|
35
|
-
this.viewRef = viewRef;
|
36
|
-
this.state = State.UNDETERMINED;
|
37
|
-
this.delegate.init(viewRef, this);
|
38
|
-
}
|
39
|
-
attachEventManager(manager) {
|
40
|
-
manager.setOnPointerDown(this.onPointerDown.bind(this));
|
41
|
-
manager.setOnPointerAdd(this.onPointerAdd.bind(this));
|
42
|
-
manager.setOnPointerUp(this.onPointerUp.bind(this));
|
43
|
-
manager.setOnPointerRemove(this.onPointerRemove.bind(this));
|
44
|
-
manager.setOnPointerMove(this.onPointerMove.bind(this));
|
45
|
-
manager.setOnPointerEnter(this.onPointerEnter.bind(this));
|
46
|
-
manager.setOnPointerLeave(this.onPointerLeave.bind(this));
|
47
|
-
manager.setOnPointerCancel(this.onPointerCancel.bind(this));
|
48
|
-
manager.setOnPointerOutOfBounds(this.onPointerOutOfBounds.bind(this));
|
49
|
-
manager.setOnPointerMoveOver(this.onPointerMoveOver.bind(this));
|
50
|
-
manager.setOnPointerMoveOut(this.onPointerMoveOut.bind(this));
|
51
|
-
manager.setOnWheel(this.onWheel.bind(this));
|
52
|
-
manager.registerListeners();
|
53
|
-
}
|
54
|
-
//
|
55
|
-
// Resetting handler
|
56
|
-
//
|
57
|
-
onCancel() { }
|
58
|
-
onReset() { }
|
59
|
-
resetProgress() { }
|
60
|
-
reset() {
|
61
|
-
this.tracker.resetTracker();
|
62
|
-
this.onReset();
|
63
|
-
this.resetProgress();
|
64
|
-
this.delegate.reset();
|
65
|
-
this.state = State.UNDETERMINED;
|
66
|
-
}
|
67
|
-
//
|
68
|
-
// State logic
|
69
|
-
//
|
70
|
-
moveToState(newState, sendIfDisabled) {
|
71
|
-
if (this.state === newState) {
|
72
|
-
return;
|
73
|
-
}
|
74
|
-
const oldState = this.state;
|
75
|
-
this.state = newState;
|
76
|
-
if (this.tracker.trackedPointersCount > 0 &&
|
77
|
-
this.config.needsPointerData &&
|
78
|
-
this.isFinished()) {
|
79
|
-
this.cancelTouches();
|
80
|
-
}
|
81
|
-
GestureHandlerOrchestrator.instance.onHandlerStateChange(this, newState, oldState, sendIfDisabled);
|
82
|
-
this.onStateChange(newState, oldState);
|
83
|
-
if (!this.enabled && this.isFinished()) {
|
84
|
-
this.state = State.UNDETERMINED;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
onStateChange(_newState, _oldState) { }
|
88
|
-
begin() {
|
89
|
-
if (!this.checkHitSlop()) {
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
if (this.state === State.UNDETERMINED) {
|
93
|
-
this.moveToState(State.BEGAN);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
/**
|
97
|
-
* @param {boolean} sendIfDisabled - Used when handler becomes disabled. With this flag orchestrator will be forced to send fail event
|
98
|
-
*/
|
99
|
-
fail(sendIfDisabled) {
|
100
|
-
if (this.state === State.ACTIVE || this.state === State.BEGAN) {
|
101
|
-
// Here the order of calling the delegate and moveToState is important.
|
102
|
-
// At this point we can use currentState as previuos state, because immediately after changing cursor we call moveToState method.
|
103
|
-
this.delegate.onFail();
|
104
|
-
this.moveToState(State.FAILED, sendIfDisabled);
|
105
|
-
}
|
106
|
-
this.resetProgress();
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* @param {boolean} sendIfDisabled - Used when handler becomes disabled. With this flag orchestrator will be forced to send cancel event
|
110
|
-
*/
|
111
|
-
cancel(sendIfDisabled) {
|
112
|
-
if (this.state === State.ACTIVE ||
|
113
|
-
this.state === State.UNDETERMINED ||
|
114
|
-
this.state === State.BEGAN) {
|
115
|
-
this.onCancel();
|
116
|
-
// Same as above - order matters
|
117
|
-
this.delegate.onCancel();
|
118
|
-
this.moveToState(State.CANCELLED, sendIfDisabled);
|
119
|
-
}
|
120
|
-
}
|
121
|
-
activate(force = false) {
|
122
|
-
if ((this.config.manualActivation !== true || force) &&
|
123
|
-
(this.state === State.UNDETERMINED || this.state === State.BEGAN)) {
|
124
|
-
this.delegate.onActivate();
|
125
|
-
this.moveToState(State.ACTIVE);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
end() {
|
129
|
-
if (this.state === State.BEGAN || this.state === State.ACTIVE) {
|
130
|
-
// Same as above - order matters
|
131
|
-
this.delegate.onEnd();
|
132
|
-
this.moveToState(State.END);
|
133
|
-
}
|
134
|
-
this.resetProgress();
|
135
|
-
}
|
136
|
-
//
|
137
|
-
// Methods for orchestrator
|
138
|
-
//
|
139
|
-
getShouldResetProgress() {
|
140
|
-
return this.shouldResetProgress;
|
141
|
-
}
|
142
|
-
setShouldResetProgress(value) {
|
143
|
-
this.shouldResetProgress = value;
|
144
|
-
}
|
145
|
-
shouldWaitForHandlerFailure(handler) {
|
146
|
-
if (handler === this) {
|
147
|
-
return false;
|
148
|
-
}
|
149
|
-
return InteractionManager.instance.shouldWaitForHandlerFailure(this, handler);
|
150
|
-
}
|
151
|
-
shouldRequireToWaitForFailure(handler) {
|
152
|
-
if (handler === this) {
|
153
|
-
return false;
|
154
|
-
}
|
155
|
-
return InteractionManager.instance.shouldRequireHandlerToWaitForFailure(this, handler);
|
156
|
-
}
|
157
|
-
shouldRecognizeSimultaneously(handler) {
|
158
|
-
if (handler === this) {
|
159
|
-
return true;
|
160
|
-
}
|
161
|
-
return InteractionManager.instance.shouldRecognizeSimultaneously(this, handler);
|
162
|
-
}
|
163
|
-
shouldBeCancelledByOther(handler) {
|
164
|
-
if (handler === this) {
|
165
|
-
return false;
|
166
|
-
}
|
167
|
-
return InteractionManager.instance.shouldHandlerBeCancelledBy(this, handler);
|
168
|
-
}
|
169
|
-
//
|
170
|
-
// Event actions
|
171
|
-
//
|
172
|
-
onPointerDown(event) {
|
173
|
-
GestureHandlerOrchestrator.instance.recordHandlerIfNotPresent(this);
|
174
|
-
this.pointerType = event.pointerType;
|
175
|
-
if (this.pointerType === PointerType.TOUCH) {
|
176
|
-
GestureHandlerOrchestrator.instance.cancelMouseAndPenGestures(this);
|
177
|
-
}
|
178
|
-
// TODO: Bring back touch events along with introducing `handleDown` method that will handle handler specific stuff
|
179
|
-
}
|
180
|
-
// Adding another pointer to existing ones
|
181
|
-
onPointerAdd(event) {
|
182
|
-
this.tryToSendTouchEvent(event);
|
183
|
-
}
|
184
|
-
onPointerUp(event) {
|
185
|
-
this.tryToSendTouchEvent(event);
|
186
|
-
}
|
187
|
-
// Removing pointer, when there is more than one pointers
|
188
|
-
onPointerRemove(event) {
|
189
|
-
this.tryToSendTouchEvent(event);
|
190
|
-
}
|
191
|
-
onPointerMove(event) {
|
192
|
-
this.tryToSendMoveEvent(false, event);
|
193
|
-
}
|
194
|
-
onPointerLeave(event) {
|
195
|
-
if (this.shouldCancelWhenOutside) {
|
196
|
-
switch (this.state) {
|
197
|
-
case State.ACTIVE:
|
198
|
-
this.cancel();
|
199
|
-
break;
|
200
|
-
case State.BEGAN:
|
201
|
-
this.fail();
|
202
|
-
break;
|
203
|
-
}
|
204
|
-
return;
|
205
|
-
}
|
206
|
-
this.tryToSendTouchEvent(event);
|
207
|
-
}
|
208
|
-
onPointerEnter(event) {
|
209
|
-
this.tryToSendTouchEvent(event);
|
210
|
-
}
|
211
|
-
onPointerCancel(event) {
|
212
|
-
this.tryToSendTouchEvent(event);
|
213
|
-
this.cancel();
|
214
|
-
this.reset();
|
215
|
-
}
|
216
|
-
onPointerOutOfBounds(event) {
|
217
|
-
this.tryToSendMoveEvent(true, event);
|
218
|
-
}
|
219
|
-
onPointerMoveOver(_event) {
|
220
|
-
// Used only by hover gesture handler atm
|
221
|
-
}
|
222
|
-
onPointerMoveOut(_event) {
|
223
|
-
// Used only by hover gesture handler atm
|
224
|
-
}
|
225
|
-
onWheel(_event) {
|
226
|
-
// Used only by pan gesture handler
|
227
|
-
}
|
228
|
-
tryToSendMoveEvent(out, event) {
|
229
|
-
if ((out && this.shouldCancelWhenOutside) || !this.enabled) {
|
230
|
-
return;
|
231
|
-
}
|
232
|
-
if (this.active) {
|
233
|
-
this.sendEvent(this.state, this.state);
|
234
|
-
}
|
235
|
-
this.tryToSendTouchEvent(event);
|
236
|
-
}
|
237
|
-
tryToSendTouchEvent(event) {
|
238
|
-
if (this.config.needsPointerData) {
|
239
|
-
this.sendTouchEvent(event);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
sendTouchEvent(event) {
|
243
|
-
if (!this.enabled) {
|
244
|
-
return;
|
245
|
-
}
|
246
|
-
const { onGestureHandlerEvent } = this.propsRef
|
247
|
-
.current;
|
248
|
-
const touchEvent = this.transformTouchEvent(event);
|
249
|
-
if (touchEvent) {
|
250
|
-
invokeNullableMethod(onGestureHandlerEvent, touchEvent);
|
251
|
-
}
|
252
|
-
}
|
253
|
-
//
|
254
|
-
// Events Sending
|
255
|
-
//
|
256
|
-
sendEvent = (newState, oldState) => {
|
257
|
-
const { onGestureHandlerEvent, onGestureHandlerStateChange } = this.propsRef.current;
|
258
|
-
const resultEvent = this.transformEventData(newState, oldState);
|
259
|
-
// In the new API oldState field has to be undefined, unless we send event state changed
|
260
|
-
// Here the order is flipped to avoid workarounds such as making backup of the state and setting it to undefined first, then changing it back
|
261
|
-
// Flipping order with setting oldState to undefined solves issue, when events were being sent twice instead of once
|
262
|
-
// However, this may cause trouble in the future (but for now we don't know that)
|
263
|
-
if (this.lastSentState !== newState) {
|
264
|
-
this.lastSentState = newState;
|
265
|
-
invokeNullableMethod(onGestureHandlerStateChange, resultEvent);
|
266
|
-
}
|
267
|
-
if (this.state === State.ACTIVE) {
|
268
|
-
resultEvent.nativeEvent.oldState = undefined;
|
269
|
-
invokeNullableMethod(onGestureHandlerEvent, resultEvent);
|
270
|
-
}
|
271
|
-
};
|
272
|
-
transformEventData(newState, oldState) {
|
273
|
-
return {
|
274
|
-
nativeEvent: {
|
275
|
-
numberOfPointers: this.tracker.trackedPointersCount,
|
276
|
-
state: newState,
|
277
|
-
pointerInside: this.delegate.isPointerInBounds(this.tracker.getAbsoluteCoordsAverage()),
|
278
|
-
...this.transformNativeEvent(),
|
279
|
-
handlerTag: this.handlerTag,
|
280
|
-
target: this.viewRef,
|
281
|
-
oldState: newState !== oldState ? oldState : undefined,
|
282
|
-
pointerType: this.pointerType,
|
283
|
-
},
|
284
|
-
timeStamp: Date.now(),
|
285
|
-
};
|
286
|
-
}
|
287
|
-
transformTouchEvent(event) {
|
288
|
-
const rect = this.delegate.measureView();
|
289
|
-
const all = [];
|
290
|
-
const changed = [];
|
291
|
-
const trackerData = this.tracker.trackedPointers;
|
292
|
-
// This if handles edge case where all pointers have been cancelled
|
293
|
-
// When pointercancel is triggered, reset method is called. This means that tracker will be reset after first pointer being cancelled
|
294
|
-
// The problem is, that handler will receive another pointercancel event from the rest of the pointers
|
295
|
-
// To avoid crashing, we don't send event if tracker tracks no pointers, i.e. has been reset
|
296
|
-
if (trackerData.size === 0 || !trackerData.has(event.pointerId)) {
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
trackerData.forEach((element, key) => {
|
300
|
-
const id = this.tracker.getMappedTouchEventId(key);
|
301
|
-
all.push({
|
302
|
-
id: id,
|
303
|
-
x: element.abosoluteCoords.x - rect.pageX,
|
304
|
-
y: element.abosoluteCoords.y - rect.pageY,
|
305
|
-
absoluteX: element.abosoluteCoords.x,
|
306
|
-
absoluteY: element.abosoluteCoords.y,
|
307
|
-
});
|
308
|
-
});
|
309
|
-
// Each pointer sends its own event, so we want changed touches to contain only the pointer that has changed.
|
310
|
-
// However, if the event is cancel, we want to cancel all pointers to avoid crashes
|
311
|
-
if (event.eventType !== EventTypes.CANCEL) {
|
312
|
-
changed.push({
|
313
|
-
id: this.tracker.getMappedTouchEventId(event.pointerId),
|
314
|
-
x: event.x - rect.pageX,
|
315
|
-
y: event.y - rect.pageY,
|
316
|
-
absoluteX: event.x,
|
317
|
-
absoluteY: event.y,
|
318
|
-
});
|
319
|
-
}
|
320
|
-
else {
|
321
|
-
trackerData.forEach((element, key) => {
|
322
|
-
const id = this.tracker.getMappedTouchEventId(key);
|
323
|
-
changed.push({
|
324
|
-
id: id,
|
325
|
-
x: element.abosoluteCoords.x - rect.pageX,
|
326
|
-
y: element.abosoluteCoords.y - rect.pageY,
|
327
|
-
absoluteX: element.abosoluteCoords.x,
|
328
|
-
absoluteY: element.abosoluteCoords.y,
|
329
|
-
});
|
330
|
-
});
|
331
|
-
}
|
332
|
-
let eventType = TouchEventType.UNDETERMINED;
|
333
|
-
switch (event.eventType) {
|
334
|
-
case EventTypes.DOWN:
|
335
|
-
case EventTypes.ADDITIONAL_POINTER_DOWN:
|
336
|
-
eventType = TouchEventType.DOWN;
|
337
|
-
break;
|
338
|
-
case EventTypes.UP:
|
339
|
-
case EventTypes.ADDITIONAL_POINTER_UP:
|
340
|
-
eventType = TouchEventType.UP;
|
341
|
-
break;
|
342
|
-
case EventTypes.MOVE:
|
343
|
-
eventType = TouchEventType.MOVE;
|
344
|
-
break;
|
345
|
-
case EventTypes.CANCEL:
|
346
|
-
eventType = TouchEventType.CANCELLED;
|
347
|
-
break;
|
348
|
-
}
|
349
|
-
// Here, when we receive up event, we want to decrease number of touches
|
350
|
-
// That's because we want handler to send information that there's one pointer less
|
351
|
-
// However, we still want this pointer to be present in allTouches array, so that its data can be accessed
|
352
|
-
let numberOfTouches = all.length;
|
353
|
-
if (event.eventType === EventTypes.UP ||
|
354
|
-
event.eventType === EventTypes.ADDITIONAL_POINTER_UP) {
|
355
|
-
--numberOfTouches;
|
356
|
-
}
|
357
|
-
return {
|
358
|
-
nativeEvent: {
|
359
|
-
handlerTag: this.handlerTag,
|
360
|
-
state: this.state,
|
361
|
-
eventType: eventType,
|
362
|
-
changedTouches: changed,
|
363
|
-
allTouches: all,
|
364
|
-
numberOfTouches: numberOfTouches,
|
365
|
-
pointerType: this.pointerType,
|
366
|
-
},
|
367
|
-
timeStamp: Date.now(),
|
368
|
-
};
|
369
|
-
}
|
370
|
-
cancelTouches() {
|
371
|
-
const rect = this.delegate.measureView();
|
372
|
-
const all = [];
|
373
|
-
const changed = [];
|
374
|
-
const trackerData = this.tracker.trackedPointers;
|
375
|
-
if (trackerData.size === 0) {
|
376
|
-
return;
|
377
|
-
}
|
378
|
-
trackerData.forEach((element, key) => {
|
379
|
-
const id = this.tracker.getMappedTouchEventId(key);
|
380
|
-
all.push({
|
381
|
-
id: id,
|
382
|
-
x: element.abosoluteCoords.x - rect.pageX,
|
383
|
-
y: element.abosoluteCoords.y - rect.pageY,
|
384
|
-
absoluteX: element.abosoluteCoords.x,
|
385
|
-
absoluteY: element.abosoluteCoords.y,
|
386
|
-
});
|
387
|
-
changed.push({
|
388
|
-
id: id,
|
389
|
-
x: element.abosoluteCoords.x - rect.pageX,
|
390
|
-
y: element.abosoluteCoords.y - rect.pageY,
|
391
|
-
absoluteX: element.abosoluteCoords.x,
|
392
|
-
absoluteY: element.abosoluteCoords.y,
|
393
|
-
});
|
394
|
-
});
|
395
|
-
const cancelEvent = {
|
396
|
-
nativeEvent: {
|
397
|
-
handlerTag: this.handlerTag,
|
398
|
-
state: this.state,
|
399
|
-
eventType: TouchEventType.CANCELLED,
|
400
|
-
changedTouches: changed,
|
401
|
-
allTouches: all,
|
402
|
-
numberOfTouches: all.length,
|
403
|
-
pointerType: this.pointerType,
|
404
|
-
},
|
405
|
-
timeStamp: Date.now(),
|
406
|
-
};
|
407
|
-
const { onGestureHandlerEvent } = this.propsRef
|
408
|
-
.current;
|
409
|
-
invokeNullableMethod(onGestureHandlerEvent, cancelEvent);
|
410
|
-
}
|
411
|
-
transformNativeEvent() {
|
412
|
-
// Those properties are shared by most handlers and if not this method will be overriden
|
413
|
-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
|
414
|
-
const lastRelativeCoords = this.tracker.getRelativeCoordsAverage();
|
415
|
-
return {
|
416
|
-
x: lastRelativeCoords.x,
|
417
|
-
y: lastRelativeCoords.y,
|
418
|
-
absoluteX: lastCoords.x,
|
419
|
-
absoluteY: lastCoords.y,
|
420
|
-
};
|
421
|
-
}
|
422
|
-
//
|
423
|
-
// Handling config
|
424
|
-
//
|
425
|
-
updateGestureConfig({ enabled = true, ...props }) {
|
426
|
-
this._config = { enabled: enabled, ...props };
|
427
|
-
this.enabled = enabled;
|
428
|
-
this.delegate.onEnabledChange(enabled);
|
429
|
-
if (this.config.shouldCancelWhenOutside !== undefined) {
|
430
|
-
this.shouldCancelWhenOutside = this.config.shouldCancelWhenOutside;
|
431
|
-
}
|
432
|
-
this.validateHitSlops();
|
433
|
-
if (this.enabled) {
|
434
|
-
return;
|
435
|
-
}
|
436
|
-
switch (this.state) {
|
437
|
-
case State.ACTIVE:
|
438
|
-
this.fail(true);
|
439
|
-
break;
|
440
|
-
case State.UNDETERMINED:
|
441
|
-
GestureHandlerOrchestrator.instance.removeHandlerFromOrchestrator(this);
|
442
|
-
break;
|
443
|
-
default:
|
444
|
-
this.cancel(true);
|
445
|
-
break;
|
446
|
-
}
|
447
|
-
}
|
448
|
-
checkCustomActivationCriteria(criterias) {
|
449
|
-
for (const key in this.config) {
|
450
|
-
if (criterias.indexOf(key) >= 0) {
|
451
|
-
this.hasCustomActivationCriteria = true;
|
452
|
-
}
|
453
|
-
}
|
454
|
-
}
|
455
|
-
validateHitSlops() {
|
456
|
-
if (!this.config.hitSlop) {
|
457
|
-
return;
|
458
|
-
}
|
459
|
-
if (this.config.hitSlop.left !== undefined &&
|
460
|
-
this.config.hitSlop.right !== undefined &&
|
461
|
-
this.config.hitSlop.width !== undefined) {
|
462
|
-
throw new Error('HitSlop Error: Cannot define left, right and width at the same time');
|
463
|
-
}
|
464
|
-
if (this.config.hitSlop.width !== undefined &&
|
465
|
-
this.config.hitSlop.left === undefined &&
|
466
|
-
this.config.hitSlop.right === undefined) {
|
467
|
-
throw new Error('HitSlop Error: When width is defined, either left or right has to be defined');
|
468
|
-
}
|
469
|
-
if (this.config.hitSlop.height !== undefined &&
|
470
|
-
this.config.hitSlop.top !== undefined &&
|
471
|
-
this.config.hitSlop.bottom !== undefined) {
|
472
|
-
throw new Error('HitSlop Error: Cannot define top, bottom and height at the same time');
|
473
|
-
}
|
474
|
-
if (this.config.hitSlop.height !== undefined &&
|
475
|
-
this.config.hitSlop.top === undefined &&
|
476
|
-
this.config.hitSlop.bottom === undefined) {
|
477
|
-
throw new Error('HitSlop Error: When height is defined, either top or bottom has to be defined');
|
478
|
-
}
|
479
|
-
}
|
480
|
-
checkHitSlop() {
|
481
|
-
if (!this.config.hitSlop) {
|
482
|
-
return true;
|
483
|
-
}
|
484
|
-
const { width, height } = this.delegate.measureView();
|
485
|
-
let left = 0;
|
486
|
-
let top = 0;
|
487
|
-
let right = width;
|
488
|
-
let bottom = height;
|
489
|
-
if (this.config.hitSlop.horizontal !== undefined) {
|
490
|
-
left -= this.config.hitSlop.horizontal;
|
491
|
-
right += this.config.hitSlop.horizontal;
|
492
|
-
}
|
493
|
-
if (this.config.hitSlop.vertical !== undefined) {
|
494
|
-
top -= this.config.hitSlop.vertical;
|
495
|
-
bottom += this.config.hitSlop.vertical;
|
496
|
-
}
|
497
|
-
if (this.config.hitSlop.left !== undefined) {
|
498
|
-
left = -this.config.hitSlop.left;
|
499
|
-
}
|
500
|
-
if (this.config.hitSlop.right !== undefined) {
|
501
|
-
right = width + this.config.hitSlop.right;
|
502
|
-
}
|
503
|
-
if (this.config.hitSlop.top !== undefined) {
|
504
|
-
top = -this.config.hitSlop.top;
|
505
|
-
}
|
506
|
-
if (this.config.hitSlop.bottom !== undefined) {
|
507
|
-
bottom = width + this.config.hitSlop.bottom;
|
508
|
-
}
|
509
|
-
if (this.config.hitSlop.width !== undefined) {
|
510
|
-
if (this.config.hitSlop.left !== undefined) {
|
511
|
-
right = left + this.config.hitSlop.width;
|
512
|
-
}
|
513
|
-
else if (this.config.hitSlop.right !== undefined) {
|
514
|
-
left = right - this.config.hitSlop.width;
|
515
|
-
}
|
516
|
-
}
|
517
|
-
if (this.config.hitSlop.height !== undefined) {
|
518
|
-
if (this.config.hitSlop.top !== undefined) {
|
519
|
-
bottom = top + this.config.hitSlop.height;
|
520
|
-
}
|
521
|
-
else if (this.config.hitSlop.bottom !== undefined) {
|
522
|
-
top = bottom - this.config.hitSlop.height;
|
523
|
-
}
|
524
|
-
}
|
525
|
-
const rect = this.delegate.measureView();
|
526
|
-
const lastCoords = this.tracker.getLastAbsoluteCoords();
|
527
|
-
if (!lastCoords) {
|
528
|
-
return false;
|
529
|
-
}
|
530
|
-
const offsetX = lastCoords.x - rect.pageX;
|
531
|
-
const offsetY = lastCoords.y - rect.pageY;
|
532
|
-
return (offsetX >= left && offsetX <= right && offsetY >= top && offsetY <= bottom);
|
533
|
-
}
|
534
|
-
isButtonInConfig(mouseButton) {
|
535
|
-
return (!mouseButton ||
|
536
|
-
(!this.config.mouseButton && mouseButton === MouseButton.LEFT) ||
|
537
|
-
(this.config.mouseButton && mouseButton & this.config.mouseButton));
|
538
|
-
}
|
539
|
-
resetConfig() { }
|
540
|
-
onDestroy() {
|
541
|
-
this.delegate.destroy(this.config);
|
542
|
-
}
|
543
|
-
//
|
544
|
-
// Getters and setters
|
545
|
-
//
|
546
|
-
get handlerTag() {
|
547
|
-
return this._handlerTag;
|
548
|
-
}
|
549
|
-
set handlerTag(value) {
|
550
|
-
this._handlerTag = value;
|
551
|
-
}
|
552
|
-
get config() {
|
553
|
-
return this._config;
|
554
|
-
}
|
555
|
-
get delegate() {
|
556
|
-
return this._delegate;
|
557
|
-
}
|
558
|
-
get tracker() {
|
559
|
-
return this._tracker;
|
560
|
-
}
|
561
|
-
get state() {
|
562
|
-
return this._state;
|
563
|
-
}
|
564
|
-
set state(value) {
|
565
|
-
this._state = value;
|
566
|
-
}
|
567
|
-
get shouldCancelWhenOutside() {
|
568
|
-
return this._shouldCancelWhenOutside;
|
569
|
-
}
|
570
|
-
set shouldCancelWhenOutside(value) {
|
571
|
-
this._shouldCancelWhenOutside = value;
|
572
|
-
}
|
573
|
-
get enabled() {
|
574
|
-
return this._enabled;
|
575
|
-
}
|
576
|
-
set enabled(value) {
|
577
|
-
this._enabled = value;
|
578
|
-
}
|
579
|
-
get pointerType() {
|
580
|
-
return this._pointerType;
|
581
|
-
}
|
582
|
-
set pointerType(value) {
|
583
|
-
this._pointerType = value;
|
584
|
-
}
|
585
|
-
get active() {
|
586
|
-
return this._active;
|
587
|
-
}
|
588
|
-
set active(value) {
|
589
|
-
this._active = value;
|
590
|
-
}
|
591
|
-
get awaiting() {
|
592
|
-
return this._awaiting;
|
593
|
-
}
|
594
|
-
set awaiting(value) {
|
595
|
-
this._awaiting = value;
|
596
|
-
}
|
597
|
-
get activationIndex() {
|
598
|
-
return this._activationIndex;
|
599
|
-
}
|
600
|
-
set activationIndex(value) {
|
601
|
-
this._activationIndex = value;
|
602
|
-
}
|
603
|
-
get shouldResetProgress() {
|
604
|
-
return this._shouldResetProgress;
|
605
|
-
}
|
606
|
-
set shouldResetProgress(value) {
|
607
|
-
this._shouldResetProgress = value;
|
608
|
-
}
|
609
|
-
getTrackedPointersID() {
|
610
|
-
return this.tracker.trackedPointersIDs;
|
611
|
-
}
|
612
|
-
isFinished() {
|
613
|
-
return (this.state === State.END ||
|
614
|
-
this.state === State.FAILED ||
|
615
|
-
this.state === State.CANCELLED);
|
616
|
-
}
|
617
|
-
}
|
618
|
-
function invokeNullableMethod(method, event) {
|
619
|
-
if (!method) {
|
620
|
-
return;
|
621
|
-
}
|
622
|
-
if (typeof method === 'function') {
|
623
|
-
method(event);
|
624
|
-
return;
|
625
|
-
}
|
626
|
-
if ('__getHandler' in method && typeof method.__getHandler === 'function') {
|
627
|
-
const handler = method.__getHandler();
|
628
|
-
invokeNullableMethod(handler, event);
|
629
|
-
return;
|
630
|
-
}
|
631
|
-
if (!('__nodeConfig' in method)) {
|
632
|
-
return;
|
633
|
-
}
|
634
|
-
const { argMapping } = method.__nodeConfig;
|
635
|
-
if (!Array.isArray(argMapping)) {
|
636
|
-
return;
|
637
|
-
}
|
638
|
-
for (const [index, [key, value]] of argMapping.entries()) {
|
639
|
-
if (!(key in event.nativeEvent)) {
|
640
|
-
continue;
|
641
|
-
}
|
642
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
643
|
-
const nativeValue = event.nativeEvent[key];
|
644
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
645
|
-
if (value?.setValue) {
|
646
|
-
// Reanimated API
|
647
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
648
|
-
value.setValue(nativeValue);
|
649
|
-
}
|
650
|
-
else {
|
651
|
-
// RN Animated API
|
652
|
-
method.__nodeConfig.argMapping[index] = [key, nativeValue];
|
653
|
-
}
|
654
|
-
}
|
655
|
-
return;
|
656
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { State } from '../../State';
|
2
|
-
import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator';
|
3
|
-
import GestureHandler from './GestureHandler';
|
4
|
-
export default class HoverGestureHandler extends GestureHandler {
|
5
|
-
stylusData;
|
6
|
-
transformNativeEvent() {
|
7
|
-
return {
|
8
|
-
...super.transformNativeEvent(),
|
9
|
-
stylusData: this.stylusData,
|
10
|
-
};
|
11
|
-
}
|
12
|
-
onPointerMoveOver(event) {
|
13
|
-
GestureHandlerOrchestrator.instance.recordHandlerIfNotPresent(this);
|
14
|
-
this.tracker.addToTracker(event);
|
15
|
-
this.stylusData = event.stylusData;
|
16
|
-
super.onPointerMoveOver(event);
|
17
|
-
if (this.state === State.UNDETERMINED) {
|
18
|
-
this.begin();
|
19
|
-
this.activate();
|
20
|
-
}
|
21
|
-
}
|
22
|
-
onPointerMoveOut(event) {
|
23
|
-
this.tracker.removeFromTracker(event.pointerId);
|
24
|
-
this.stylusData = event.stylusData;
|
25
|
-
super.onPointerMoveOut(event);
|
26
|
-
this.end();
|
27
|
-
}
|
28
|
-
onPointerMove(event) {
|
29
|
-
this.tracker.track(event);
|
30
|
-
this.stylusData = event.stylusData;
|
31
|
-
super.onPointerMove(event);
|
32
|
-
}
|
33
|
-
onPointerCancel(event) {
|
34
|
-
super.onPointerCancel(event);
|
35
|
-
this.reset();
|
36
|
-
}
|
37
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|