mirror of
https://github.com/penpot/penpot.git
synced 2026-09-07 04:29:31 +00:00
✨ Enable wheel scrolling over templates-section in the dashboard
This commit is contained in:
parent
8d80eebeb1
commit
7febf330ac
@ -17,6 +17,7 @@
|
|||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
|
[app.util.dom.normalize-wheel :as nw]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.storage :as storage]
|
[app.util.storage :as storage]
|
||||||
@ -206,6 +207,17 @@
|
|||||||
(fn [_event]
|
(fn [_event]
|
||||||
(swap! collapsed* not)))
|
(swap! collapsed* not)))
|
||||||
|
|
||||||
|
on-wheel
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps content-ref)
|
||||||
|
(fn [^js event]
|
||||||
|
(let [event* (nw/normalize-wheel event)
|
||||||
|
deltaY (.-spinY event*)
|
||||||
|
deltaX (.-spinX event*)
|
||||||
|
node (mf/ref-val content-ref)]
|
||||||
|
(when (> (abs deltaY) (abs deltaX))
|
||||||
|
(.scrollBy node #js {:left (* 300 deltaY) :mode "smooth"})))))
|
||||||
|
|
||||||
on-scroll
|
on-scroll
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [e]
|
(fn [e]
|
||||||
@ -258,6 +270,7 @@
|
|||||||
|
|
||||||
[:div {:class (stl/css :content)
|
[:div {:class (stl/css :content)
|
||||||
:on-scroll on-scroll
|
:on-scroll on-scroll
|
||||||
|
:on-wheel on-wheel
|
||||||
:ref content-ref}
|
:ref content-ref}
|
||||||
|
|
||||||
(for [index (range (count templates))]
|
(for [index (range (count templates))]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user