0
Fork 0
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:
Andrey Antukh 2016-04-26 21:03:26 +03:00
parent 0969d62a50
commit dfe5765d50
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
4 changed files with 10 additions and 11 deletions

View file

@ -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)

View file

@ -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 %)))))

View file

@ -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)))

View file

@ -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