0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 12:59:12 -05:00

Properly emit changes on rect dimensions are touched.

This commit is contained in:
Andrey Antukh 2020-01-16 20:00:48 +01:00
parent 55c2ad9644
commit 655c7ae023
2 changed files with 13 additions and 7 deletions

View file

@ -1095,8 +1095,6 @@
(s/def ::update-dimensions (s/def ::update-dimensions
(s/keys :opt-un [::width ::height])) (s/keys :opt-un [::width ::height]))
;; TODO: emit commit-changes
(defn update-dimensions (defn update-dimensions
"A helper event just for update the position "A helper event just for update the position
of the shape using the width and height attrs of the shape using the width and height attrs
@ -1105,9 +1103,19 @@
(us/assert ::us/uuid id) (us/assert ::us/uuid id)
(us/assert ::update-dimensions dimensions) (us/assert ::update-dimensions dimensions)
(ptk/reify ::update-dimensions (ptk/reify ::update-dimensions
IBatchedChange
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update-in state [:workspace-data :shapes-by-id id] geom/resize-dim dimensions)))) (let [shape-old (get-in state [:workspace-data :shapes-by-id id])
shape-new (geom/resize-dim shape-old dimensions)
operations (d/diff-maps shape-old shape-new)
change {:type :mod-shape
:session-id (:session-id state)
:operations operations
:id id}]
(-> state
(assoc-in [:workspace-data :shapes-by-id id] shape-new)
(update ::batched-changes (fnil conj []) change))))))
;; --- Shape Proportions ;; --- Shape Proportions

View file

@ -201,10 +201,8 @@
instead of absolute positions." instead of absolute positions."
[shape opts] [shape opts]
(case (:type shape) (case (:type shape)
:rect (resize-dim-rect shape opts) :cirle (resize-dim-circle shape opts)
:icon (resize-dim-rect shape opts) (resize-dim-rect shape opts)))
:image (resize-dim-rect shape opts)
:circle (resize-dim-circle shape opts)))
(defn- resize-dim-rect (defn- resize-dim-rect
[{:keys [proportion proportion-lock x y] :as shape} [{:keys [proportion proportion-lock x y] :as shape}