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

Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
Robin Townsend 2021-07-22 09:46:29 -04:00
parent b99a6a8d54
commit 875b46bacb

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);
}
};