From c9507f8f8aebcf818e7305ced4bf7279838f4289 Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Tue, 26 Oct 2021 13:17:54 +0200 Subject: [PATCH] NodeGraph: Fix zooming sensitivity on touchpads (#40718) --- public/app/plugins/panel/nodeGraph/useZoom.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/nodeGraph/useZoom.ts b/public/app/plugins/panel/nodeGraph/useZoom.ts index 0c157f41943..bbbf4775344 100644 --- a/public/app/plugins/panel/nodeGraph/useZoom.ts +++ b/public/app/plugins/panel/nodeGraph/useZoom.ts @@ -53,10 +53,14 @@ export function useZoom({ stepUp, stepDown, min, max } = defaultOptions) { if (wheelEvent.ctrlKey || wheelEvent.metaKey) { event.preventDefault(); + setScale(Math.min(Math.max(min ?? -Infinity, scale + Math.min(wheelEvent.deltaY, 2) * -0.01), max ?? Infinity)); + if (wheelEvent.deltaY < 0) { - onStepUp(); + const newScale = scale + Math.max(wheelEvent.deltaY, -4) * -0.015; + setScale(Math.max(min ?? -Infinity, newScale)); } else if (wheelEvent.deltaY > 0) { - onStepDown(); + const newScale = scale + Math.min(wheelEvent.deltaY, 4) * -0.015; + setScale(Math.min(max ?? Infinity, newScale)); } } },