🐛 Properly setup group on creation.

This commit is contained in:
Andrey Antukh 2020-06-09 15:53:26 +02:00
parent 4bdaab637c
commit b8dab7253e
2 changed files with 16 additions and 17 deletions

View file

@ -227,14 +227,11 @@
(defn- setup-image (defn- setup-image
[{:keys [metadata] :as shape} {:keys [x y width height] :as props}] [{:keys [metadata] :as shape} {:keys [x y width height] :as props}]
(assoc shape (-> (setup-rect shape props)
:x x (assoc
:y y :proportion (/ (:width metadata)
:width width (:height metadata))
:height height :proportion-lock true)))
:proportion (/ (:width metadata)
(:height metadata))
:proportion-lock true))
;; --- Coerce to Rect-like shape. ;; --- Coerce to Rect-like shape.

View file

@ -1209,21 +1209,23 @@
(when (not-empty selected) (when (not-empty selected)
(let [page-id (get-in state [:workspace-page :id]) (let [page-id (get-in state [:workspace-page :id])
objects (get-in state [:workspace-data page-id :objects]) objects (get-in state [:workspace-data page-id :objects])
selected-objects (map (partial get objects) selected) selected-objects (map (partial get objects) selected)
selection-rect (geom/selection-rect selected-objects) selrect (geom/selection-rect selected-objects)
frame-id (-> selected-objects first :frame-id) frame-id (-> selected-objects first :frame-id)
group-shape (group-shape id frame-id selected selection-rect) group (-> (group-shape id frame-id selected selrect)
frame-children (get-in objects [frame-id :shapes]) (geom/setup selrect))
index-frame (->> frame-children
(map-indexed vector) index (->> (get-in objects [frame-id :shapes])
(filter #(selected (second %))) (map-indexed vector)
(ffirst)) (filter #(selected (second %)))
(ffirst))
rchanges [{:type :add-obj rchanges [{:type :add-obj
:id id :id id
:frame-id frame-id :frame-id frame-id
:obj group-shape :obj group
:index index-frame} :index index}
{:type :mov-objects {:type :mov-objects
:parent-id id :parent-id id
:shapes (vec selected)}] :shapes (vec selected)}]