From c3ddf2ad3281a84f5fc1a560af6d6b72e30a6ea8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 30 Jan 2016 20:18:31 +0200 Subject: [PATCH] Add absolute mouse position stream. --- src/uxbox/ui/workspace/base.cljs | 7 ++++++- src/uxbox/ui/workspace/canvas.cljs | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/uxbox/ui/workspace/base.cljs b/src/uxbox/ui/workspace/base.cljs index bc2d365df..0b273c072 100644 --- a/src/uxbox/ui/workspace/base.cljs +++ b/src/uxbox/ui/workspace/base.cljs @@ -89,7 +89,12 @@ (defonce mouse-s (->> mouse-b (rx/filter #(= (:id %) (:id @page-l))) - (rx/map :coords))) + (rx/map :canvas-coords))) + +(defonce mouse-absolute-s + (->> mouse-b + (rx/filter #(= (:id %) (:id @page-l))) + (rx/map :window-coords))) (defn- coords-delta [[old new]] diff --git a/src/uxbox/ui/workspace/canvas.cljs b/src/uxbox/ui/workspace/canvas.cljs index 5b8a42a74..130bd647b 100644 --- a/src/uxbox/ui/workspace/canvas.cljs +++ b/src/uxbox/ui/workspace/canvas.cljs @@ -112,8 +112,9 @@ (let [x (.-clientX event) y (.-clientY event) event {:id (:id page) - :coords [(- x offset-x) - (- y offset-y)]}] + :window-coords [x y] + :canvas-coords [(- x offset-x) + (- y offset-y)]}] (rx/push! wb/mouse-b event)))] (let [[page] (:rum/props own) canvas (mx/get-ref-dom own (str "canvas" (:id page)))