From d73781f51ca59aea1599406aa0ce2a28f0c822f0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 22 Jan 2016 19:36:47 +0200 Subject: [PATCH] Make translate-coords parametrizable with operation. --- src/uxbox/shapes.cljs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 951d0b0dc..90b718b9f 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -144,10 +144,12 @@ (defn translate-coords "Given a shape and initial coords, transform it mapping its coords to new provided initial coords." - [shape x y] - (let [x' (:x shape) - y' (:y shape)] - (assoc shape :x (- x' x) :y (- y' y)))) + ([shape x y] + (translate-coords shape x y -)) + ([shape x y op] + (let [x' (:x shape) + y' (:y shape)] + (assoc shape :x (op x' x) :y (op y' y))))) (defn resolve-position "Recursively resolve the real shape position in