mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 12:59:12 -05:00
Improve proportions persistence handling on shapes.
This commit is contained in:
parent
0a28efb838
commit
6ebeaf521a
3 changed files with 8 additions and 22 deletions
|
@ -241,20 +241,6 @@
|
|||
(update-in state [:shapes-by-id sid] assoc
|
||||
:proportion-lock false))))
|
||||
|
||||
(defn setup-proportions
|
||||
[sid]
|
||||
{:pre [(uuid? sid)]}
|
||||
(reify
|
||||
udp/IPageUpdate
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(let [[width height] (-> (get-in state [:shapes-by-id sid])
|
||||
(geom/size)
|
||||
(keep [:width :height]))
|
||||
proportion (/ width height)]
|
||||
(update-in state [:shapes-by-id sid] assoc
|
||||
:proportion proportion)))))
|
||||
|
||||
;; --- Group Collapsing
|
||||
|
||||
(defn collapse-shape
|
||||
|
|
|
@ -284,27 +284,28 @@
|
|||
(declare setup-proportions-rect)
|
||||
(declare setup-proportions-image)
|
||||
|
||||
;; FIXME: improve proportions setup for icons.
|
||||
|
||||
(defn setup-proportions
|
||||
[shape]
|
||||
(case (:type shape)
|
||||
:rect (setup-proportions-rect shape)
|
||||
:icon (setup-proportions-rect shape)
|
||||
:circle (setup-proportions-rect shape)
|
||||
:icon (setup-proportions-image shape)
|
||||
:image (setup-proportions-image shape)
|
||||
shape))
|
||||
:text shape))
|
||||
|
||||
(defn setup-proportions-image
|
||||
[{:keys [metadata] :as shape}]
|
||||
(println "setup-proportions-image" shape)
|
||||
(let [{:keys [width height]} metadata]
|
||||
(assoc shape :proportion (/ width height))))
|
||||
(assoc shape
|
||||
:proportion (/ width height)
|
||||
:proportion-lock true)))
|
||||
|
||||
(defn setup-proportions-rect
|
||||
[shape]
|
||||
(let [{:keys [width height]} (size shape)]
|
||||
(assoc shape :proportion (/ width height))))
|
||||
(assoc shape
|
||||
:proportion (/ width height)
|
||||
:proportion-lock true)))
|
||||
|
||||
;; --- Resize (Dimentsions)
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
(let [params {:vid vid :delta (assoc delta :lock ctrl?)}]
|
||||
(rs/emit! (uds/update-vertex-position sid params))))
|
||||
(on-end []
|
||||
(rs/emit! (uds/setup-proportions sid))
|
||||
(rlocks/release! :shape/resize))]
|
||||
(let [stoper (->> wb/events-s
|
||||
(rx/map first)
|
||||
|
|
Loading…
Add table
Reference in a new issue