From 28047aa64d4d965b46619c8a297215811476ee7b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 28 Jan 2016 20:24:46 +0200 Subject: [PATCH] Stop using group-dimensions on groupe creation. --- src/uxbox/data/workspace.cljs | 7 ++----- src/uxbox/shapes.cljs | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index aca5c14b7..637f1c240 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -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) diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 19fa12392..fa75ca3dc 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -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]