react-native-gesture-handler 2.17.1 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReanimatedSwipeable/package.json +6 -0
- package/android/build.gradle +0 -103
- package/android/gradle.properties +0 -7
- package/android/paper/src/main/java/com/swmansion/gesturehandler/NativeRNGestureHandlerModuleSpec.java +22 -10
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +7 -8
- package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +14 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +3 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +3 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +2 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +8 -7
- package/android/src/main/jni/cpp-adapter.cpp +5 -3
- package/apple/Handlers/RNFlingHandler.m +1 -0
- package/apple/Handlers/RNForceTouchHandler.m +2 -0
- package/apple/Handlers/RNLongPressHandler.m +2 -1
- package/apple/Handlers/RNManualHandler.m +1 -0
- package/apple/Handlers/RNNativeViewHandler.mm +31 -27
- package/apple/Handlers/RNPanHandler.m +1 -0
- package/apple/Handlers/RNPinchHandler.m +1 -0
- package/apple/Handlers/RNRotationHandler.m +1 -0
- package/apple/Handlers/RNTapHandler.m +1 -0
- package/apple/RNGestureHandlerModule.mm +3 -2
- package/apple/RNRootViewGestureRecognizer.m +5 -0
- package/lib/commonjs/Directions.js +2 -2
- package/lib/commonjs/Directions.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +2 -2
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js +3 -3
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureButtonsProps.js +6 -0
- package/lib/commonjs/components/GestureButtonsProps.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +1 -1
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.android.js +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +334 -0
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -0
- package/lib/commonjs/components/Pressable/PressableProps.js +6 -0
- package/lib/commonjs/components/Pressable/PressableProps.js.map +1 -0
- package/lib/commonjs/components/Pressable/index.js +24 -0
- package/lib/commonjs/components/Pressable/index.js.map +1 -0
- package/lib/commonjs/components/Pressable/utils.js +136 -0
- package/lib/commonjs/components/Pressable/utils.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js +317 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +3 -3
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +4 -4
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchableProps.js +6 -0
- package/lib/commonjs/components/touchables/GenericTouchableProps.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedbackProps.js +6 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedbackProps.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +2 -2
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/ghQueueMicrotask.js +3 -4
- package/lib/commonjs/ghQueueMicrotask.js.map +1 -1
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/GestureHandlerEventPayload.js +2 -0
- package/lib/commonjs/handlers/GestureHandlerEventPayload.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +21 -19
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +3 -3
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -86
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +9 -9
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +2 -2
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.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/handlers/gestures/GestureDetector/updateHandlers.js +21 -31
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +5 -5
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +7 -7
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js +5 -5
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/commonjs/handlers/getNextHandlerTag.js +12 -0
- package/lib/commonjs/handlers/getNextHandlerTag.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +0 -6
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
- package/lib/commonjs/handlers/utils.js +91 -0
- package/lib/commonjs/handlers/utils.js.map +1 -0
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +1 -1
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils/jestUtils.js +2 -2
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
- package/lib/commonjs/mocks.js +2 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/Gestures.js +1 -1
- package/lib/commonjs/web/Gestures.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +4 -4
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +6 -11
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js +2 -2
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +4 -11
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/LeastSquareSolver.js +18 -18
- package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +2 -2
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +4 -4
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js +6 -6
- package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -1
- package/lib/commonjs/web_hammer/NodeManager.js +2 -0
- package/lib/commonjs/web_hammer/NodeManager.js.map +1 -1
- package/lib/module/Directions.js +2 -2
- package/lib/module/Directions.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +2 -2
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +2 -2
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js +3 -3
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureButtonsProps.js +2 -0
- package/lib/module/components/GestureButtonsProps.js.map +1 -0
- package/lib/module/components/GestureComponents.js +1 -1
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js +1 -1
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +309 -0
- package/lib/module/components/Pressable/Pressable.js.map +1 -0
- package/lib/module/components/Pressable/PressableProps.js +2 -0
- package/lib/module/components/Pressable/PressableProps.js.map +1 -0
- package/lib/module/components/Pressable/index.js +3 -0
- package/lib/module/components/Pressable/index.js.map +1 -0
- package/lib/module/components/Pressable/utils.js +120 -0
- package/lib/module/components/Pressable/utils.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable.js +293 -0
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -0
- package/lib/module/components/Swipeable.js +3 -3
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +4 -4
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchableProps.js +2 -0
- package/lib/module/components/touchables/GenericTouchableProps.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedbackProps.js +2 -0
- package/lib/module/components/touchables/TouchableNativeFeedbackProps.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +2 -2
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/ghQueueMicrotask.js +3 -4
- package/lib/module/ghQueueMicrotask.js.map +1 -1
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/GestureHandlerEventPayload.js +2 -0
- package/lib/module/handlers/GestureHandlerEventPayload.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +6 -5
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/createNativeWrapper.js +3 -3
- package/lib/module/handlers/createNativeWrapper.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +0 -72
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +4 -4
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.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/handlers/gestures/GestureDetector/updateHandlers.js +18 -28
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +5 -5
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +6 -6
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureComposition.js +5 -5
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/handlers/getNextHandlerTag.js +5 -0
- package/lib/module/handlers/getNextHandlerTag.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +0 -4
- package/lib/module/handlers/handlersRegistry.js.map +1 -1
- package/lib/module/handlers/utils.js +73 -0
- package/lib/module/handlers/utils.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +1 -1
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils/jestUtils.js +2 -2
- package/lib/module/jestUtils/jestUtils.js.map +1 -1
- package/lib/module/mocks.js +2 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/Gestures.js +1 -1
- package/lib/module/web/Gestures.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +4 -4
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +6 -11
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/EventManager.js +2 -2
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +4 -11
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/LeastSquareSolver.js +18 -18
- package/lib/module/web/tools/LeastSquareSolver.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +2 -2
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +1 -1
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +4 -4
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/VelocityTracker.js +6 -6
- package/lib/module/web/tools/VelocityTracker.js.map +1 -1
- package/lib/module/web_hammer/NodeManager.js +1 -1
- package/lib/module/web_hammer/NodeManager.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +2 -85
- package/lib/typescript/components/GestureButtonsProps.d.ts +99 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +1 -1
- package/lib/typescript/components/Pressable/Pressable.d.ts +3 -0
- package/lib/typescript/components/Pressable/PressableProps.d.ts +116 -0
- package/lib/typescript/components/Pressable/index.d.ts +2 -0
- package/lib/typescript/components/Pressable/utils.d.ts +15 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +125 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +4 -16
- package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +14 -0
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -1
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +2 -9
- package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +9 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +2 -1
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -10
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +159 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -35
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/PanGestureHandler.d.ts +3 -51
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +2 -23
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +2 -23
- package/lib/typescript/handlers/TapGestureHandler.d.ts +2 -6
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -5
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +10 -9
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -8
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +2 -1
- package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -2
- package/lib/typescript/handlers/utils.d.ts +6 -0
- package/lib/typescript/index.d.ts +12 -9
- package/lib/typescript/jestUtils/jestUtils.d.ts +9 -7
- 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/HoverGestureHandler.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_hammer/NodeManager.d.ts +4 -5
- package/package.json +14 -16
- package/src/Directions.ts +2 -2
- package/src/RNGestureHandlerModule.web.ts +2 -2
- package/src/components/DrawerLayout.tsx +7 -9
- package/src/components/GestureButtons.tsx +13 -123
- package/src/components/GestureButtonsProps.ts +115 -0
- package/src/components/GestureComponents.tsx +1 -1
- package/src/components/GestureHandlerButton.tsx +1 -1
- package/src/components/GestureHandlerRootView.android.tsx +1 -1
- package/src/components/GestureHandlerRootView.tsx +1 -1
- package/src/components/Pressable/Pressable.tsx +398 -0
- package/src/components/Pressable/PressableProps.tsx +149 -0
- package/src/components/Pressable/index.ts +2 -0
- package/src/components/Pressable/utils.ts +180 -0
- package/src/components/ReanimatedSwipeable.tsx +629 -0
- package/src/components/Swipeable.tsx +6 -6
- package/src/components/touchables/GenericTouchable.tsx +9 -36
- package/src/components/touchables/GenericTouchableProps.ts +26 -0
- package/src/components/touchables/TouchableHighlight.tsx +2 -4
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +7 -17
- package/src/components/touchables/TouchableNativeFeedbackProps.tsx +12 -0
- package/src/components/touchables/TouchableOpacity.tsx +3 -5
- package/src/components/touchables/TouchableWithoutFeedback.tsx +2 -1
- package/src/getShadowNodeFromRef.ts +2 -2
- package/src/ghQueueMicrotask.ts +7 -4
- package/src/handlers/FlingGestureHandler.ts +1 -6
- package/src/handlers/ForceTouchGestureHandler.ts +1 -12
- package/src/handlers/GestureHandlerEventPayload.ts +184 -0
- package/src/handlers/LongPressGestureHandler.ts +1 -40
- package/src/handlers/NativeViewGestureHandler.ts +1 -7
- package/src/handlers/PanGestureHandler.ts +1 -58
- package/src/handlers/PinchGestureHandler.ts +1 -27
- package/src/handlers/RotationGestureHandler.ts +1 -27
- package/src/handlers/TapGestureHandler.ts +1 -6
- package/src/handlers/createHandler.tsx +6 -11
- package/src/handlers/createNativeWrapper.tsx +3 -3
- package/src/handlers/gestureHandlerCommon.ts +3 -79
- package/src/handlers/gestureHandlerTypesCompat.ts +16 -30
- package/src/handlers/gestures/GestureDetector/Wrap.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +4 -7
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +1 -1
- package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +20 -30
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
- package/src/handlers/gestures/GestureDetector/utils.ts +5 -5
- package/src/handlers/gestures/flingGesture.ts +2 -4
- package/src/handlers/gestures/forceTouchGesture.ts +2 -4
- package/src/handlers/gestures/gesture.ts +17 -15
- package/src/handlers/gestures/gestureComposition.ts +5 -5
- package/src/handlers/gestures/gestureStateManager.ts +1 -1
- package/src/handlers/gestures/longPressGesture.ts +2 -4
- package/src/handlers/gestures/nativeGesture.ts +2 -4
- package/src/handlers/gestures/panGesture.ts +2 -4
- package/src/handlers/gestures/pinchGesture.ts +1 -1
- package/src/handlers/gestures/rotationGesture.ts +1 -1
- package/src/handlers/gestures/tapGesture.ts +2 -4
- package/src/handlers/getNextHandlerTag.ts +5 -0
- package/src/handlers/handlersRegistry.ts +0 -6
- package/src/handlers/utils.ts +75 -0
- package/src/index.ts +25 -36
- package/src/init.ts +1 -1
- package/src/jestUtils/jestUtils.ts +12 -10
- package/src/mocks.ts +2 -2
- package/src/utils.ts +1 -1
- package/src/web/Gestures.ts +1 -1
- package/src/web/detectors/RotationGestureDetector.ts +1 -1
- package/src/web/detectors/ScaleGestureDetector.ts +4 -4
- package/src/web/handlers/FlingGestureHandler.ts +1 -1
- package/src/web/handlers/GestureHandler.ts +8 -14
- package/src/web/handlers/NativeViewGestureHandler.ts +3 -3
- package/src/web/handlers/PanGestureHandler.ts +1 -1
- package/src/web/handlers/TapGestureHandler.ts +1 -1
- package/src/web/tools/EventManager.ts +2 -2
- package/src/web/tools/GestureHandlerWebDelegate.ts +3 -8
- package/src/web/tools/LeastSquareSolver.ts +18 -18
- package/src/web/tools/PointerEventManager.ts +2 -2
- package/src/web/tools/PointerTracker.ts +2 -1
- package/src/web/tools/TouchEventManager.ts +4 -4
- package/src/web/tools/VelocityTracker.ts +6 -6
- package/src/web_hammer/NodeManager.ts +2 -11
@@ -1,36 +1,10 @@
|
|
1
|
+
import { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload';
|
1
2
|
import createHandler from './createHandler';
|
2
3
|
import {
|
3
4
|
BaseGestureHandlerProps,
|
4
5
|
baseGestureHandlerProps,
|
5
6
|
} from './gestureHandlerCommon';
|
6
7
|
|
7
|
-
export type RotationGestureHandlerEventPayload = {
|
8
|
-
/**
|
9
|
-
* Amount rotated, expressed in radians, from the gesture's focal point
|
10
|
-
* (anchor).
|
11
|
-
*/
|
12
|
-
rotation: number;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* X coordinate, expressed in points, of the gesture's central focal point
|
16
|
-
* (anchor).
|
17
|
-
*/
|
18
|
-
anchorX: number;
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Y coordinate, expressed in points, of the gesture's central focal point
|
22
|
-
* (anchor).
|
23
|
-
*/
|
24
|
-
anchorY: number;
|
25
|
-
|
26
|
-
/**
|
27
|
-
*
|
28
|
-
* Instantaneous velocity, expressed in point units per second, of the
|
29
|
-
* gesture.
|
30
|
-
*/
|
31
|
-
velocity: number;
|
32
|
-
};
|
33
|
-
|
34
8
|
export interface RotationGestureHandlerProps
|
35
9
|
extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}
|
36
10
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload';
|
1
2
|
import createHandler from './createHandler';
|
2
3
|
import {
|
3
4
|
BaseGestureHandlerProps,
|
@@ -14,12 +15,6 @@ export const tapGestureHandlerProps = [
|
|
14
15
|
'minPointers',
|
15
16
|
] as const;
|
16
17
|
|
17
|
-
export type TapGestureHandlerEventPayload = {
|
18
|
-
x: number;
|
19
|
-
y: number;
|
20
|
-
absoluteX: number;
|
21
|
-
absoluteY: number;
|
22
|
-
};
|
23
18
|
export interface TapGestureConfig {
|
24
19
|
/**
|
25
20
|
* Minimum number of pointers (fingers) required to be placed before the
|
@@ -8,20 +8,15 @@ import {
|
|
8
8
|
import { customDirectEventTypes } from './customDirectEventTypes';
|
9
9
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
10
10
|
import { State } from '../State';
|
11
|
-
import {
|
12
|
-
|
13
|
-
getNextHandlerTag,
|
14
|
-
registerOldGestureHandler,
|
15
|
-
} from './handlersRegistry';
|
11
|
+
import { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry';
|
12
|
+
import { getNextHandlerTag } from './getNextHandlerTag';
|
16
13
|
|
17
14
|
import {
|
18
15
|
BaseGestureHandlerProps,
|
19
|
-
filterConfig,
|
20
16
|
GestureEvent,
|
21
17
|
HandlerStateChangeEvent,
|
22
|
-
findNodeHandle,
|
23
|
-
scheduleFlushOperations,
|
24
18
|
} from './gestureHandlerCommon';
|
19
|
+
import { filterConfig, findNodeHandle, scheduleFlushOperations } from './utils';
|
25
20
|
import { ValueOf } from '../typeUtils';
|
26
21
|
import { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';
|
27
22
|
import { ActionType } from '../ActionType';
|
@@ -86,10 +81,10 @@ if (UIManagerConstants) {
|
|
86
81
|
// Wrap JS responder calls and notify gesture handler manager
|
87
82
|
const {
|
88
83
|
setJSResponder: oldSetJSResponder = () => {
|
89
|
-
//no
|
84
|
+
// no-op
|
90
85
|
},
|
91
86
|
clearJSResponder: oldClearJSResponder = () => {
|
92
|
-
//no
|
87
|
+
// no-op
|
93
88
|
},
|
94
89
|
} = UIManagerAny;
|
95
90
|
UIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {
|
@@ -323,7 +318,7 @@ export default function createHandler<
|
|
323
318
|
this.viewTag = newViewTag;
|
324
319
|
|
325
320
|
if (Platform.OS === 'web') {
|
326
|
-
//
|
321
|
+
// Typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
|
327
322
|
(
|
328
323
|
RNGestureHandlerModule.attachGestureHandler as AttachGestureHandlerWeb
|
329
324
|
)(
|
@@ -28,7 +28,7 @@ export default function createNativeWrapper<P>(
|
|
28
28
|
React.ComponentType<any>,
|
29
29
|
P & NativeViewGestureHandlerProps
|
30
30
|
>((props, ref) => {
|
31
|
-
//
|
31
|
+
// Filter out props that should be passed to gesture handler wrapper
|
32
32
|
const gestureHandlerProps = Object.keys(props).reduce(
|
33
33
|
(res, key) => {
|
34
34
|
// TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info
|
@@ -39,7 +39,7 @@ export default function createNativeWrapper<P>(
|
|
39
39
|
}
|
40
40
|
return res;
|
41
41
|
},
|
42
|
-
{ ...config } //
|
42
|
+
{ ...config } // Watch out not to modify config
|
43
43
|
);
|
44
44
|
const _ref = useRef<React.ComponentType<P>>();
|
45
45
|
const _gestureHandlerRef = useRef<React.ComponentType<P>>();
|
@@ -48,7 +48,7 @@ export default function createNativeWrapper<P>(
|
|
48
48
|
// @ts-ignore TODO(TS) decide how nulls work in this context
|
49
49
|
() => {
|
50
50
|
const node = _gestureHandlerRef.current;
|
51
|
-
//
|
51
|
+
// Add handlerTag for relations config
|
52
52
|
if (_ref.current && node) {
|
53
53
|
// @ts-ignore FIXME(TS) think about createHandler return type
|
54
54
|
_ref.current.handlerTag = node.handlerTag;
|
@@ -3,15 +3,10 @@
|
|
3
3
|
// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
|
4
4
|
// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
|
5
5
|
import * as React from 'react';
|
6
|
-
import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
|
7
6
|
|
8
7
|
import { State } from '../State';
|
9
8
|
import { TouchEventType } from '../TouchEventType';
|
10
9
|
import { ValueOf } from '../typeUtils';
|
11
|
-
import { handlerIDToTag } from './handlersRegistry';
|
12
|
-
import { toArray } from '../utils';
|
13
|
-
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
14
|
-
import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
15
10
|
import { PointerType } from '../PointerType';
|
16
11
|
|
17
12
|
const commonProps = [
|
@@ -141,7 +136,7 @@ export type TouchAction =
|
|
141
136
|
| 'revert-layer'
|
142
137
|
| 'unset';
|
143
138
|
|
144
|
-
//TODO(TS) events in handlers
|
139
|
+
// TODO(TS) events in handlers
|
145
140
|
|
146
141
|
export interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {
|
147
142
|
nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;
|
@@ -206,82 +201,11 @@ export type BaseGestureHandlerProps<
|
|
206
201
|
onActivated?: (event: HandlerStateChangeEvent) => void;
|
207
202
|
onEnded?: (event: HandlerStateChangeEvent) => void;
|
208
203
|
|
209
|
-
//TODO(TS) consider using NativeSyntheticEvent
|
204
|
+
// TODO(TS) consider using NativeSyntheticEvent
|
210
205
|
onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;
|
211
206
|
onHandlerStateChange?: (
|
212
207
|
event: HandlerStateChangeEvent<ExtraEventPayloadT>
|
213
208
|
) => void;
|
214
|
-
//
|
209
|
+
// Implicit `children` prop has been removed in @types/react^18.0.0
|
215
210
|
children?: React.ReactNode;
|
216
211
|
};
|
217
|
-
|
218
|
-
function isConfigParam(param: unknown, name: string) {
|
219
|
-
// param !== Object(param) returns false if `param` is a function
|
220
|
-
// or an object and returns true if `param` is null
|
221
|
-
return (
|
222
|
-
param !== undefined &&
|
223
|
-
(param !== Object(param) ||
|
224
|
-
!('__isNative' in (param as Record<string, unknown>))) &&
|
225
|
-
name !== 'onHandlerStateChange' &&
|
226
|
-
name !== 'onGestureEvent'
|
227
|
-
);
|
228
|
-
}
|
229
|
-
|
230
|
-
export function filterConfig(
|
231
|
-
props: Record<string, unknown>,
|
232
|
-
validProps: string[],
|
233
|
-
defaults: Record<string, unknown> = {}
|
234
|
-
) {
|
235
|
-
const filteredConfig = { ...defaults };
|
236
|
-
for (const key of validProps) {
|
237
|
-
let value = props[key];
|
238
|
-
if (isConfigParam(value, key)) {
|
239
|
-
if (key === 'simultaneousHandlers' || key === 'waitFor') {
|
240
|
-
value = transformIntoHandlerTags(props[key]);
|
241
|
-
} else if (key === 'hitSlop' && typeof value !== 'object') {
|
242
|
-
value = { top: value, left: value, bottom: value, right: value };
|
243
|
-
}
|
244
|
-
filteredConfig[key] = value;
|
245
|
-
}
|
246
|
-
}
|
247
|
-
return filteredConfig;
|
248
|
-
}
|
249
|
-
|
250
|
-
function transformIntoHandlerTags(handlerIDs: any) {
|
251
|
-
handlerIDs = toArray(handlerIDs);
|
252
|
-
|
253
|
-
if (Platform.OS === 'web') {
|
254
|
-
return handlerIDs
|
255
|
-
.map(({ current }: { current: any }) => current)
|
256
|
-
.filter((handle: any) => handle);
|
257
|
-
}
|
258
|
-
// converts handler string IDs into their numeric tags
|
259
|
-
return handlerIDs
|
260
|
-
.map(
|
261
|
-
(handlerID: any) =>
|
262
|
-
handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1
|
263
|
-
)
|
264
|
-
.filter((handlerTag: number) => handlerTag > 0);
|
265
|
-
}
|
266
|
-
|
267
|
-
export function findNodeHandle(
|
268
|
-
node: null | number | React.Component<any, any> | React.ComponentClass<any>
|
269
|
-
): null | number | React.Component<any, any> | React.ComponentClass<any> {
|
270
|
-
if (Platform.OS === 'web') {
|
271
|
-
return node;
|
272
|
-
}
|
273
|
-
return findNodeHandleRN(node);
|
274
|
-
}
|
275
|
-
|
276
|
-
let flushOperationsScheduled = false;
|
277
|
-
|
278
|
-
export function scheduleFlushOperations() {
|
279
|
-
if (!flushOperationsScheduled) {
|
280
|
-
flushOperationsScheduled = true;
|
281
|
-
ghQueueMicrotask(() => {
|
282
|
-
RNGestureHandlerModule.flushOperations();
|
283
|
-
|
284
|
-
flushOperationsScheduled = false;
|
285
|
-
});
|
286
|
-
}
|
287
|
-
}
|
@@ -1,55 +1,41 @@
|
|
1
|
-
import {
|
1
|
+
import type {
|
2
2
|
BaseButtonProps,
|
3
3
|
BorderlessButtonProps,
|
4
4
|
RawButtonProps,
|
5
5
|
RectButtonProps,
|
6
|
-
} from '../components/
|
6
|
+
} from '../components/GestureButtonsProps';
|
7
7
|
import {
|
8
8
|
GestureEvent,
|
9
9
|
GestureEventPayload,
|
10
10
|
HandlerStateChangeEvent,
|
11
11
|
HandlerStateChangeEventPayload,
|
12
12
|
} from './gestureHandlerCommon';
|
13
|
-
import {
|
13
|
+
import type { FlingGestureHandlerProps } from './FlingGestureHandler';
|
14
|
+
import type {
|
14
15
|
FlingGestureHandlerEventPayload,
|
15
|
-
FlingGestureHandlerProps,
|
16
|
-
} from './FlingGestureHandler';
|
17
|
-
import {
|
18
16
|
ForceTouchGestureHandlerEventPayload,
|
19
|
-
ForceTouchGestureHandlerProps,
|
20
|
-
} from './ForceTouchGestureHandler';
|
21
|
-
import {
|
22
17
|
LongPressGestureHandlerEventPayload,
|
23
|
-
LongPressGestureHandlerProps,
|
24
|
-
} from './LongPressGestureHandler';
|
25
|
-
import {
|
26
18
|
PanGestureHandlerEventPayload,
|
27
|
-
PanGestureHandlerProps,
|
28
|
-
} from './PanGestureHandler';
|
29
|
-
import {
|
30
19
|
PinchGestureHandlerEventPayload,
|
31
|
-
PinchGestureHandlerProps,
|
32
|
-
} from './PinchGestureHandler';
|
33
|
-
import {
|
34
20
|
RotationGestureHandlerEventPayload,
|
35
|
-
RotationGestureHandlerProps,
|
36
|
-
} from './RotationGestureHandler';
|
37
|
-
import {
|
38
21
|
TapGestureHandlerEventPayload,
|
39
|
-
TapGestureHandlerProps,
|
40
|
-
} from './TapGestureHandler';
|
41
|
-
import {
|
42
22
|
NativeViewGestureHandlerPayload,
|
43
|
-
|
44
|
-
} from './
|
23
|
+
} from './GestureHandlerEventPayload';
|
24
|
+
import type { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler';
|
25
|
+
import type { LongPressGestureHandlerProps } from './LongPressGestureHandler';
|
26
|
+
import type { PanGestureHandlerProps } from './PanGestureHandler';
|
27
|
+
import type { PinchGestureHandlerProps } from './PinchGestureHandler';
|
28
|
+
import type { RotationGestureHandlerProps } from './RotationGestureHandler';
|
29
|
+
import type { TapGestureHandlerProps } from './TapGestureHandler';
|
30
|
+
import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler';
|
45
31
|
|
46
|
-
//
|
32
|
+
// Events
|
47
33
|
export type GestureHandlerGestureEventNativeEvent = GestureEventPayload;
|
48
34
|
export type GestureHandlerStateChangeNativeEvent =
|
49
35
|
HandlerStateChangeEventPayload;
|
50
36
|
export type GestureHandlerGestureEvent = GestureEvent;
|
51
37
|
export type GestureHandlerStateChangeEvent = HandlerStateChangeEvent;
|
52
|
-
//
|
38
|
+
// Gesture handlers events
|
53
39
|
export type NativeViewGestureHandlerGestureEvent =
|
54
40
|
GestureEvent<NativeViewGestureHandlerPayload>;
|
55
41
|
export type NativeViewGestureHandlerStateChangeEvent =
|
@@ -90,7 +76,7 @@ export type FlingGestureHandlerGestureEvent =
|
|
90
76
|
export type FlingGestureHandlerStateChangeEvent =
|
91
77
|
HandlerStateChangeEvent<FlingGestureHandlerEventPayload>;
|
92
78
|
|
93
|
-
//
|
79
|
+
// Handlers properties
|
94
80
|
export type NativeViewGestureHandlerProperties = NativeViewGestureHandlerProps;
|
95
81
|
export type TapGestureHandlerProperties = TapGestureHandlerProps;
|
96
82
|
export type LongPressGestureHandlerProperties = LongPressGestureHandlerProps;
|
@@ -99,7 +85,7 @@ export type PinchGestureHandlerProperties = PinchGestureHandlerProps;
|
|
99
85
|
export type RotationGestureHandlerProperties = RotationGestureHandlerProps;
|
100
86
|
export type FlingGestureHandlerProperties = FlingGestureHandlerProps;
|
101
87
|
export type ForceTouchGestureHandlerProperties = ForceTouchGestureHandlerProps;
|
102
|
-
//
|
88
|
+
// Button props
|
103
89
|
export type RawButtonProperties = RawButtonProps;
|
104
90
|
export type BaseButtonProperties = BaseButtonProps;
|
105
91
|
export type RectButtonProperties = RectButtonProps;
|
@@ -4,7 +4,7 @@ import { tagMessage } from '../../../utils';
|
|
4
4
|
|
5
5
|
export class Wrap extends React.Component<{
|
6
6
|
onGestureHandlerEvent?: unknown;
|
7
|
-
//
|
7
|
+
// Implicit `children` prop has been removed in @types/react^18.0.0
|
8
8
|
children?: React.ReactNode;
|
9
9
|
}> {
|
10
10
|
render() {
|
@@ -2,10 +2,7 @@ import React from 'react';
|
|
2
2
|
import { GestureType, HandlerCallbacks } from '../gesture';
|
3
3
|
import { registerHandler } from '../../handlersRegistry';
|
4
4
|
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
5
|
-
import {
|
6
|
-
filterConfig,
|
7
|
-
scheduleFlushOperations,
|
8
|
-
} from '../../gestureHandlerCommon';
|
5
|
+
import { filterConfig, scheduleFlushOperations } from '../../utils';
|
9
6
|
import { ComposedGesture } from '../gestureComposition';
|
10
7
|
import { ActionType } from '../../../ActionType';
|
11
8
|
import { Platform } from 'react-native';
|
@@ -35,7 +32,7 @@ export function attachHandlers({
|
|
35
32
|
}: AttachHandlersConfig) {
|
36
33
|
gestureConfig.initialize();
|
37
34
|
|
38
|
-
//
|
35
|
+
// Use queueMicrotask to extract handlerTags, because all refs should be initialized
|
39
36
|
// when it's ran
|
40
37
|
ghQueueMicrotask(() => {
|
41
38
|
if (!preparedGesture.isMounted) {
|
@@ -55,7 +52,7 @@ export function attachHandlers({
|
|
55
52
|
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
56
53
|
}
|
57
54
|
|
58
|
-
//
|
55
|
+
// Use queueMicrotask to extract handlerTags, because all refs should be initialized
|
59
56
|
// when it's ran
|
60
57
|
ghQueueMicrotask(() => {
|
61
58
|
if (!preparedGesture.isMounted) {
|
@@ -86,7 +83,7 @@ export function attachHandlers({
|
|
86
83
|
)(
|
87
84
|
gesture.handlerTag,
|
88
85
|
viewTag,
|
89
|
-
ActionType.JS_FUNCTION_OLD_API, //
|
86
|
+
ActionType.JS_FUNCTION_OLD_API, // Ignored on web
|
90
87
|
webEventHandlersRef
|
91
88
|
);
|
92
89
|
} else {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { unregisterHandler } from '../../handlersRegistry';
|
2
2
|
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
3
|
-
import { scheduleFlushOperations } from '../../
|
3
|
+
import { scheduleFlushOperations } from '../../utils';
|
4
4
|
import { AttachedGestureState } from './types';
|
5
5
|
|
6
6
|
export function dropHandlers(preparedGesture: AttachedGestureState) {
|
@@ -111,7 +111,7 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
111
111
|
);
|
112
112
|
|
113
113
|
const webEventHandlersRef = useWebEventHandlers();
|
114
|
-
//
|
114
|
+
// Store state in ref to prevent unnecessary renders
|
115
115
|
const state = useRef<GestureDetectorState>({
|
116
116
|
firstRender: true,
|
117
117
|
viewRef: null,
|
@@ -1,10 +1,7 @@
|
|
1
1
|
import { GestureType, HandlerCallbacks } from '../gesture';
|
2
2
|
import { registerHandler } from '../../handlersRegistry';
|
3
3
|
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
4
|
-
import {
|
5
|
-
filterConfig,
|
6
|
-
scheduleFlushOperations,
|
7
|
-
} from '../../gestureHandlerCommon';
|
4
|
+
import { filterConfig, scheduleFlushOperations } from '../../utils';
|
8
5
|
import { ComposedGesture } from '../gestureComposition';
|
9
6
|
import { ghQueueMicrotask } from '../../../ghQueueMicrotask';
|
10
7
|
import { AttachedGestureState } from './types';
|
@@ -25,7 +22,7 @@ export function updateHandlers(
|
|
25
22
|
const handler = preparedGesture.attachedGestures[i];
|
26
23
|
checkGestureCallbacksForWorklets(handler);
|
27
24
|
|
28
|
-
//
|
25
|
+
// Only update handlerTag when it's actually different, it may be the same
|
29
26
|
// if gesture config object is wrapped with useMemo
|
30
27
|
if (newGestures[i].handlerTag !== handler.handlerTag) {
|
31
28
|
newGestures[i].handlerTag = handler.handlerTag;
|
@@ -33,16 +30,30 @@ export function updateHandlers(
|
|
33
30
|
}
|
34
31
|
}
|
35
32
|
|
36
|
-
//
|
33
|
+
// Use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
|
37
34
|
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
|
38
35
|
// in case of external relations)
|
39
36
|
ghQueueMicrotask(() => {
|
40
37
|
if (!preparedGesture.isMounted) {
|
41
38
|
return;
|
42
39
|
}
|
40
|
+
|
41
|
+
// If amount of gesture configs changes, we need to update the callbacks in shared value
|
42
|
+
let shouldUpdateSharedValueIfUsed =
|
43
|
+
preparedGesture.attachedGestures.length !== newGestures.length;
|
44
|
+
|
43
45
|
for (let i = 0; i < newGestures.length; i++) {
|
44
46
|
const handler = preparedGesture.attachedGestures[i];
|
45
47
|
|
48
|
+
// If the gestureId is different (gesture isn't wrapped with useMemo or its dependencies changed),
|
49
|
+
// we need to update the shared value, assuming the gesture runs on UI thread or the thread changed
|
50
|
+
if (
|
51
|
+
handler.handlers.gestureId !== newGestures[i].handlers.gestureId &&
|
52
|
+
(newGestures[i].shouldUseReanimated || handler.shouldUseReanimated)
|
53
|
+
) {
|
54
|
+
shouldUpdateSharedValueIfUsed = true;
|
55
|
+
}
|
56
|
+
|
46
57
|
handler.config = newGestures[i].config;
|
47
58
|
handler.handlers = newGestures[i].handlers;
|
48
59
|
|
@@ -58,35 +69,14 @@ export function updateHandlers(
|
|
58
69
|
registerHandler(handler.handlerTag, handler, handler.config.testId);
|
59
70
|
}
|
60
71
|
|
61
|
-
if (preparedGesture.animatedHandlers) {
|
62
|
-
const previousHandlersValue =
|
63
|
-
preparedGesture.animatedHandlers.value ?? [];
|
72
|
+
if (preparedGesture.animatedHandlers && shouldUpdateSharedValueIfUsed) {
|
64
73
|
const newHandlersValue = preparedGesture.attachedGestures
|
65
|
-
.filter((g) => g.shouldUseReanimated) //
|
74
|
+
.filter((g) => g.shouldUseReanimated) // Ignore gestures that shouldn't run on UI
|
66
75
|
.map((g) => g.handlers) as unknown as HandlerCallbacks<
|
67
76
|
Record<string, unknown>
|
68
77
|
>[];
|
69
78
|
|
70
|
-
|
71
|
-
let shouldUpdateSharedValue =
|
72
|
-
previousHandlersValue.length !== newHandlersValue.length;
|
73
|
-
|
74
|
-
if (!shouldUpdateSharedValue) {
|
75
|
-
// if the amount is the same, we need to check if any of the configs inside has changed
|
76
|
-
for (let i = 0; i < newHandlersValue.length; i++) {
|
77
|
-
if (
|
78
|
-
// we can use the `gestureId` prop as it's unique for every config instance
|
79
|
-
newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId
|
80
|
-
) {
|
81
|
-
shouldUpdateSharedValue = true;
|
82
|
-
break;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
if (shouldUpdateSharedValue) {
|
88
|
-
preparedGesture.animatedHandlers.value = newHandlersValue;
|
89
|
-
}
|
79
|
+
preparedGesture.animatedHandlers.value = newHandlersValue;
|
90
80
|
}
|
91
81
|
|
92
82
|
scheduleFlushOperations();
|
@@ -28,7 +28,7 @@ export function useDetectorUpdater(
|
|
28
28
|
const updateAttachedGestures = useCallback(
|
29
29
|
// skipConfigUpdate is used to prevent unnecessary updates when only checking if the view has changed
|
30
30
|
(skipConfigUpdate?: boolean) => {
|
31
|
-
//
|
31
|
+
// If the underlying view has changed we need to reattach handlers to the new view
|
32
32
|
const viewTag = findNodeHandle(state.viewRef) as number;
|
33
33
|
const didUnderlyingViewChange = viewTag !== state.previousViewTag;
|
34
34
|
|
@@ -73,7 +73,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
|
73
73
|
if (!__DEV__) {
|
74
74
|
return;
|
75
75
|
}
|
76
|
-
//
|
76
|
+
// If a gesture is explicitly marked to run on the JS thread there is no need to check
|
77
77
|
// if callbacks are worklets as the user is aware they will be ran on the JS thread
|
78
78
|
if (gesture.config.runOnJS) {
|
79
79
|
return;
|
@@ -82,7 +82,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
|
82
82
|
const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
|
83
83
|
const areSomeWorklets = gesture.handlers.isWorklet.includes(true);
|
84
84
|
|
85
|
-
//
|
85
|
+
// If some of the callbacks are worklets and some are not, and the gesture is not
|
86
86
|
// explicitly marked with `.runOnJS(true)` show an error
|
87
87
|
if (areSomeNotWorklets && areSomeWorklets) {
|
88
88
|
console.error(
|
@@ -93,12 +93,12 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
|
93
93
|
}
|
94
94
|
|
95
95
|
if (Reanimated === undefined) {
|
96
|
-
//
|
96
|
+
// If Reanimated is not available, we can't run worklets, so we shouldn't show the warning
|
97
97
|
return;
|
98
98
|
}
|
99
99
|
|
100
100
|
const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;
|
101
|
-
//
|
101
|
+
// If none of the callbacks are worklets and the gesture is not explicitly marked with
|
102
102
|
// `.runOnJS(true)` show a warning
|
103
103
|
if (areAllNotWorklets) {
|
104
104
|
console.warn(
|
@@ -111,7 +111,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
|
|
111
111
|
|
112
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
113
113
|
export function validateDetectorChildren(ref: any) {
|
114
|
-
//
|
114
|
+
// Finds the first native view under the Wrap component and traverses the fiber tree upwards
|
115
115
|
// to check whether there is more than one native view as a pseudo-direct child of GestureDetector
|
116
116
|
// i.e. this is not ok:
|
117
117
|
// Wrap
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { BaseGesture, BaseGestureConfig } from './gesture';
|
2
|
-
import {
|
3
|
-
|
4
|
-
FlingGestureHandlerEventPayload,
|
5
|
-
} from '../FlingGestureHandler';
|
2
|
+
import { FlingGestureConfig } from '../FlingGestureHandler';
|
3
|
+
import type { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload';
|
6
4
|
|
7
5
|
export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
|
8
6
|
public config: BaseGestureConfig & FlingGestureConfig = {};
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
|
-
import {
|
3
|
-
|
4
|
-
ForceTouchGestureHandlerEventPayload,
|
5
|
-
} from '../ForceTouchGestureHandler';
|
2
|
+
import { ForceTouchGestureConfig } from '../ForceTouchGestureHandler';
|
3
|
+
import type { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload';
|
6
4
|
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
7
5
|
|
8
6
|
export type ForceTouchGestureChangeEventPayload = {
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';
|
2
|
-
import { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';
|
3
1
|
import {
|
4
2
|
HitSlop,
|
5
3
|
CommonGestureConfig,
|
@@ -9,14 +7,18 @@ import {
|
|
9
7
|
ActiveCursor,
|
10
8
|
MouseButton,
|
11
9
|
} from '../gestureHandlerCommon';
|
12
|
-
import { getNextHandlerTag } from '../
|
10
|
+
import { getNextHandlerTag } from '../getNextHandlerTag';
|
13
11
|
import { GestureStateManagerType } from './gestureStateManager';
|
14
|
-
import {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
import type {
|
13
|
+
FlingGestureHandlerEventPayload,
|
14
|
+
ForceTouchGestureHandlerEventPayload,
|
15
|
+
LongPressGestureHandlerEventPayload,
|
16
|
+
PanGestureHandlerEventPayload,
|
17
|
+
PinchGestureHandlerEventPayload,
|
18
|
+
RotationGestureHandlerEventPayload,
|
19
|
+
TapGestureHandlerEventPayload,
|
20
|
+
NativeViewGestureHandlerPayload,
|
21
|
+
} from '../GestureHandlerEventPayload';
|
20
22
|
import { isRemoteDebuggingEnabled } from '../../utils';
|
21
23
|
|
22
24
|
export type GestureType =
|
@@ -35,7 +37,7 @@ export type GestureRef =
|
|
35
37
|
| number
|
36
38
|
| GestureType
|
37
39
|
| React.RefObject<GestureType | undefined>
|
38
|
-
| React.RefObject<React.ComponentType | undefined>; //
|
40
|
+
| React.RefObject<React.ComponentType | undefined>; // Allow adding a ref to a gesture handler
|
39
41
|
export interface BaseGestureConfig
|
40
42
|
extends CommonGestureConfig,
|
41
43
|
Record<string, unknown> {
|
@@ -166,7 +168,7 @@ export abstract class BaseGesture<
|
|
166
168
|
|
167
169
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
168
170
|
protected isWorklet(callback: Function) {
|
169
|
-
|
171
|
+
// @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
170
172
|
return callback.__workletHash !== undefined;
|
171
173
|
}
|
172
174
|
|
@@ -203,7 +205,7 @@ export abstract class BaseGesture<
|
|
203
205
|
) => void
|
204
206
|
) {
|
205
207
|
this.handlers.onEnd = callback;
|
206
|
-
|
208
|
+
// @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
207
209
|
this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
|
208
210
|
return this;
|
209
211
|
}
|
@@ -219,7 +221,7 @@ export abstract class BaseGesture<
|
|
219
221
|
) => void
|
220
222
|
) {
|
221
223
|
this.handlers.onFinalize = callback;
|
222
|
-
|
224
|
+
// @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
223
225
|
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
|
224
226
|
return this;
|
225
227
|
}
|
@@ -416,8 +418,8 @@ export abstract class BaseGesture<
|
|
416
418
|
prepare() {}
|
417
419
|
|
418
420
|
get shouldUseReanimated(): boolean {
|
419
|
-
//
|
420
|
-
//
|
421
|
+
// Use Reanimated when runOnJS isn't set explicitly,
|
422
|
+
// all defined callbacks are worklets
|
421
423
|
// and remote debugging is disabled
|
422
424
|
return (
|
423
425
|
this.config.runOnJS !== true &&
|