From 558bcc07b2e29533f83b1749460f62f49330b239 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 17 Sep 2020 14:28:43 +0200 Subject: [PATCH] :bug: Fixed problem when create a shape with click --- .../src/app/main/data/workspace/drawing.cljs | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 75ad0a49b..a18dd5ff7 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -80,6 +80,7 @@ (gpt/point v v)) scalev)] (-> shape + (assoc ::click-draw? false) (assoc-in [:modifiers :resize-vector] scalev) (assoc-in [:modifiers :resize-origin] (gpt/point x y)) (assoc-in [:modifiers :resize-rotation] 0)))) @@ -112,7 +113,8 @@ (get-in [:workspace-drawing :object]) (geom/setup {:x (:x initial) :y (:y initial) :width 1 :height 1}) (assoc :frame-id fid) - (assoc ::initialized? true))] + (assoc ::initialized? true) + (assoc ::click-draw? true))] (rx/concat ;; Add shape to drawing state (rx/of #(assoc-in state [:workspace-drawing :object] shape)) @@ -123,6 +125,7 @@ #(update-in % [:workspace-drawing :object] assoc :x x :y y)))) (->> ms/mouse-position + (rx/filter #(> (gpt/distance % initial) 2)) (rx/with-latest vector ms/mouse-position-ctrl) (rx/switch-map (fn [[point :as current]] @@ -269,15 +272,23 @@ (rx/concat (rx/of dw/clear-drawing) (when (::initialized? shape) - (let [shape-min-width (case (:type shape) - :text 20 - 5) - shape-min-height (case (:type shape) - :text 16 - 5) + (let [shape-click-width (case (:type shape) + :text 150 + 20) + shape-click-height (case (:type shape) + :text 40 + 20) + shape (if (::click-draw? shape) + (-> shape + (assoc-in [:modifiers :resize-vector] + (gpt/point shape-click-width shape-click-height)) + (assoc-in [:modifiers :resize-origin] + (gpt/point (:x shape) (:y shape)))) + shape) shape (-> shape geom/transform-shape - (dissoc ::initialized?)) ] + (dissoc ::initialized? + ::click-draw?))] ;; Add & select the created shape to the workspace (rx/of dw/deselect-all (dw/add-shape shape)))))))))