0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Make update-size event work with different types of shapes.

Thanks to the previously added `resize-dim` geom helpers.
This commit is contained in:
Andrey Antukh 2016-09-29 07:06:03 +02:00
parent b3207b5746
commit e30871bd48
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -108,25 +108,14 @@
(defn update-size
"A helper event just for update the position
of the shape using the width and heigt attrs
instread final point of coordinates.
WARN: only works with shapes that works
with height and width such are ::rect"
[sid {:keys [width height] :as opts}]
of the shape using the width and height attrs
instread final point of coordinates."
[sid opts]
(reify
udp/IPageUpdate
rs/UpdateEvent
(-apply-update [_ state]
(letfn [(resize [shape {:keys [width height] :as size}]
(let [x1 (:x1 shape)
y1 (:y1 shape)]
(assoc shape
:x2 (+ x1 width)
:y2 (+ y1 height))))]
(let [shape (get-in state [:shapes-by-id sid])
size (merge (geom/size shape) opts)]
(update-in state [:shapes-by-id sid] resize size))))))
(update-in state [:shapes-by-id sid] geom/resize-dim opts))))
(defn update-vertex-position
[id {:keys [vid delta]}]