From efb2b2098ba1872b004239045cf37dbd862df521 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 19 Sep 2023 11:21:32 +0800 Subject: [PATCH 1/2] fix error when zoom with keyboard --- src/components/ImageView/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index c92bd7738253..ae44f1c94b9b 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -141,11 +141,15 @@ function ImageView({isAuthTokenRequired, url, fileName}) { */ const onContainerPress = (e) => { if (!isZoomed && !isDragging) { - const {offsetX, offsetY} = e.nativeEvent; - // Dividing clicked positions by the zoom scale to get coordinates - // so that once we zoom we will scroll to the clicked location. - const delta = getScrollOffset(offsetX / zoomScale, offsetY / zoomScale); - setZoomDelta(delta); + if (e.nativeEvent) { + const {offsetX, offsetY} = e.nativeEvent; + // Dividing clicked positions by the zoom scale to get coordinates + // so that once we zoom we will scroll to the clicked location. + const delta = getScrollOffset(offsetX / zoomScale, offsetY / zoomScale); + setZoomDelta(delta); + } else { + setZoomDelta({offsetX: 0, offsetY: 0}); + } } if (isZoomed && isDragging && isMouseDown) { From 192d459487f6577ce1082a99e4c25828e0ed77f5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 20 Sep 2023 12:55:23 +0800 Subject: [PATCH 2/2] add space before comment --- src/components/ImageView/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index ae44f1c94b9b..2df700cc061a 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -143,6 +143,7 @@ function ImageView({isAuthTokenRequired, url, fileName}) { if (!isZoomed && !isDragging) { if (e.nativeEvent) { const {offsetX, offsetY} = e.nativeEvent; + // Dividing clicked positions by the zoom scale to get coordinates // so that once we zoom we will scroll to the clicked location. const delta = getScrollOffset(offsetX / zoomScale, offsetY / zoomScale);