Minor enhancements in selection and movement

This commit is contained in:
alonso.torres 2020-05-13 09:28:37 +02:00
parent 27810c9df8
commit e9c97ef5d0
2 changed files with 6 additions and 5 deletions

View file

@ -272,9 +272,9 @@
(s/def ::direction #{:up :down :right :left}) (s/def ::direction #{:up :down :right :left})
(defn move-selected (defn move-selected
[direction align?] [direction shift?]
(us/verify ::direction direction) (us/verify ::direction direction)
(us/verify boolean? align?) (us/verify boolean? shift?)
(let [same-event (js/Symbol "same-event")] (let [same-event (js/Symbol "same-event")]
(ptk/reify ::move-selected (ptk/reify ::move-selected
@ -299,7 +299,8 @@
stopper (->> move-events stopper (->> move-events
(rx/debounce 100) (rx/debounce 100)
(rx/first)) (rx/first))
mov-vec (get-displacement direction)] scale (if shift? (gpt/point 10) (gpt/point 1))
mov-vec (gpt/multiply (get-displacement direction) scale)]
(rx/concat (rx/concat
(rx/merge (rx/merge
@ -307,7 +308,7 @@
(rx/take-until stopper) (rx/take-until stopper)
(rx/scan #(gpt/add %1 mov-vec) (gpt/point 0 0)) (rx/scan #(gpt/add %1 mov-vec) (gpt/point 0 0))
(rx/map #(set-modifiers selected {:displacement (gmt/translate-matrix %)}))) (rx/map #(set-modifiers selected {:displacement (gmt/translate-matrix %)})))
(rx/of (move-selected direction align?))) (rx/of (move-selected direction shift?)))
(rx/of (apply-modifiers selected) (rx/of (apply-modifiers selected)
(fn [state] (-> state (fn [state] (-> state

View file

@ -112,7 +112,7 @@
:bottom-right [(+ x width) (+ y height)]}] :bottom-right [(+ x width) (+ y height)]}]
[:g.controls [:g.controls
(when (not (#{:move :rotate :resize} current-transform)) (when (not (#{:move :rotate} current-transform))
[:rect.main [:rect.main
{:transform transform {:transform transform
:x x :y y :x x :y y