diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index 5f1c0c45d6..7460bb9d7e 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -608,6 +608,10 @@ ^boolean (mth/finite? d) ^boolean (every? mth/finite? others)))) +(defn safe+ + [a b] + (if (mth/finite? a) (+ a b) a)) + (defn max ([a] a) ([a b] (mth/max a b)) diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index 03932bf7f7..d7f51ff64a 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -80,19 +80,22 @@ (defn move "Move the shape relatively to its current position applying the provided delta." - [{:keys [type] :as shape} {dx :x dy :y}] - (let [dx (d/check-num dx 0) - dy (d/check-num dy 0) - move-vec (gpt/point dx dy)] + [shape point] + (let [type (dm/get-prop shape :type) + dx (dm/get-prop point :x) + dy (dm/get-prop point :y) + dx (d/check-num dx 0) + dy (d/check-num dy 0) + mvec (gpt/point dx dy)] (-> shape - (update :selrect move-selrect move-vec) - (update :points move-points move-vec) - (d/update-when :x + dx) - (d/update-when :y + dy) + (update :selrect move-selrect mvec) + (update :points move-points mvec) + (d/update-when :x d/safe+ dx) + (d/update-when :y d/safe+ dy) (d/update-when :position-data move-position-data dx dy) - (cond-> (= :bool type) (update :bool-content gpa/move-content move-vec)) - (cond-> (= :path type) (update :content gpa/move-content move-vec))))) + (cond-> (= :bool type) (update :bool-content gpa/move-content mvec)) + (cond-> (= :path type) (update :content gpa/move-content mvec))))) ;; --- Absolute Movement