From 9815c83d1ab076a96d2530bdd9037f60f6ad45fb Mon Sep 17 00:00:00 2001 From: Ivanka Todorova Date: Thu, 12 Oct 2023 20:37:09 +0300 Subject: [PATCH] feat: Allow disable the pinch/pan gestures via props --- src/index.tsx | 3 +++ src/types.d.ts | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index c2f04e4..75e0074 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -30,6 +30,7 @@ export default forwardRef(function PanPinchView( maxScale = 4, initialScale = 1, onTranslationFinished = undefined, + disabled = undefined, children, }: PanPinchViewProps, ref: React.Ref @@ -160,6 +161,7 @@ export default forwardRef(function PanPinchView( }; const panGesture = Gesture.Pan() + .enabled(!disabled) .averageTouches(true) .onBegin(() => { 'worklet'; @@ -174,6 +176,7 @@ export default forwardRef(function PanPinchView( }); const pinchGesture = Gesture.Pinch() + .enabled(!disabled) .onBegin( (event: GestureStateChangeEvent) => { 'worklet'; diff --git a/src/types.d.ts b/src/types.d.ts index 88d57e9..c589899 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -42,6 +42,11 @@ export type PanPinchViewProps = { * Callback function called when translation is finished updating. */ onTranslationFinished?: Function; + + /** + * Disable the pan and pinch gestures. + */ + disabled?: boolean; }; export type PanPinchViewRef = {