From 4751d7d385fdfd0d80a514e117916405d3225898 Mon Sep 17 00:00:00 2001 From: Aitor Date: Tue, 24 Jan 2023 17:44:15 +0100 Subject: [PATCH] :bug: Fix all viewer mouse wheel issues --- frontend/src/app/main/ui/viewer.cljs | 2 +- frontend/src/app/main/ui/viewer/inspect.cljs | 20 ++------------------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index a9dfb822c..4b7de5729 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -318,7 +318,7 @@ mod? (kbd/mod? event) shift? (kbd/shift? event) delta (.-pixelY norm-event) - viewer-section (mf/ref-val viewer-section-ref) + viewer-section (.target event) scroll-pos (if shift? (dom/get-h-scroll-pos viewer-section) (dom/get-scroll-pos viewer-section)) diff --git a/frontend/src/app/main/ui/viewer/inspect.cljs b/frontend/src/app/main/ui/viewer/inspect.cljs index 8f78cc5bc..f1e901ad0 100644 --- a/frontend/src/app/main/ui/viewer/inspect.cljs +++ b/frontend/src/app/main/ui/viewer/inspect.cljs @@ -46,30 +46,14 @@ (.-deltaX ^js event))] (if (pos? delta) (st/emit! dv/decrease-zoom) - (st/emit! dv/increase-zoom)))) - (when-not (kbd/mod? event) - (let [event (.getBrowserEvent ^js event) - shift? (kbd/shift? event) - inspect-svg-container (mf/ref-val inspect-svg-container-ref) - delta (+ (.-deltaY ^js event) - (.-deltaX ^js event)) - scroll-pos (if shift? - (dom/get-h-scroll-pos inspect-svg-container) - (dom/get-scroll-pos inspect-svg-container)) - new-scroll-pos (+ scroll-pos delta)] - (do - (dom/prevent-default event) - (dom/stop-propagation event) - (if shift? - (dom/set-h-scroll-pos! inspect-svg-container new-scroll-pos) - (dom/set-scroll-pos! inspect-svg-container new-scroll-pos)))))) + (st/emit! dv/increase-zoom))))) on-mount (fn [] ;; bind with passive=false to allow the event to be cancelled ;; https://stackoverflow.com/a/57582286/3219895 (let [key1 (events/listen goog/global EventType.WHEEL - on-mouse-wheel #js {"passive" false "capture" true})] + on-mouse-wheel #js {"passive" false})] (fn [] (events/unlistenByKey key1))))]