mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 02:58:39 -05:00
Enable precise moviments using keyboard up/down/right/left keys.
This commit is contained in:
parent
a2401a4d7a
commit
6ecec4af0a
2 changed files with 21 additions and 1 deletions
|
@ -188,6 +188,22 @@
|
||||||
(let [shape (get-in state [:shapes-by-id sid])]
|
(let [shape (get-in state [:shapes-by-id sid])]
|
||||||
(update-in state [:shapes-by-id sid] shapes/-move {:dx dx :dy dy})))))
|
(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
|
(defn update-shape-rotation
|
||||||
[sid rotation]
|
[sid rotation]
|
||||||
{:pre [(number? rotation)
|
{:pre [(number? rotation)
|
||||||
|
|
|
@ -19,7 +19,11 @@
|
||||||
:ctrl+shift+i #(rs/emit! (dw/toggle-toolbox :icons))
|
:ctrl+shift+i #(rs/emit! (dw/toggle-toolbox :icons))
|
||||||
:ctrl+shift+l #(rs/emit! (dw/toggle-toolbox :layers))
|
:ctrl+shift+l #(rs/emit! (dw/toggle-toolbox :layers))
|
||||||
:esc #(rs/emit! (dw/deselect-all))
|
: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
|
;; Keyboard Shortcuts Watcher
|
||||||
|
|
Loading…
Add table
Reference in a new issue