react-native-gesture-handler 2.26.0 → 2.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/android/src/main/jni/CMakeLists.txt +7 -26
- package/lib/commonjs/components/Pressable/Pressable.js +139 -188
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/StateMachine.js +38 -0
- package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js +88 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -0
- package/lib/commonjs/components/Pressable/utils.js +1 -1
- package/lib/commonjs/components/Pressable/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js +3 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +3 -0
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +3 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +6 -6
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +24 -33
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +15 -17
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +12 -11
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +1 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +141 -190
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/StateMachine.js +34 -0
- package/lib/module/components/Pressable/StateMachine.js.map +1 -0
- package/lib/module/components/Pressable/stateDefinitions.js +83 -0
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -0
- package/lib/module/components/Pressable/utils.js +1 -1
- package/lib/module/components/Pressable/utils.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +13 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +3 -1
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +3 -0
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +3 -0
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +6 -6
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +24 -33
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +15 -17
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +1 -1
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +12 -11
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/Vector.js +1 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +0 -1
- package/lib/typescript/ActionType.js +6 -0
- package/lib/typescript/Directions.d.ts +0 -1
- package/lib/typescript/Directions.js +18 -0
- package/lib/typescript/EnableNewWebImplementation.d.ts +0 -1
- package/lib/typescript/EnableNewWebImplementation.js +30 -0
- package/lib/typescript/GestureHandlerRootViewContext.d.ts +0 -1
- package/lib/typescript/GestureHandlerRootViewContext.js +2 -0
- package/lib/typescript/PlatformConstants.d.ts +0 -1
- package/lib/typescript/PlatformConstants.js +3 -0
- package/lib/typescript/PlatformConstants.web.d.ts +0 -1
- package/lib/typescript/PlatformConstants.web.js +5 -0
- package/lib/typescript/PointerType.d.ts +0 -1
- package/lib/typescript/PointerType.js +8 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.js +4 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.web.js +92 -0
- package/lib/typescript/RNGestureHandlerModule.windows.d.ts +0 -1
- package/lib/typescript/RNGestureHandlerModule.windows.js +47 -0
- package/lib/typescript/RNRenderer.d.ts +0 -1
- package/lib/typescript/RNRenderer.js +3 -0
- package/lib/typescript/RNRenderer.web.d.ts +0 -1
- package/lib/typescript/RNRenderer.web.js +3 -0
- package/lib/typescript/State.d.ts +0 -1
- package/lib/typescript/State.js +9 -0
- package/lib/typescript/TouchEventType.d.ts +0 -1
- package/lib/typescript/TouchEventType.js +7 -0
- package/lib/typescript/components/DrawerLayout.d.ts +0 -1
- package/lib/typescript/components/DrawerLayout.js +417 -0
- package/lib/typescript/components/GestureButtons.d.ts +0 -1
- package/lib/typescript/components/GestureButtons.js +165 -0
- package/lib/typescript/components/GestureButtonsProps.d.ts +0 -1
- package/lib/typescript/components/GestureButtonsProps.js +1 -0
- package/lib/typescript/components/GestureComponents.d.ts +0 -1
- package/lib/typescript/components/GestureComponents.js +67 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +0 -1
- package/lib/typescript/components/GestureComponents.web.js +21 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerButton.js +2 -0
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerButton.web.js +3 -0
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.android.js +17 -0
- package/lib/typescript/components/GestureHandlerRootView.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.js +16 -0
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +0 -1
- package/lib/typescript/components/GestureHandlerRootView.web.js +11 -0
- package/lib/typescript/components/Pressable/Pressable.d.ts +1 -3
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/Pressable.js +231 -0
- package/lib/typescript/components/Pressable/PressableProps.d.ts +15 -2
- package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/PressableProps.js +1 -0
- package/lib/typescript/components/Pressable/StateMachine.d.ts +14 -0
- package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -0
- package/lib/typescript/components/Pressable/StateMachine.js +34 -0
- package/lib/typescript/components/Pressable/index.d.ts +0 -1
- package/lib/typescript/components/Pressable/index.js +1 -0
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts +9 -0
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -0
- package/lib/typescript/components/Pressable/stateDefinitions.js +104 -0
- package/lib/typescript/components/Pressable/utils.d.ts +3 -7
- package/lib/typescript/components/Pressable/utils.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/utils.js +80 -0
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +0 -1
- package/lib/typescript/components/ReanimatedDrawerLayout.js +364 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +0 -1
- package/lib/typescript/components/ReanimatedSwipeable.js +400 -0
- package/lib/typescript/components/Swipeable.d.ts +0 -1
- package/lib/typescript/components/Swipeable.js +287 -0
- package/lib/typescript/components/Text.d.ts +0 -1
- package/lib/typescript/components/Text.js +38 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts +0 -1
- package/lib/typescript/components/gestureHandlerRootHOC.js +18 -0
- package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +0 -1
- package/lib/typescript/components/touchables/ExtraButtonProps.js +1 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -1
- package/lib/typescript/components/touchables/GenericTouchable.js +221 -0
- package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +0 -1
- package/lib/typescript/components/touchables/GenericTouchableProps.js +1 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableHighlight.js +75 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +65 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.js +6 -0
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableOpacity.js +51 -0
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/typescript/components/touchables/index.d.ts +0 -1
- package/lib/typescript/components/touchables/index.js +4 -0
- package/lib/typescript/components/utils.d.ts +0 -1
- package/lib/typescript/components/utils.js +11 -0
- package/lib/typescript/findNodeHandle.d.ts +0 -1
- package/lib/typescript/findNodeHandle.js +2 -0
- package/lib/typescript/findNodeHandle.web.d.ts +0 -1
- package/lib/typescript/findNodeHandle.web.js +31 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.js +45 -0
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.web.js +7 -0
- package/lib/typescript/ghQueueMicrotask.d.ts +0 -1
- package/lib/typescript/ghQueueMicrotask.js +7 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/FlingGestureHandler.js +19 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/ForceTouchGestureHandler.js +37 -0
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +3 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts.map +1 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.js +1 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/LongPressGestureHandler.js +22 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/NativeViewGestureHandler.js +20 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/PanGestureHandler.js +128 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/PinchGestureHandler.js +12 -0
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.js +2 -0
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.web.js +4 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/RotationGestureHandler.js +12 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/handlers/TapGestureHandler.js +26 -0
- package/lib/typescript/handlers/createHandler.d.ts +0 -1
- package/lib/typescript/handlers/createHandler.js +375 -0
- package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -1
- package/lib/typescript/handlers/createNativeWrapper.js +67 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.js +2 -0
- package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.web.js +4 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -1
- package/lib/typescript/handlers/gestureHandlerCommon.js +42 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +9 -1
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts.map +1 -1
- package/lib/typescript/handlers/gestureHandlerTypesCompat.js +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +22 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +24 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +55 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
- package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/index.js +114 -0
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/types.js +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +54 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +137 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +48 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +35 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +32 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector/utils.js +140 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +0 -1
- package/lib/typescript/handlers/gestures/eventReceiver.js +105 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/flingGesture.js +27 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +9 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.js +57 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gesture.js +303 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureComposition.js +78 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +3 -2
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureObjects.js +125 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.js +60 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +0 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.web.js +19 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/hoverGesture.js +45 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/longPressGesture.js +35 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/manualGesture.js +16 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/nativeGesture.js +24 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/panGesture.js +181 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/pinchGesture.js +27 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +0 -1
- package/lib/typescript/handlers/gestures/reanimatedWrapper.js +23 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/rotationGesture.js +27 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +0 -1
- package/lib/typescript/handlers/gestures/tapGesture.js +72 -0
- package/lib/typescript/handlers/getNextHandlerTag.d.ts +0 -1
- package/lib/typescript/handlers/getNextHandlerTag.js +4 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +0 -1
- package/lib/typescript/handlers/handlersRegistry.js +36 -0
- package/lib/typescript/handlers/utils.d.ts +0 -1
- package/lib/typescript/handlers/utils.js +58 -0
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.js +28 -0
- package/lib/typescript/init.d.ts +0 -1
- package/lib/typescript/init.js +15 -0
- package/lib/typescript/jestUtils/index.d.ts +0 -1
- package/lib/typescript/jestUtils/index.js +1 -0
- package/lib/typescript/jestUtils/jestUtils.d.ts +0 -1
- package/lib/typescript/jestUtils/jestUtils.js +290 -0
- package/lib/typescript/mocks.d.ts +0 -1
- package/lib/typescript/mocks.js +59 -0
- package/lib/typescript/mountRegistry.d.ts +0 -1
- package/lib/typescript/mountRegistry.js +29 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +0 -1
- package/lib/typescript/specs/NativeRNGestureHandlerModule.js +2 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +0 -1
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +2 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +0 -1
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +2 -0
- package/lib/typescript/typeUtils.d.ts +0 -1
- package/lib/typescript/typeUtils.js +1 -0
- package/lib/typescript/utils.d.ts +0 -1
- package/lib/typescript/utils.js +80 -0
- package/lib/typescript/web/Gestures.d.ts +0 -1
- package/lib/typescript/web/Gestures.js +38 -0
- package/lib/typescript/web/constants.d.ts +0 -1
- package/lib/typescript/web/constants.js +2 -0
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +0 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
- package/lib/typescript/web/detectors/RotationGestureDetector.js +122 -0
- package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +0 -1
- package/lib/typescript/web/detectors/ScaleGestureDetector.js +117 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.js +133 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/GestureHandler.js +656 -0
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.js +37 -0
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/IGestureHandler.js +1 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/LongPressGestureHandler.js +136 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/ManualGestureHandler.js +29 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/NativeViewGestureHandler.js +133 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +2 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/PanGestureHandler.js +420 -0
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PinchGestureHandler.js +117 -0
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/RotationGestureHandler.js +122 -0
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -1
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/handlers/TapGestureHandler.js +202 -0
- package/lib/typescript/web/interfaces.d.ts +0 -1
- package/lib/typescript/web/interfaces.js +25 -0
- package/lib/typescript/web/tools/CircularBuffer.d.ts +0 -1
- package/lib/typescript/web/tools/CircularBuffer.js +37 -0
- package/lib/typescript/web/tools/EventManager.d.ts +0 -1
- package/lib/typescript/web/tools/EventManager.js +85 -0
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerDelegate.js +1 -0
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +273 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +0 -1
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +169 -0
- package/lib/typescript/web/tools/InteractionManager.d.ts +0 -1
- package/lib/typescript/web/tools/InteractionManager.js +91 -0
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/KeyboardEventManager.js +73 -0
- package/lib/typescript/web/tools/LeastSquareSolver.d.ts +0 -1
- package/lib/typescript/web/tools/LeastSquareSolver.js +147 -0
- package/lib/typescript/web/tools/NodeManager.d.ts +0 -1
- package/lib/typescript/web/tools/NodeManager.js +28 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/PointerEventManager.js +179 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +3 -4
- package/lib/typescript/web/tools/PointerTracker.d.ts.map +1 -1
- package/lib/typescript/web/tools/PointerTracker.js +161 -0
- package/lib/typescript/web/tools/Vector.d.ts +1 -2
- package/lib/typescript/web/tools/Vector.js +43 -0
- package/lib/typescript/web/tools/VelocityTracker.d.ts +0 -1
- package/lib/typescript/web/tools/VelocityTracker.js +76 -0
- package/lib/typescript/web/tools/WheelEventManager.d.ts +0 -1
- package/lib/typescript/web/tools/WheelEventManager.js +40 -0
- package/lib/typescript/web/utils.d.ts +0 -1
- package/lib/typescript/web/utils.js +233 -0
- package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/DiscreteGestureHandler.js +48 -0
- package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/DraggingGestureHandler.js +25 -0
- package/lib/typescript/web_hammer/Errors.d.ts +0 -1
- package/lib/typescript/web_hammer/Errors.js +5 -0
- package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/FlingGestureHandler.js +119 -0
- package/lib/typescript/web_hammer/GestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/GestureHandler.js +469 -0
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +26 -0
- package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/LongPressGestureHandler.js +46 -0
- package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/NativeViewGestureHandler.js +40 -0
- package/lib/typescript/web_hammer/NodeManager.d.ts +0 -1
- package/lib/typescript/web_hammer/NodeManager.js +28 -0
- package/lib/typescript/web_hammer/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PanGestureHandler.js +151 -0
- package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PinchGestureHandler.js +19 -0
- package/lib/typescript/web_hammer/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/PressGestureHandler.js +133 -0
- package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/RotationGestureHandler.js +20 -0
- package/lib/typescript/web_hammer/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/web_hammer/TapGestureHandler.js +142 -0
- package/lib/typescript/web_hammer/constants.d.ts +0 -1
- package/lib/typescript/web_hammer/constants.js +42 -0
- package/lib/typescript/web_hammer/utils.d.ts +0 -1
- package/lib/typescript/web_hammer/utils.js +15 -0
- package/package.json +4 -2
- package/src/components/Pressable/Pressable.tsx +357 -445
- package/src/components/Pressable/PressableProps.tsx +15 -0
- package/src/components/Pressable/StateMachine.tsx +49 -0
- package/src/components/Pressable/stateDefinitions.ts +125 -0
- package/src/components/Pressable/utils.ts +11 -7
- package/src/handlers/GestureHandlerEventPayload.ts +3 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +9 -0
- package/src/handlers/gestures/forceTouchGesture.ts +9 -0
- package/src/handlers/gestures/gestureObjects.ts +3 -1
- package/src/web/detectors/RotationGestureDetector.ts +4 -0
- package/src/web/handlers/FlingGestureHandler.ts +4 -0
- package/src/web/handlers/GestureHandler.ts +9 -3
- package/src/web/handlers/PanGestureHandler.ts +25 -36
- package/src/web/handlers/TapGestureHandler.ts +14 -19
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -0
- package/src/web/tools/PointerEventManager.ts +1 -1
- package/src/web/tools/PointerTracker.ts +17 -15
- package/src/web/tools/Vector.ts +1 -1
@@ -0,0 +1,469 @@
|
|
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;
|
@@ -0,0 +1,26 @@
|
|
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;
|
@@ -0,0 +1,46 @@
|
|
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;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import DiscreteGestureHandler from './DiscreteGestureHandler';
|
2
|
+
import * as NodeManager from './NodeManager';
|
3
|
+
import PressGestureHandler from './PressGestureHandler';
|
4
|
+
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
5
|
+
class NativeViewGestureHandler extends PressGestureHandler {
|
6
|
+
get isNative() {
|
7
|
+
return true;
|
8
|
+
}
|
9
|
+
onRawEvent(ev) {
|
10
|
+
super.onRawEvent(ev);
|
11
|
+
if (!ev.isFinal) {
|
12
|
+
// if (this.ref instanceof ScrollView) {
|
13
|
+
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
|
14
|
+
// @ts-ignore FIXME(TS) config type
|
15
|
+
if (this.config.disallowInterruption) {
|
16
|
+
const gestures = Object.values(NodeManager.getNodes()).filter((gesture) => {
|
17
|
+
const { handlerTag, view, isGestureRunning } = gesture;
|
18
|
+
return (
|
19
|
+
// Check if this gesture isn't self
|
20
|
+
handlerTag !== this.handlerTag &&
|
21
|
+
// Ensure the gesture needs to be cancelled
|
22
|
+
isGestureRunning &&
|
23
|
+
// ScrollView can cancel discrete gestures like taps and presses
|
24
|
+
gesture instanceof DiscreteGestureHandler &&
|
25
|
+
// Ensure a view exists and is a child of the current view
|
26
|
+
view &&
|
27
|
+
// @ts-ignore FIXME(TS) view type
|
28
|
+
this.view.contains(view));
|
29
|
+
});
|
30
|
+
// Cancel all of the gestures that passed the filter
|
31
|
+
for (const gesture of gestures) {
|
32
|
+
// TODO: Bacon: Send some cached event.
|
33
|
+
gesture.forceInvalidate(ev);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
export default NativeViewGestureHandler;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export const gestures = {};
|
2
|
+
export function getHandler(tag) {
|
3
|
+
if (tag in gestures) {
|
4
|
+
return gestures[tag];
|
5
|
+
}
|
6
|
+
throw new Error(`No handler for tag ${tag}`);
|
7
|
+
}
|
8
|
+
export function createGestureHandler(handlerTag, handler) {
|
9
|
+
if (handlerTag in gestures) {
|
10
|
+
throw new Error(`Handler with tag ${handlerTag} already exists`);
|
11
|
+
}
|
12
|
+
gestures[handlerTag] = handler;
|
13
|
+
// @ts-ignore no types for web handlers yet
|
14
|
+
gestures[handlerTag].handlerTag = handlerTag;
|
15
|
+
}
|
16
|
+
export function dropGestureHandler(handlerTag) {
|
17
|
+
// Since React 18, there are cases where componentWillUnmount gets called twice in a row
|
18
|
+
// so skip this if the tag was already removed.
|
19
|
+
if (!(handlerTag in gestures)) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
getHandler(handlerTag).destroy();
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
24
|
+
delete gestures[handlerTag];
|
25
|
+
}
|
26
|
+
export function getNodes() {
|
27
|
+
return { ...gestures };
|
28
|
+
}
|