0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-11 01:28:30 -05:00

Enable precise moviments using keyboard up/down/right/left keys.

This commit is contained in:
Andrey Antukh 2016-01-10 23:50:21 +02:00
parent a2401a4d7a
commit 6ecec4af0a
2 changed files with 21 additions and 1 deletions

View file

@ -188,6 +188,22 @@
(let [shape (get-in state [:shapes-by-id sid])]
(update-in state [:shapes-by-id sid] shapes/-move {:dx dx :dy dy})))))
(defn move-selected
"Move a minimal position unit the selected shapes."
[dir]
{:pre [(contains? #{:up :down :right :left} dir)]}
(reify
rs/WatchEvent
(-apply-watch [_ state]
(let [selected (get-in state [:workspace :selected])
delta (case dir
:up [0 -1]
:down [0 +1]
:right [+1 0]
:left [-1 0])]
(rx/from-coll
(map #(move-shape % delta) selected))))))
(defn update-shape-rotation
[sid rotation]
{:pre [(number? rotation)

View file

@ -19,7 +19,11 @@
:ctrl+shift+i #(rs/emit! (dw/toggle-toolbox :icons))
:ctrl+shift+l #(rs/emit! (dw/toggle-toolbox :layers))
:esc #(rs/emit! (dw/deselect-all))
:backspace #(rs/emit! (dw/remove-selected))})
:backspace #(rs/emit! (dw/remove-selected))
:up #(rs/emit! (dw/move-selected :up))
:down #(rs/emit! (dw/move-selected :down))
:right #(rs/emit! (dw/move-selected :right))
:left #(rs/emit! (dw/move-selected :left))})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keyboard Shortcuts Watcher