mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Stop using group-dimensions on groupe creation.
This commit is contained in:
parent
462b9681e1
commit
28047aa64d
2 changed files with 19 additions and 22 deletions
|
@ -318,14 +318,11 @@
|
||||||
pid (get-in state [:workspace :page])
|
pid (get-in state [:workspace :page])
|
||||||
selected (get-in state [:workspace :selected])
|
selected (get-in state [:workspace :selected])
|
||||||
selected' (map #(get shapes-by-id %) selected)
|
selected' (map #(get shapes-by-id %) selected)
|
||||||
dimensions (sh/group-dimensions selected')
|
group {:type :builtin/group
|
||||||
|
|
||||||
data {:type :builtin/group
|
|
||||||
:name (str "Group " (rand-int 1000))
|
:name (str "Group " (rand-int 1000))
|
||||||
:items (into [] selected)
|
:items (into [] selected)
|
||||||
:id sid
|
:id sid
|
||||||
:page pid}
|
:page pid}]
|
||||||
group (merge data dimensions)]
|
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(update-shapes-on-index $ selected' dimensions sid)
|
(update-shapes-on-index $ selected' dimensions sid)
|
||||||
(update-shapes-on-page $ pid selected sid)
|
(update-shapes-on-page $ pid selected sid)
|
||||||
|
|
|
@ -204,23 +204,23 @@
|
||||||
:width final-width
|
:width final-width
|
||||||
:height final-height})))
|
:height final-height})))
|
||||||
|
|
||||||
(defn group-dimensions
|
;; (defn group-dimensions
|
||||||
"Given a collection of shapes, calculates the
|
;; "Given a collection of shapes, calculates the
|
||||||
dimensions of the resultant group."
|
;; dimensions of the resultant group."
|
||||||
[shapes]
|
;; [shapes]
|
||||||
{:pre [(seq shapes)]}
|
;; {:pre [(seq shapes)]}
|
||||||
(let [shapes (map container-rect shapes)
|
;; (let [shapes (map container-rect shapes)
|
||||||
x (apply min (map :x shapes))
|
;; x (apply min (map :x shapes))
|
||||||
y (apply min (map :y shapes))
|
;; y (apply min (map :y shapes))
|
||||||
x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
|
;; x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
|
||||||
y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
|
;; y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
|
||||||
width (- x' x)
|
;; width (- x' x)
|
||||||
height (- y' y)]
|
;; height (- y' y)]
|
||||||
{:width width
|
;; {:width width
|
||||||
:height height
|
;; :height height
|
||||||
:view-box [0 0 width height]
|
;; :view-box [0 0 width height]
|
||||||
:x x
|
;; :x x
|
||||||
:y y}))
|
;; :y y}))
|
||||||
|
|
||||||
(defn outer-rect
|
(defn outer-rect
|
||||||
[shapes]
|
[shapes]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue