mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
📎 Simplify distribute-objects fn impl.
This commit is contained in:
parent
5409f83167
commit
dcd53183a8
1 changed files with 9 additions and 8 deletions
|
@ -1198,15 +1198,16 @@
|
||||||
(ptk/reify ::distribute-objects
|
(ptk/reify ::distribute-objects
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
moved (-> (map #(get objects %) selected)
|
moved (-> (map #(get objects %) selected)
|
||||||
(gal/distribute-space axis objects))
|
(gal/distribute-space axis objects))
|
||||||
|
|
||||||
moved-objects (->> moved (group-by :id))
|
moved (d/index-by :id moved)
|
||||||
ids (keys moved-objects)
|
ids (keys moved)
|
||||||
update-fn (fn [shape] (first (get moved-objects (:id shape))))]
|
|
||||||
|
update-fn #(get moved (:id %))]
|
||||||
(when (can-distribute? selected)
|
(when (can-distribute? selected)
|
||||||
(rx/of (dch/update-shapes ids update-fn {:reg-objects? true})))))))
|
(rx/of (dch/update-shapes ids update-fn {:reg-objects? true})))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue