mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
parent
cc0f99333f
commit
25d8d76524
1 changed files with 19 additions and 10 deletions
|
@ -222,7 +222,7 @@
|
|||
root
|
||||
transformed-root)))]
|
||||
(reduce set-child
|
||||
(update-in modif-tree [(:id shape) :modifiers] #(merge % modifiers))
|
||||
(assoc-in modif-tree [(:id shape) :modifiers] modifiers)
|
||||
children)))
|
||||
|
||||
(defn- check-delta
|
||||
|
@ -281,7 +281,7 @@
|
|||
(defn start-resize
|
||||
"Enter mouse resize mode, until mouse button is released."
|
||||
[handler ids shape]
|
||||
(letfn [(resize [shape initial layout [point lock? point-snap]]
|
||||
(letfn [(resize [shape initial layout [point lock? center? point-snap]]
|
||||
(let [{:keys [width height]} (:selrect shape)
|
||||
{:keys [rotation]} shape
|
||||
rotation (or rotation 0)
|
||||
|
@ -303,6 +303,11 @@
|
|||
(gpt/transform (gmt/rotate-matrix (- rotation)))
|
||||
(gpt/multiply handler-mult))
|
||||
|
||||
displacement (when center?
|
||||
(-> (gpt/point (/ (:x deltav) (if (neg? (:x handler-mult)) 2 -2))
|
||||
(/ (:y deltav) (if (neg? (:y handler-mult)) 2 -2)))
|
||||
(gpt/transform (:transform shape))))
|
||||
|
||||
;; Resize vector
|
||||
scalev (gpt/divide (gpt/add shapev deltav) shapev)
|
||||
|
||||
|
@ -325,8 +330,12 @@
|
|||
(gsh/transform-point-center shape-center shape-transform))]
|
||||
|
||||
(rx/of (set-modifiers ids
|
||||
{:resize-vector scalev
|
||||
:resize-origin origin
|
||||
{:displacement (when displacement
|
||||
(gmt/translate-matrix displacement))
|
||||
:resize-vector scalev
|
||||
:resize-origin (if displacement
|
||||
(gpt/add origin displacement)
|
||||
origin)
|
||||
:resize-transform shape-transform
|
||||
:resize-scale-text scale-text
|
||||
:resize-transform-inverse shape-transform-inverse}))))
|
||||
|
@ -334,9 +343,9 @@
|
|||
;; Unifies the instantaneous proportion lock modifier
|
||||
;; activated by Shift key and the shapes own proportion
|
||||
;; lock flag that can be activated on element options.
|
||||
(normalize-proportion-lock [[point shift?]]
|
||||
(normalize-proportion-lock [[point shift? alt?]]
|
||||
(let [proportion-lock? (:proportion-lock shape)]
|
||||
[point (or proportion-lock? shift?)]))]
|
||||
[point (or proportion-lock? shift?) alt?]))]
|
||||
(reify
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -358,11 +367,11 @@
|
|||
(rx/concat
|
||||
(rx/of (dch/update-shapes text-shapes-ids #(assoc % :grow-type :fixed)))
|
||||
(->> ms/mouse-position
|
||||
(rx/with-latest vector ms/mouse-position-shift)
|
||||
(rx/with-latest-from ms/mouse-position-shift ms/mouse-position-alt)
|
||||
(rx/map normalize-proportion-lock)
|
||||
(rx/switch-map (fn [[point :as current]]
|
||||
(->> (snap/closest-snap-point page-id resizing-shapes layout zoom point)
|
||||
(rx/map #(conj current %)))))
|
||||
(rx/switch-map (fn [[point _ _ :as current]]
|
||||
(->> (snap/closest-snap-point page-id resizing-shapes layout zoom point)
|
||||
(rx/map #(conj current %)))))
|
||||
(rx/mapcat (partial resize shape initial-position layout))
|
||||
(rx/take-until stoper))
|
||||
(rx/of (apply-modifiers ids)
|
||||
|
|
Loading…
Add table
Reference in a new issue