@@ -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
@@ -280,17 +281,20 @@ export const useImageGalleryGestures = ({
280281 */
281282 const finalXPosition = event . translationX - event . velocityX * 0.3 ;
282283 const finalYPosition = event . translationY + event . velocityY * 0.1 ;
284+ console . log ( finalXPosition ) ;
283285
284286 /**
285287 * If there is a next photo, the image is lined up to the right
286288 * edge, the swipe is to the left, and the final position is more
287289 * than half the screen width, move to the next image
290+ *
291+ * As we move towards the left to move to next image, the translationX value will be negative on X axis.
288292 */
289293 if (
290294 index < photoLength - 1 &&
291295 Math . abs ( halfScreenWidth * ( scale . value - 1 ) + offsetX . value ) < 3 &&
292296 translateX . value < 0 &&
293- finalXPosition < - halfScreenWidth &&
297+ finalXPosition > halfScreenWidth &&
294298 isSwiping . value === IsSwiping . TRUE
295299 ) {
296300 cancelAnimation ( translationX ) ;
@@ -310,13 +314,15 @@ export const useImageGalleryGestures = ({
310314 /**
311315 * If there is a previous photo, the image is lined up to the left
312316 * edge, the swipe is to the right, and the final position is more
313- * than half the screen width, move to the previous image
317+ * than half the screen width, move to the previous image.
318+ *
319+ * As we move towards the right to move to previous image, the translationX value will be positive on X axis.
314320 */
315321 } else if (
316322 index > 0 &&
317323 Math . abs ( - halfScreenWidth * ( scale . value - 1 ) + offsetX . value ) < 3 &&
318324 translateX . value > 0 &&
319- finalXPosition > halfScreenWidth &&
325+ finalXPosition < - halfScreenWidth &&
320326 isSwiping . value === IsSwiping . TRUE
321327 ) {
322328 cancelAnimation ( translationX ) ;
@@ -370,9 +376,11 @@ export const useImageGalleryGestures = ({
370376 */
371377 translateY . value =
372378 currentImageHeight * scale . value < screenHeight
373- ? withTiming ( 0 )
379+ ? withTiming ( 0 , { reduceMotion : ReduceMotion . Never } )
374380 : translateY . value > ( currentImageHeight / 2 ) * scale . value - halfScreenHeight
375- ? withTiming ( ( currentImageHeight / 2 ) * scale . value - halfScreenHeight )
381+ ? withTiming ( ( currentImageHeight / 2 ) * scale . value - halfScreenHeight , {
382+ reduceMotion : ReduceMotion . Never ,
383+ } )
376384 : translateY . value < ( - currentImageHeight / 2 ) * scale . value + halfScreenHeight
377385 ? withTiming ( ( - currentImageHeight / 2 ) * scale . value + halfScreenHeight )
378386 : withDecay ( {
0 commit comments