Don't zoom images when the cursor isn't over the image

Signed-off-by: Robin Townsend <robin@robin.town>
pull/21833/head
Robin Townsend 2021-07-22 09:46:29 -04:00
parent b99a6a8d54
commit 875b46bacb
1 changed files with 4 additions and 8 deletions

View File

@ -216,17 +216,13 @@ export default class ImageView extends React.Component<IProps, IState> {
}
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);
}
};