Wire up normalizeWheelEvent()
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
ad53b0e2e2
commit
2e6397d8aa
1 changed files with 5 additions and 2 deletions
|
@ -32,13 +32,14 @@ import dis from '../../../dispatcher/dispatcher';
|
||||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
||||||
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks"
|
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks"
|
||||||
import {MatrixEvent} from "matrix-js-sdk/src/models/event";
|
import {MatrixEvent} from "matrix-js-sdk/src/models/event";
|
||||||
|
import {normalizeWheelEvent} from "../../../utils/Mouse";
|
||||||
|
|
||||||
const MIN_ZOOM = 100;
|
const MIN_ZOOM = 100;
|
||||||
const MAX_ZOOM = 300;
|
const MAX_ZOOM = 300;
|
||||||
// This is used for the buttons
|
// This is used for the buttons
|
||||||
const ZOOM_STEP = 10;
|
const ZOOM_STEP = 10;
|
||||||
// This is used for mouse wheel events
|
// This is used for mouse wheel events
|
||||||
const ZOOM_COEFFICIENT = 7.5;
|
const ZOOM_COEFFICIENT = 0.5;
|
||||||
// If we have moved only this much we can zoom
|
// If we have moved only this much we can zoom
|
||||||
const ZOOM_DISTANCE = 10;
|
const ZOOM_DISTANCE = 10;
|
||||||
|
|
||||||
|
@ -115,7 +116,9 @@ export default class ImageView extends React.Component<IProps, IState> {
|
||||||
private onWheel = (ev: WheelEvent) => {
|
private onWheel = (ev: WheelEvent) => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
const newZoom = this.state.zoom - (ev.deltaY * ZOOM_COEFFICIENT);
|
|
||||||
|
const {deltaY} = normalizeWheelEvent(ev);
|
||||||
|
const newZoom = this.state.zoom - (deltaY * ZOOM_COEFFICIENT);
|
||||||
|
|
||||||
if (newZoom <= MIN_ZOOM) {
|
if (newZoom <= MIN_ZOOM) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
Loading…
Reference in a new issue