mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
Add mouse-ctrl stream and improve general stream performance.
This commit is contained in:
parent
4cf702fb0b
commit
e84246aecd
2 changed files with 15 additions and 3 deletions
|
@ -89,12 +89,21 @@
|
|||
(defonce mouse-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(rx/map :canvas-coords)))
|
||||
(rx/map :canvas-coords)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-absolute-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(rx/map :window-coords)))
|
||||
(rx/map :window-coords)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-ctrl-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(rx/map :ctrl)
|
||||
(rx/dedupe)
|
||||
(rx/share)))
|
||||
|
||||
(defn- coords-delta
|
||||
[[old new]]
|
||||
|
@ -107,7 +116,8 @@
|
|||
(->> mouse-s
|
||||
(rx/sample 10)
|
||||
(rx/buffer 2 1)
|
||||
(rx/map coords-delta)))
|
||||
(rx/map coords-delta)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-position
|
||||
(->> mouse-s
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
[uxbox.data.workspace :as dw]
|
||||
[uxbox.ui.mixins :as mx]
|
||||
[uxbox.ui.dom :as dom]
|
||||
[uxbox.ui.keyboard :as kbd]
|
||||
[uxbox.ui.workspace.base :as wb]
|
||||
[uxbox.ui.workspace.canvas.movement]
|
||||
[uxbox.ui.workspace.canvas.draw :refer (draw-area)]
|
||||
|
@ -112,6 +113,7 @@
|
|||
(let [x (.-clientX event)
|
||||
y (.-clientY event)
|
||||
event {:id (:id page)
|
||||
:ctrl (kbd/ctrl? event)
|
||||
:window-coords [x y]
|
||||
:canvas-coords [(- x offset-x)
|
||||
(- y offset-y)]}]
|
||||
|
|
Loading…
Add table
Reference in a new issue