mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 14:36:12 +02:00
✨ Align item to it's parent
This commit is contained in:
parent
86c394f4ce
commit
5c1b007c1b
2 changed files with 10 additions and 8 deletions
|
@ -1148,7 +1148,7 @@
|
|||
|
||||
;; --- Shape / Selection Alignment and Distribution
|
||||
|
||||
(declare align-object-to-frame)
|
||||
(declare align-object-to-parent)
|
||||
(declare align-objects-list)
|
||||
|
||||
(defn can-align? [selected objects]
|
||||
|
@ -1168,7 +1168,7 @@
|
|||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
moved (if (= 1 (count selected))
|
||||
(align-object-to-frame objects (first selected) axis)
|
||||
(align-object-to-parent objects (first selected) axis)
|
||||
(align-objects-list objects selected axis))
|
||||
moved-objects (->> moved (group-by :id))
|
||||
ids (keys moved-objects)
|
||||
|
@ -1176,11 +1176,12 @@
|
|||
(when (can-align? selected objects)
|
||||
(rx/of (dch/update-shapes ids update-fn {:reg-objects? true})))))))
|
||||
|
||||
(defn align-object-to-frame
|
||||
(defn align-object-to-parent
|
||||
[objects object-id axis]
|
||||
(let [object (get objects object-id)
|
||||
frame (get objects (:frame-id object))]
|
||||
(gal/align-to-rect object frame axis objects)))
|
||||
parent (:parent-id (get objects object-id))
|
||||
parent-obj (get objects parent)]
|
||||
(gal/align-to-rect object parent-obj axis objects)))
|
||||
|
||||
(defn align-objects-list
|
||||
[objects selected axis]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue