mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05: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])
|
||||
selected (get-in state [:workspace :selected])
|
||||
selected' (map #(get shapes-by-id %) selected)
|
||||
dimensions (sh/group-dimensions selected')
|
||||
|
||||
data {:type :builtin/group
|
||||
group {:type :builtin/group
|
||||
:name (str "Group " (rand-int 1000))
|
||||
:items (into [] selected)
|
||||
:id sid
|
||||
:page pid}
|
||||
group (merge data dimensions)]
|
||||
:page pid}]
|
||||
(as-> state $
|
||||
(update-shapes-on-index $ selected' dimensions sid)
|
||||
(update-shapes-on-page $ pid selected sid)
|
||||
|
|
|
@ -204,23 +204,23 @@
|
|||
:width final-width
|
||||
:height final-height})))
|
||||
|
||||
(defn group-dimensions
|
||||
"Given a collection of shapes, calculates the
|
||||
dimensions of the resultant group."
|
||||
[shapes]
|
||||
{:pre [(seq shapes)]}
|
||||
(let [shapes (map container-rect shapes)
|
||||
x (apply min (map :x shapes))
|
||||
y (apply min (map :y shapes))
|
||||
x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
|
||||
y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
|
||||
width (- x' x)
|
||||
height (- y' y)]
|
||||
{:width width
|
||||
:height height
|
||||
:view-box [0 0 width height]
|
||||
:x x
|
||||
:y y}))
|
||||
;; (defn group-dimensions
|
||||
;; "Given a collection of shapes, calculates the
|
||||
;; dimensions of the resultant group."
|
||||
;; [shapes]
|
||||
;; {:pre [(seq shapes)]}
|
||||
;; (let [shapes (map container-rect shapes)
|
||||
;; x (apply min (map :x shapes))
|
||||
;; y (apply min (map :y shapes))
|
||||
;; x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
|
||||
;; y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
|
||||
;; width (- x' x)
|
||||
;; height (- y' y)]
|
||||
;; {:width width
|
||||
;; :height height
|
||||
;; :view-box [0 0 width height]
|
||||
;; :x x
|
||||
;; :y y}))
|
||||
|
||||
(defn outer-rect
|
||||
[shapes]
|
||||
|
|
Loading…
Add table
Reference in a new issue