mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 17:27:09 +00:00
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;
|
deltaY *= 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const zoomingOut = deltaY > 0;
|
||||||
|
|
||||||
// ctrlKey is true when pinch-zooming on a trackpad.
|
// ctrlKey is true when pinch-zooming on a trackpad.
|
||||||
const divisor = ctrlKey ? 100 : 300;
|
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({
|
this._applyChange({
|
||||||
scaleDiff,
|
scaleDiff,
|
||||||
|
|||||||
Reference in New Issue
Block a user