Stable mousewheel scrolling, one wheel up + one wheel down = no change (#1131)

This commit is contained in:
Adam Burgess
2021-08-24 23:52:25 +10:00
committed by GitHub
parent 14c3d190e9
commit b74788e036

View File

@@ -300,9 +300,13 @@ export default class PinchZoom extends HTMLElement {
deltaY *= 15;
}
const zoomingOut = deltaY > 0;
// ctrlKey is true when pinch-zooming on a trackpad.
const divisor = ctrlKey ? 100 : 300;
const scaleDiff = 1 - deltaY / divisor;
// when zooming out, invert the delta and the ratio to keep zoom stable
const ratio = 1 - (zoomingOut ? -deltaY : deltaY) / divisor;
const scaleDiff = zoomingOut ? 1 / ratio : ratio;
this._applyChange({
scaleDiff,