forked from external-repos/squoosh
Stable mousewheel scrolling, one wheel up + one wheel down = no change (#1131)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user