Suppress tap navigation concurrent with swipe navigation

This commit is contained in:
sezzim 2026-01-10 14:08:52 -08:00
parent c8be7df4e0
commit e2d5f09b70
2 changed files with 10 additions and 4 deletions

View file

@ -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 (

View file

@ -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<IProps> = ({
}
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 (