mirror of
https://github.com/penpot/penpot.git
synced 2026-09-09 21:49:10 +00:00
🐛 Fix issue on transforms/move function related to path shapes
Where shape contains nils for x and y coords
This commit is contained in:
parent
daeaf1548b
commit
9b477ca0eb
@ -608,6 +608,10 @@
|
|||||||
^boolean (mth/finite? d)
|
^boolean (mth/finite? d)
|
||||||
^boolean (every? mth/finite? others))))
|
^boolean (every? mth/finite? others))))
|
||||||
|
|
||||||
|
(defn safe+
|
||||||
|
[a b]
|
||||||
|
(if (mth/finite? a) (+ a b) a))
|
||||||
|
|
||||||
(defn max
|
(defn max
|
||||||
([a] a)
|
([a] a)
|
||||||
([a b] (mth/max a b))
|
([a b] (mth/max a b))
|
||||||
|
|||||||
@ -80,19 +80,22 @@
|
|||||||
(defn move
|
(defn move
|
||||||
"Move the shape relatively to its current
|
"Move the shape relatively to its current
|
||||||
position applying the provided delta."
|
position applying the provided delta."
|
||||||
[{:keys [type] :as shape} {dx :x dy :y}]
|
[shape point]
|
||||||
(let [dx (d/check-num dx 0)
|
(let [type (dm/get-prop shape :type)
|
||||||
dy (d/check-num dy 0)
|
dx (dm/get-prop point :x)
|
||||||
move-vec (gpt/point dx dy)]
|
dy (dm/get-prop point :y)
|
||||||
|
dx (d/check-num dx 0)
|
||||||
|
dy (d/check-num dy 0)
|
||||||
|
mvec (gpt/point dx dy)]
|
||||||
|
|
||||||
(-> shape
|
(-> shape
|
||||||
(update :selrect move-selrect move-vec)
|
(update :selrect move-selrect mvec)
|
||||||
(update :points move-points move-vec)
|
(update :points move-points mvec)
|
||||||
(d/update-when :x + dx)
|
(d/update-when :x d/safe+ dx)
|
||||||
(d/update-when :y + dy)
|
(d/update-when :y d/safe+ dy)
|
||||||
(d/update-when :position-data move-position-data dx dy)
|
(d/update-when :position-data move-position-data dx dy)
|
||||||
(cond-> (= :bool type) (update :bool-content gpa/move-content move-vec))
|
(cond-> (= :bool type) (update :bool-content gpa/move-content mvec))
|
||||||
(cond-> (= :path type) (update :content gpa/move-content move-vec)))))
|
(cond-> (= :path type) (update :content gpa/move-content mvec)))))
|
||||||
|
|
||||||
;; --- Absolute Movement
|
;; --- Absolute Movement
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user