From 4aaa5c3e7a3ef61dc4e4d434697c84c1fd915821 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 5 Apr 2016 17:55:54 +0300 Subject: [PATCH] Add zoom events. --- src/uxbox/data/workspace.cljs | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 15ce6826db..3b030e585d 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -242,3 +242,39 @@ "Copy selected shapes to clipboard." ([] (PasteFromClipboard. nil)) ([id] (PasteFromClipboard. id))) + +;; --- Increase Zoom + +(defrecord IncreaseZoom [] + rs/UpdateEvent + (-apply-update [_ state] + (let [increase #(+ % 0.1)] + (update-in state [:workspace :zoom] (fnil increase 1))))) + +(defn increase-zoom + [] + (IncreaseZoom.)) + +;; --- Decrease Zoom + +(defrecord DecreaseZoom [] + rs/UpdateEvent + (-apply-update [_ state] + (let [decrease #(if (> % 0) (- % 0.1) 0)] + (update-in state [:workspace :zoom] (fnil decrease 1))))) + +(defn decrease-zoom + [] + (DecreaseZoom.)) + +;; --- Reset Zoom + +(defrecord ResetZoom [] + rs/UpdateEvent + (-apply-update [_ state] + (assoc-in state [:workspace :zoom] 1))) + +(defn reset-zoom + [] + (ResetZoom.)) +