From e43ca70245b148d7b0792f65df4d59d6927e5af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sun, 10 Apr 2016 19:07:24 +0200 Subject: [PATCH] Added round and limit to zoom steps (#7) --- src/uxbox/data/workspace.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 445013b05..e4f869495 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -16,6 +16,7 @@ [uxbox.data.shapes :as uds] [uxbox.data.worker :as wrk] [uxbox.util.datetime :as dt] + [uxbox.util.math :as mth] [uxbox.util.geom.point :as gpt])) ;; --- Workspace Initialization @@ -115,7 +116,7 @@ (defrecord IncreaseZoom [] rs/UpdateEvent (-apply-update [_ state] - (let [increase #(* % 1.05)] + (let [increase #(min (mth/precision (* % 1.05) 2) 3)] (update-in state [:workspace :zoom] (fnil increase 1))))) (defn increase-zoom @@ -127,7 +128,7 @@ (defrecord DecreaseZoom [] rs/UpdateEvent (-apply-update [_ state] - (let [decrease #(* % 0.95)] + (let [decrease #(max (mth/precision (* % 0.95) 2) 0.15)] (update-in state [:workspace :zoom] (fnil decrease 1))))) (defn decrease-zoom