mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 09:56:12 +02:00
🐛 Fix all viewer mouse wheel issues
This commit is contained in:
parent
7ac6f49c08
commit
4751d7d385
2 changed files with 3 additions and 19 deletions
|
@ -318,7 +318,7 @@
|
||||||
mod? (kbd/mod? event)
|
mod? (kbd/mod? event)
|
||||||
shift? (kbd/shift? event)
|
shift? (kbd/shift? event)
|
||||||
delta (.-pixelY norm-event)
|
delta (.-pixelY norm-event)
|
||||||
viewer-section (mf/ref-val viewer-section-ref)
|
viewer-section (.target event)
|
||||||
scroll-pos (if shift?
|
scroll-pos (if shift?
|
||||||
(dom/get-h-scroll-pos viewer-section)
|
(dom/get-h-scroll-pos viewer-section)
|
||||||
(dom/get-scroll-pos viewer-section))
|
(dom/get-scroll-pos viewer-section))
|
||||||
|
|
|
@ -46,30 +46,14 @@
|
||||||
(.-deltaX ^js event))]
|
(.-deltaX ^js event))]
|
||||||
(if (pos? delta)
|
(if (pos? delta)
|
||||||
(st/emit! dv/decrease-zoom)
|
(st/emit! dv/decrease-zoom)
|
||||||
(st/emit! dv/increase-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))))))
|
|
||||||
|
|
||||||
on-mount
|
on-mount
|
||||||
(fn []
|
(fn []
|
||||||
;; bind with passive=false to allow the event to be cancelled
|
;; bind with passive=false to allow the event to be cancelled
|
||||||
;; https://stackoverflow.com/a/57582286/3219895
|
;; https://stackoverflow.com/a/57582286/3219895
|
||||||
(let [key1 (events/listen goog/global EventType.WHEEL
|
(let [key1 (events/listen goog/global EventType.WHEEL
|
||||||
on-mouse-wheel #js {"passive" false "capture" true})]
|
on-mouse-wheel #js {"passive" false})]
|
||||||
(fn []
|
(fn []
|
||||||
(events/unlistenByKey key1))))]
|
(events/unlistenByKey key1))))]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue