mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 17:21:17 -05:00
Improve alignment when zoom is applied.
This commit is contained in:
parent
0969d62a50
commit
dfe5765d50
4 changed files with 10 additions and 11 deletions
|
@ -119,6 +119,7 @@
|
|||
(defonce mouse-delta-s
|
||||
(->> mouse-viewport-s
|
||||
(rx/sample 10)
|
||||
(rx/map #(gpt/divide % @zoom-l))
|
||||
(rx/mapcat (fn [point]
|
||||
(if @alignment-l
|
||||
(uds/align-point point)
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
(rx/filter empty?)
|
||||
(rx/take 1))
|
||||
stream (->> wb/mouse-delta-s
|
||||
(rx/take-until stoper)
|
||||
(rx/map #(gpt/divide % @wb/zoom-l)))]
|
||||
(rx/take-until stoper))]
|
||||
(when @wb/alignment-l
|
||||
(rs/emit! (uds/initial-align-shape shape)))
|
||||
(rx/subscribe stream #(rs/emit! (uds/move-shape shape %)))))
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
(rx/take 1))
|
||||
stream (->> wb/mouse-delta-s
|
||||
(rx/take-until stoper)
|
||||
(rx/map #(gpt/divide % @wb/zoom-l))
|
||||
(rx/with-latest-from vector wb/mouse-ctrl-s))]
|
||||
(when @wb/alignment-l
|
||||
(rs/emit! (uds/initial-vertext-align shape vid)))
|
||||
|
|
|
@ -49,26 +49,26 @@
|
|||
for rect-like shapes."
|
||||
[shape {dx :x dy :y}]
|
||||
(assoc shape
|
||||
:x1 (+ (:x1 shape) dx)
|
||||
:y1 (+ (:y1 shape) dy)
|
||||
:x2 (+ (:x2 shape) dx)
|
||||
:y2 (+ (:y2 shape) dy)))
|
||||
:x1 (mth/round (+ (:x1 shape) dx))
|
||||
:y1 (mth/round (+ (:y1 shape) dy))
|
||||
:x2 (mth/round (+ (:x2 shape) dx))
|
||||
:y2 (mth/round (+ (:y2 shape) dy))))
|
||||
|
||||
(defn- move-circle
|
||||
"A specialized function for relative movement
|
||||
for circle shapes."
|
||||
[shape {dx :x dy :y}]
|
||||
(assoc shape
|
||||
:cx (+ (:cx shape) dx)
|
||||
:cy (+ (:cy shape) dy)))
|
||||
:cx (mth/round (+ (:cx shape) dx))
|
||||
:cy (mth/round (+ (:cy shape) dy))))
|
||||
|
||||
(defn- move-group
|
||||
"A specialized function for relative movement
|
||||
for group shapes."
|
||||
[shape {dx :x dy :y}]
|
||||
(assoc shape
|
||||
:dx (+ (:dx shape 0) dx)
|
||||
:dy (+ (:dy shape 0) dy)))
|
||||
:dx (mth/round (+ (:dx shape 0) dx))
|
||||
:dy (mth/round (+ (:dy shape 0) dy))))
|
||||
|
||||
;; --- Absolute Movement
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue