@@ -4,6 +4,7 @@ import { Gesture, GestureType } from 'react-native-gesture-handler';
44import {
55 cancelAnimation ,
66 Easing ,
7+ ReduceMotion ,
78 runOnJS ,
89 SharedValue ,
910 useSharedValue ,
@@ -242,8 +243,8 @@ export const useImageGalleryGestures = ({
242243 */
243244 translateX . value =
244245 scale . value !== offsetScale . value
245- ? offsetX . value * localEvtScale - event . translationX
246- : offsetX . value - event . translationX ;
246+ ? offsetX . value * localEvtScale + event . translationX
247+ : offsetX . value + event . translationX ;
247248 translateY . value =
248249 isSwiping . value !== IsSwiping . TRUE
249250 ? scale . value !== offsetScale . value
@@ -285,12 +286,14 @@ export const useImageGalleryGestures = ({
285286 * If there is a next photo, the image is lined up to the right
286287 * edge, the swipe is to the left, and the final position is more
287288 * than half the screen width, move to the next image
289+ *
290+ * As we move towards the left to move to next image, the translationX value will be negative on X axis.
288291 */
289292 if (
290293 index < photoLength - 1 &&
291294 Math . abs ( halfScreenWidth * ( scale . value - 1 ) + offsetX . value ) < 3 &&
292295 translateX . value < 0 &&
293- finalXPosition < - halfScreenWidth &&
296+ finalXPosition > halfScreenWidth &&
294297 isSwiping . value === IsSwiping . TRUE
295298 ) {
296299 cancelAnimation ( translationX ) ;
@@ -310,13 +313,15 @@ export const useImageGalleryGestures = ({
310313 /**
311314 * If there is a previous photo, the image is lined up to the left
312315 * edge, the swipe is to the right, and the final position is more
313- * than half the screen width, move to the previous image
316+ * than half the screen width, move to the previous image.
317+ *
318+ * As we move towards the right to move to previous image, the translationX value will be positive on X axis.
314319 */
315320 } else if (
316321 index > 0 &&
317322 Math . abs ( - halfScreenWidth * ( scale . value - 1 ) + offsetX . value ) < 3 &&
318323 translateX . value > 0 &&
319- finalXPosition > halfScreenWidth &&
324+ finalXPosition < - halfScreenWidth &&
320325 isSwiping . value === IsSwiping . TRUE
321326 ) {
322327 cancelAnimation ( translationX ) ;
@@ -370,9 +375,11 @@ export const useImageGalleryGestures = ({
370375 */
371376 translateY . value =
372377 currentImageHeight * scale . value < screenHeight
373- ? withTiming ( 0 )
378+ ? withTiming ( 0 , { reduceMotion : ReduceMotion . Never } )
374379 : translateY . value > ( currentImageHeight / 2 ) * scale . value - halfScreenHeight
375- ? withTiming ( ( currentImageHeight / 2 ) * scale . value - halfScreenHeight )
380+ ? withTiming ( ( currentImageHeight / 2 ) * scale . value - halfScreenHeight , {
381+ reduceMotion : ReduceMotion . Never ,
382+ } )
376383 : translateY . value < ( - currentImageHeight / 2 ) * scale . value + halfScreenHeight
377384 ? withTiming ( ( - currentImageHeight / 2 ) * scale . value + halfScreenHeight )
378385 : withDecay ( {
0 commit comments