From 8aedbd1418b9d5eebaf22e474aa33e6cd1dbb889 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 2 Feb 2021 15:36:49 +0100 Subject: [PATCH] :bug: Fixes problems with paste empty text --- frontend/src/app/main/data/workspace.cljs | 2 +- frontend/src/app/main/data/workspace/drawing/box.cljs | 7 ++++++- frontend/src/app/main/ui/workspace/selection.cljs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index e01eab722..ae552a469 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1564,7 +1564,7 @@ (watch [_ state stream] (let [id (uuid/next) {:keys [x y]} @ms/mouse-position - width (min (* 7 (count text)) 700) + width (max 8 (min (* 7 (count text)) 700)) height 16 page-id (:current-page-id state) frame-id (-> (dwc/lookup-page-objects state page-id) diff --git a/frontend/src/app/main/data/workspace/drawing/box.cljs b/frontend/src/app/main/data/workspace/drawing/box.cljs index 669da547b..699302067 100644 --- a/frontend/src/app/main/data/workspace/drawing/box.cljs +++ b/frontend/src/app/main/data/workspace/drawing/box.cljs @@ -21,12 +21,17 @@ [app.main.data.workspace.drawing.common :as common] [app.common.math :as mth])) +(defn truncate-zero [num default] + (if (mth/almost-zero? num) default num)) + (defn resize-shape [{:keys [x y width height transform transform-inverse] :as shape} point lock?] (let [;; The new shape behaves like a resize on the bottom-right corner initial (gpt/point (+ x width) (+ y height)) shapev (gpt/point width height) deltav (gpt/to-vec initial point) - scalev (gpt/divide (gpt/add shapev deltav) shapev) + scalev (-> (gpt/divide (gpt/add shapev deltav) shapev) + (update :x truncate-zero 1) + (update :y truncate-zero 1)) scalev (if lock? (let [v (max (:x scalev) (:y scalev))] (gpt/point v v)) diff --git a/frontend/src/app/main/ui/workspace/selection.cljs b/frontend/src/app/main/ui/workspace/selection.cljs index f2b916974..ddfb7b0b1 100644 --- a/frontend/src/app/main/ui/workspace/selection.cljs +++ b/frontend/src/app/main/ui/workspace/selection.cljs @@ -176,7 +176,7 @@ :y cy' :width resize-point-circle-radius :height resize-point-circle-radius - :transform (str/fmt "rotate(%s, %s, %s)" rotation cx' cy') + :transform (when rotation (str/fmt "rotate(%s, %s, %s)" rotation cx' cy')) :style {:fill (if (debug? :resize-handler) "red" "transparent") :cursor cursor} :on-mouse-down #(on-resize {:x cx' :y cy'} %)}])