mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Merge pull request #2831 from penpot/azazeln28-fix-viewer-all-mouse-wheel-issues
Fix all viewer mouse wheel issues
This commit is contained in:
commit
58d7bc5c14
2 changed files with 3 additions and 19 deletions
|
@ -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))
|
||||
|
|
|
@ -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))))]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue