mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
🐛 Fix positioning on group and ungroup.
This commit is contained in:
parent
9ed6d23041
commit
861150ff46
2 changed files with 22 additions and 9 deletions
|
@ -60,6 +60,13 @@
|
|||
(or (not= (:type shape) :frame)
|
||||
(= parent-id uuid/zero))))
|
||||
|
||||
(defn position-on-parent
|
||||
[id objects]
|
||||
(let [obj (get objects id)
|
||||
pid (:parent-id obj)
|
||||
prt (get objects pid)]
|
||||
(d/index-of (:shapes prt) id)))
|
||||
|
||||
(defn insert-at-index
|
||||
[shapes index ids]
|
||||
(let [[before after] (split-at index shapes)
|
||||
|
|
|
@ -1244,10 +1244,7 @@
|
|||
group (-> (group-shape id frame-id selected selrect)
|
||||
(geom/setup selrect))
|
||||
|
||||
index (->> (get-in objects [frame-id :shapes])
|
||||
(map-indexed vector)
|
||||
(filter #(selected (second %)))
|
||||
(ffirst))
|
||||
index (cph/position-on-parent (:id (first items)) objects)
|
||||
|
||||
rchanges [{:type :add-obj
|
||||
:id id
|
||||
|
@ -1258,11 +1255,20 @@
|
|||
{:type :mov-objects
|
||||
:parent-id id
|
||||
:shapes (vec selected)}]
|
||||
uchanges [{:type :mov-objects
|
||||
:parent-id frame-id
|
||||
:shapes (vec selected)}
|
||||
{:type :del-obj
|
||||
:id id}]]
|
||||
|
||||
uchanges
|
||||
(reduce (fn [res obj]
|
||||
(conj res {:type :mov-objects
|
||||
:parent-id (:parent-id obj)
|
||||
:index (:index obj)
|
||||
:shapes [(:id obj)]}))
|
||||
[]
|
||||
(->> selected
|
||||
(map #(get objects %))
|
||||
(map #(assoc % :index (cph/position-on-parent (:id %) objects)))
|
||||
(sort-by :index)))
|
||||
|
||||
uchanges (conj uchanges {:type :del-obj :id id})]
|
||||
|
||||
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})
|
||||
(dws/select-shapes #{id}))))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue