diff --git a/lib/ImageViewer.tsx b/lib/ImageViewer.tsx index ae58472..7291b2a 100644 --- a/lib/ImageViewer.tsx +++ b/lib/ImageViewer.tsx @@ -147,14 +147,28 @@ export default function ImageViewer({ }) .onEnd((event) => { if (scale.value === 1) { + const topBoundary = -finalHeight - dimensions.height; + const bottomBoundary = dimensions.height + finalHeight; + if (event.translationY < -50) { if (event.velocityY < -2000 || event.translationY < -200) { - runOnJS(onRequestClose)(); + translateY.value = withTiming(topBoundary, { duration: 200 }, () => { + runOnJS(onRequestClose)(); + }); return; } } + if (event.translationY > 50) { + if (event.velocityY > 2000 || event.translationY > 200) { + translateY.value = withTiming(bottomBoundary, { duration: 200 }, () => { + runOnJS(onRequestClose)(); + }); + return; + } + } + translateY.value = withTiming(0); translateX.value = withTiming(0); } else if (scale.value < 1) {