mirror of
https://github.com/penpot/penpot.git
synced 2025-06-12 19:31:39 +02:00
🐛 Fix color palettes displacement.
This commit is contained in:
parent
8fb70e9f8d
commit
117744f3f7
1 changed files with 6 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
|
[uxbox.common.math :as mth]
|
||||||
[uxbox.main.data.library :as dlib]
|
[uxbox.main.data.library :as dlib]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
@ -65,7 +66,7 @@
|
||||||
state (mf/use-state {:show-menu false })
|
state (mf/use-state {:show-menu false })
|
||||||
|
|
||||||
width (:width @state 0)
|
width (:width @state 0)
|
||||||
visible (/ width 66)
|
visible (mth/round (/ width 66))
|
||||||
|
|
||||||
offset (:offset @state 0)
|
offset (:offset @state 0)
|
||||||
max-offset (- (count items)
|
max-offset (- (count items)
|
||||||
|
@ -76,21 +77,22 @@
|
||||||
|
|
||||||
on-left-arrow-click
|
on-left-arrow-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
(mf/deps max-offset visible)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(swap! state update :offset
|
(swap! state update :offset
|
||||||
(fn [offset]
|
(fn [offset]
|
||||||
(if (pos? offset)
|
(if (pos? offset)
|
||||||
(dec offset)
|
(max (- offset (mth/round (/ visible 2))) 0)
|
||||||
offset)))))
|
offset)))))
|
||||||
|
|
||||||
on-right-arrow-click
|
on-right-arrow-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps max-offset)
|
(mf/deps max-offset visible)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(swap! state update :offset
|
(swap! state update :offset
|
||||||
(fn [offset]
|
(fn [offset]
|
||||||
(if (< offset max-offset)
|
(if (< offset max-offset)
|
||||||
(inc offset)
|
(min max-offset (+ offset (mth/round (/ visible 2))))
|
||||||
offset)))))
|
offset)))))
|
||||||
|
|
||||||
on-scroll
|
on-scroll
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue