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:
parent
b99a6a8d54
commit
875b46bacb
1 changed files with 4 additions and 8 deletions
|
@ -216,17 +216,13 @@ export default class ImageView extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onWheel = (ev: WheelEvent) => {
|
private onWheel = (ev: WheelEvent) => {
|
||||||
ev.stopPropagation();
|
|
||||||
ev.preventDefault();
|
|
||||||
const { deltaY } = normalizeWheelEvent(ev);
|
|
||||||
|
|
||||||
if (ev.target === this.image.current) {
|
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
|
// Zoom in on the point on the image targeted by the cursor
|
||||||
this.zoomDelta(-deltaY * ZOOM_COEFFICIENT, ev.offsetX, ev.offsetY);
|
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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue