pavelbabenko / react-native-awesome-gallery

Performant, native-like, and well-customizable gallery for React Native.
MIT License
494 stars 54 forks source link

Added swipeEnabled prop #81

Closed vladgolav closed 3 months ago

vladgolav commented 4 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-awesome-gallery@0.3.9 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-awesome-gallery/lib/typescript/index.d.ts b/node_modules/react-native-awesome-gallery/lib/typescript/index.d.ts
index 7bea206..53a89c5 100644
--- a/node_modules/react-native-awesome-gallery/lib/typescript/index.d.ts
+++ b/node_modules/react-native-awesome-gallery/lib/typescript/index.d.ts
@@ -73,6 +73,7 @@ declare const Gallery: <T extends unknown>(p: EventsCallbacks & {
         height: number;
     } | undefined;
     pinchEnabled?: boolean | undefined;
+    swipeEnabled?: boolean | undefined;
     doubleTapEnabled?: boolean | undefined;
     disableTransitionOnScaledImage?: boolean | undefined;
     hideAdjacentImagesOnScaledImage?: boolean | undefined;
diff --git a/node_modules/react-native-awesome-gallery/src/index.tsx b/node_modules/react-native-awesome-gallery/src/index.tsx
index c296990..2147021 100644
--- a/node_modules/react-native-awesome-gallery/src/index.tsx
+++ b/node_modules/react-native-awesome-gallery/src/index.tsx
@@ -114,6 +114,7 @@ type Props<T> = EventsCallbacks & {
   doubleTapScale: number;
   maxScale: number;
   pinchEnabled: boolean;
+  swipeEnabled: boolean;
   doubleTapEnabled: boolean;
   disableTransitionOnScaledImage: boolean;
   hideAdjacentImagesOnScaledImage: boolean;
@@ -159,6 +160,7 @@ const ResizableImage = React.memo(
     doubleTapInterval,
     maxScale,
     pinchEnabled,
+    swipeEnabled,
     doubleTapEnabled,
     disableTransitionOnScaledImage,
     hideAdjacentImagesOnScaledImage,
@@ -523,6 +525,7 @@ const ResizableImage = React.memo(
     const isMoving = useVector(0);

     const panGesture = Gesture.Pan()
+      .enabled(swipeEnabled)
       .minDistance(10)
       .maxPointers(1)
       .onBegin(() => {
@@ -877,6 +880,7 @@ type GalleryProps<T> = EventsCallbacks & {
   style?: ViewStyle;
   containerDimensions?: { width: number; height: number };
   pinchEnabled?: boolean;
+  swipeEnabled?: boolean;
   doubleTapEnabled?: boolean;
   disableTransitionOnScaledImage?: boolean;
   hideAdjacentImagesOnScaledImage?: boolean;
@@ -898,6 +902,7 @@ const GalleryComponent = <T extends any>(
     doubleTapInterval = 500,
     maxScale = MAX_SCALE,
     pinchEnabled = true,
+    swipeEnabled = true,
     doubleTapEnabled = true,
     disableTransitionOnScaledImage = false,
     hideAdjacentImagesOnScaledImage = false,
@@ -1029,6 +1034,7 @@ const GalleryComponent = <T extends any>(
                     doubleTapInterval,
                     maxScale,
                     pinchEnabled,
+                    swipeEnabled,
                     doubleTapEnabled,
                     disableTransitionOnScaledImage,
                     hideAdjacentImagesOnScaledImage,

This issue body was partially generated by patch-package.

pavelbabenko commented 3 months ago

Thank you! Added in v0.4.1