mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 17:18:21 -05:00
Refactor basic mouse streams and atoms on workspace/base.
This commit is contained in:
parent
2982f347a4
commit
c7a38113a1
1 changed files with 17 additions and 17 deletions
|
@ -79,25 +79,32 @@
|
|||
|
||||
(defonce mouse-b (rx/bus))
|
||||
(defonce mouse-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(rx/dedupe mouse-b))
|
||||
|
||||
(defonce mouse-canvas-s
|
||||
(->> mouse-s
|
||||
(rx/map :canvas-coords)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-a
|
||||
(rx/to-atom mouse-s))
|
||||
(defonce mouse-canvas-a
|
||||
(rx/to-atom mouse-canvas-s))
|
||||
|
||||
(defonce mouse-viewport-s
|
||||
(->> mouse-s
|
||||
(rx/map :viewport-coords)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-viewport-a
|
||||
(rx/to-atom mouse-viewport-s))
|
||||
|
||||
(defonce mouse-absolute-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(->> mouse-s
|
||||
(rx/map :window-coords)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-ctrl-s
|
||||
(->> mouse-b
|
||||
(rx/filter #(= (:id %) (:id @page-l)))
|
||||
(->> mouse-s
|
||||
(rx/map :ctrl)
|
||||
(rx/dedupe)
|
||||
(rx/share)))
|
||||
|
||||
(defn- coords-delta
|
||||
|
@ -105,19 +112,12 @@
|
|||
(gpt/subtract new old))
|
||||
|
||||
(defonce mouse-delta-s
|
||||
(->> mouse-s
|
||||
(->> mouse-viewport-s
|
||||
(rx/sample 10)
|
||||
(rx/buffer 2 1)
|
||||
(rx/map coords-delta)
|
||||
(rx/share)))
|
||||
|
||||
(defonce mouse-position
|
||||
(->> mouse-s
|
||||
(rx/sample 10)
|
||||
(rx/to-atom)))
|
||||
|
||||
(defonce bounding-rect (atom {}))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Constants
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Add table
Reference in a new issue