diff --git a/frontend/uxbox/data/workspace.cljs b/frontend/uxbox/data/workspace.cljs index 1652658b9..05ece16eb 100644 --- a/frontend/uxbox/data/workspace.cljs +++ b/frontend/uxbox/data/workspace.cljs @@ -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) diff --git a/frontend/uxbox/ui/workspace/shortcuts.cljs b/frontend/uxbox/ui/workspace/shortcuts.cljs index efb99ba98..3ccd36096 100644 --- a/frontend/uxbox/ui/workspace/shortcuts.cljs +++ b/frontend/uxbox/ui/workspace/shortcuts.cljs @@ -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