fix: wheel zoom normalization (#5165)
Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
b27ac257e7
commit
33bb23d2f3
@ -71,7 +71,6 @@ import {
|
|||||||
THEME,
|
THEME,
|
||||||
TOUCH_CTX_MENU_TIMEOUT,
|
TOUCH_CTX_MENU_TIMEOUT,
|
||||||
VERTICAL_ALIGN,
|
VERTICAL_ALIGN,
|
||||||
ZOOM_STEP,
|
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
import { loadFromBlob } from "../data";
|
import { loadFromBlob } from "../data";
|
||||||
import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
|
import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
|
||||||
@ -5642,11 +5641,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
if (event.metaKey || event.ctrlKey) {
|
if (event.metaKey || event.ctrlKey) {
|
||||||
const sign = Math.sign(deltaY);
|
const sign = Math.sign(deltaY);
|
||||||
const MAX_STEP = 10;
|
const MAX_STEP = 10;
|
||||||
let delta = Math.abs(deltaY);
|
const absDelta = Math.abs(deltaY);
|
||||||
if (delta > MAX_STEP) {
|
let delta = deltaY;
|
||||||
delta = MAX_STEP;
|
if (absDelta > MAX_STEP) {
|
||||||
|
delta = MAX_STEP * sign;
|
||||||
}
|
}
|
||||||
delta *= sign;
|
|
||||||
if (Object.keys(previousSelectedElementIds).length !== 0) {
|
if (Object.keys(previousSelectedElementIds).length !== 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -5658,9 +5657,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
let newZoom = this.state.zoom.value - delta / 100;
|
let newZoom = this.state.zoom.value - delta / 100;
|
||||||
// increase zoom steps the more zoomed-in we are (applies to >100% only)
|
// increase zoom steps the more zoomed-in we are (applies to >100% only)
|
||||||
newZoom += Math.log10(Math.max(1, this.state.zoom.value)) * -sign;
|
newZoom +=
|
||||||
// round to nearest step
|
Math.log10(Math.max(1, this.state.zoom.value)) *
|
||||||
newZoom = Math.round(newZoom * ZOOM_STEP * 100) / (ZOOM_STEP * 100);
|
-sign *
|
||||||
|
// reduced amplification for small deltas (small movements on a trackpad)
|
||||||
|
Math.min(1, absDelta / 20);
|
||||||
|
|
||||||
this.setState((state) => ({
|
this.setState((state) => ({
|
||||||
...getStateForZoom(
|
...getStateForZoom(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user