🐛 Fix problem with moving+selection not working properly

This commit is contained in:
alonso.torres 2024-06-07 13:51:12 +02:00
parent d29215a282
commit 2c21a049e1
3 changed files with 19 additions and 10 deletions

View file

@ -72,12 +72,20 @@
(defn drag-stopper
"Creates a stream to stop drag events. Takes into account the mouse and also
if the window loses focus or the esc key is pressed."
[stream]
(rx/merge
(->> stream
(rx/filter blur-event?))
(->> stream
(rx/filter mouse-event?)
(rx/filter mouse-up-event?))
(->> stream
(rx/filter #(= % :interrupt)))))
([stream]
(drag-stopper stream nil))
([stream {:keys [blur? up-mouse? interrupt?] :or {blur? true up-mouse? true interrupt? true}}]
(rx/merge
(if blur?
(->> stream
(rx/filter blur-event?))
(rx/empty))
(if up-mouse?
(->> stream
(rx/filter mouse-event?)
(rx/filter mouse-up-event?))
(rx/empty))
(if interrupt?
(->> stream
(rx/filter #(= % :interrupt)))
(rx/empty)))))