0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 16:30:37 -05:00

Add absolute mouse position stream.

This commit is contained in:
Andrey Antukh 2016-01-30 20:18:31 +02:00
parent 0b5de2d2b8
commit c3ddf2ad32
2 changed files with 9 additions and 3 deletions

View file

@ -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]]

View file

@ -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)))