mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
🐛 Fixes issues with horizontal scroll with trackpad
This commit is contained in:
parent
356572c21b
commit
3b6c9f9511
4 changed files with 25 additions and 14 deletions
|
@ -77,8 +77,10 @@
|
|||
(fn [event]
|
||||
(when (kbd/ctrl? event)
|
||||
(dom/prevent-default event)
|
||||
(let [event (.getBrowserEvent ^js event)]
|
||||
(if (pos? (.-deltaY ^js event))
|
||||
(let [event (.getBrowserEvent ^js event)
|
||||
delta (+ (.-deltaY ^js event)
|
||||
(.-deltaX ^js event))]
|
||||
(if (pos? delta)
|
||||
(st/emit! dv/decrease-zoom)
|
||||
(st/emit! dv/increase-zoom))))))
|
||||
|
||||
|
|
|
@ -215,8 +215,9 @@
|
|||
(fn [event]
|
||||
(when (kbd/ctrl? event)
|
||||
(dom/prevent-default event)
|
||||
(let [event (.getBrowserEvent ^js event)]
|
||||
(if (pos? (.-deltaY ^js event))
|
||||
(let [event (.getBrowserEvent ^js event)
|
||||
delta (+ (.-deltaY ^js event) (.-deltaX ^js event))]
|
||||
(if (pos? delta)
|
||||
(st/emit! dv/decrease-zoom)
|
||||
(st/emit! dv/increase-zoom)))))
|
||||
|
||||
|
|
|
@ -103,9 +103,10 @@
|
|||
(mf/use-callback
|
||||
(mf/deps max-offset)
|
||||
(fn [event]
|
||||
(if (pos? (.. event -nativeEvent -deltaY))
|
||||
(on-right-arrow-click event)
|
||||
(on-left-arrow-click event))))
|
||||
(let [delta (+ (.. event -nativeEvent -deltaY) (.. event -nativeEvent -deltaX))]
|
||||
(if (pos? delta)
|
||||
(on-right-arrow-click event)
|
||||
(on-left-arrow-click event)))))
|
||||
|
||||
on-resize
|
||||
(mf/use-callback
|
||||
|
|
|
@ -427,9 +427,11 @@
|
|||
pos @ms/mouse-position]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(if (pos? (.-deltaY event))
|
||||
(st/emit! (dw/decrease-zoom pos))
|
||||
(st/emit! (dw/increase-zoom pos))))
|
||||
(let [delta (+ (.-deltaY ^js event)
|
||||
(.-deltaX ^js event))]
|
||||
(if (pos? delta)
|
||||
(st/emit! (dw/decrease-zoom pos))
|
||||
(st/emit! (dw/increase-zoom pos)))))
|
||||
|
||||
(.contains ^js node target)
|
||||
(let [event (.getBrowserEvent ^js event)
|
||||
|
@ -440,13 +442,18 @@
|
|||
(= delta-mode WheelEvent.DeltaMode.LINE) 16
|
||||
(= delta-mode WheelEvent.DeltaMode.PAGE) 100)
|
||||
|
||||
delta (* (.-deltaY ^js event) unit)
|
||||
delta (/ delta @refs/selected-zoom)]
|
||||
delta-y (-> (.-deltaY ^js event)
|
||||
(* unit)
|
||||
(/ @refs/selected-zoom))
|
||||
delta-x (-> (.-deltaX ^js event)
|
||||
(* unit)
|
||||
(/ @refs/selected-zoom))]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(if (kbd/shift? event)
|
||||
(st/emit! (dw/update-viewport-position {:x #(+ % delta)}))
|
||||
(st/emit! (dw/update-viewport-position {:y #(+ % delta)}))))))))
|
||||
(st/emit! (dw/update-viewport-position {:x #(+ % delta-y)}))
|
||||
(st/emit! (dw/update-viewport-position {:x #(+ % delta-x)
|
||||
:y #(+ % delta-y)}))))))))
|
||||
|
||||
on-drag-enter
|
||||
(mf/use-callback
|
||||
|
|
Loading…
Add table
Reference in a new issue