diff --git a/ui/v2.5/src/hooks/Lightbox/Lightbox.tsx b/ui/v2.5/src/hooks/Lightbox/Lightbox.tsx index e67b85e92..7d0f8d073 100644 --- a/ui/v2.5/src/hooks/Lightbox/Lightbox.tsx +++ b/ui/v2.5/src/hooks/Lightbox/Lightbox.tsx @@ -144,16 +144,20 @@ const LightboxCarousel = forwardRef(function ( event: React.PointerEvent, swipeDuration: number, cancelled: boolean - ) { + ): boolean { const cappedDuration = Math.max(50, Math.min(500, swipeDuration)) / 1000; const adjustedShift = carouselShift / (2 * cappedDuration); + let changed = false; if (!cancelled && adjustedShift < -window.innerWidth / 2) { handleRight(); + changed = true; } else if (!cancelled && adjustedShift > window.innerWidth / 2) { handleLeft(); + changed = true; } setCarouselShift(0); overrideTransition(CLASSNAME_SWIPE); + return changed; } return ( diff --git a/ui/v2.5/src/hooks/Lightbox/LightboxImage.tsx b/ui/v2.5/src/hooks/Lightbox/LightboxImage.tsx index f223aec35..2cd2a34a7 100644 --- a/ui/v2.5/src/hooks/Lightbox/LightboxImage.tsx +++ b/ui/v2.5/src/hooks/Lightbox/LightboxImage.tsx @@ -107,7 +107,7 @@ interface IProps { ev: React.PointerEvent, swipeDuration: number, cancelled: boolean - ) => void; + ) => boolean; isVideo: boolean; } @@ -501,8 +501,10 @@ export const LightboxImage: React.FC = ({ } if (ev.pointerType === "touch" && startPoint.current !== null) { - // Swipe navigation - releaseCarousel(ev, ev.timeStamp - startTime.current, false); + // Swipe navigation, returns true if actually moved to another image. + if (releaseCarousel(ev, ev.timeStamp - startTime.current, false)) { + return; + } } if (