Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2e6397d

Browse files
committed
Wire up normalizeWheelEvent()
Signed-off-by: Šimon Brandner <[email protected]>
1 parent ad53b0e commit 2e6397d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/views/elements/ImageView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ import dis from '../../../dispatcher/dispatcher';
3232
import {replaceableComponent} from "../../../utils/replaceableComponent";
3333
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks"
3434
import {MatrixEvent} from "matrix-js-sdk/src/models/event";
35+
import {normalizeWheelEvent} from "../../../utils/Mouse";
3536

3637
const MIN_ZOOM = 100;
3738
const MAX_ZOOM = 300;
3839
// This is used for the buttons
3940
const ZOOM_STEP = 10;
4041
// This is used for mouse wheel events
41-
const ZOOM_COEFFICIENT = 7.5;
42+
const ZOOM_COEFFICIENT = 0.5;
4243
// If we have moved only this much we can zoom
4344
const ZOOM_DISTANCE = 10;
4445

@@ -115,7 +116,9 @@ export default class ImageView extends React.Component<IProps, IState> {
115116
private onWheel = (ev: WheelEvent) => {
116117
ev.stopPropagation();
117118
ev.preventDefault();
118-
const newZoom = this.state.zoom - (ev.deltaY * ZOOM_COEFFICIENT);
119+
120+
const {deltaY} = normalizeWheelEvent(ev);
121+
const newZoom = this.state.zoom - (deltaY * ZOOM_COEFFICIENT);
119122

120123
if (newZoom <= MIN_ZOOM) {
121124
this.setState({

0 commit comments

Comments
 (0)