From b74788e0369e77b14c76967be3f5afaddaa40c08 Mon Sep 17 00:00:00 2001 From: Adam Burgess Date: Tue, 24 Aug 2021 23:52:25 +1000 Subject: [PATCH] Stable mousewheel scrolling, one wheel up + one wheel down = no change (#1131) --- .../lazy-app/Compress/Output/custom-els/PinchZoom/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/lazy-app/Compress/Output/custom-els/PinchZoom/index.ts b/src/client/lazy-app/Compress/Output/custom-els/PinchZoom/index.ts index 9e5acd4f..667484ab 100644 --- a/src/client/lazy-app/Compress/Output/custom-els/PinchZoom/index.ts +++ b/src/client/lazy-app/Compress/Output/custom-els/PinchZoom/index.ts @@ -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,