feat: adjust zoom mob

This commit is contained in:
Julien Froidefond
2025-02-28 14:20:17 +01:00
parent 7542f39f7e
commit 6218292484

View File

@@ -118,7 +118,10 @@ export const usePageNavigation = ({
const distance = calculateDistance(event.touches[0], event.touches[1]); const distance = calculateDistance(event.touches[0], event.touches[1]);
if (initialDistanceRef.current !== null) { if (initialDistanceRef.current !== null) {
const scale = distance / initialDistanceRef.current; const scale = distance / initialDistanceRef.current;
setZoomLevel((prevZoomLevel) => Math.max(1, prevZoomLevel * scale)); const zoomFactor = 0.3;
setZoomLevel((prevZoomLevel) =>
Math.min(3, Math.max(1, prevZoomLevel + (scale - 1) * zoomFactor))
);
} }
} }
}, []); }, []);