From 875b46bacb0719e58d5ee6537f0cdf326d973986 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 22 Jul 2021 09:46:29 -0400 Subject: [PATCH] Don't zoom images when the cursor isn't over the image Signed-off-by: Robin Townsend --- src/components/views/elements/ImageView.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/views/elements/ImageView.tsx b/src/components/views/elements/ImageView.tsx index eff0ad4d61..4059277ea3 100644 --- a/src/components/views/elements/ImageView.tsx +++ b/src/components/views/elements/ImageView.tsx @@ -216,17 +216,13 @@ export default class ImageView extends React.Component { } private onWheel = (ev: WheelEvent) => { - ev.stopPropagation(); - ev.preventDefault(); - const { deltaY } = normalizeWheelEvent(ev); - if (ev.target === this.image.current) { + ev.stopPropagation(); + ev.preventDefault(); + + const { deltaY } = normalizeWheelEvent(ev); // Zoom in on the point on the image targeted by the cursor this.zoomDelta(-deltaY * ZOOM_COEFFICIENT, ev.offsetX, ev.offsetY); - } else { - // The user is scrolling outside of the image, so we can't really - // get a targeted point. Instead, we'll just zoom in on the center. - this.zoomDelta(-deltaY * ZOOM_COEFFICIENT); } };