0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Handle properly the mouse capture.

This commit is contained in:
Andrey Antukh 2021-03-15 15:52:23 +01:00
parent fde6126ac6
commit 48747d9553

View file

@ -435,11 +435,12 @@
(mf/use-callback
(fn [event]
(let [target (dom/get-target event)
closest (.closest target ".public-DraftStyleDefault-block")]
(when-not closest
;; Capture mouse pointer to detect the movements even if cursor
;; leaves the viewport or the browser itself
;; https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
closest (.closest target "foreignObject")]
;; Capture mouse pointer to detect the movements even if cursor
;; leaves the viewport or the browser itself
;; https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
(if closest
(.setPointerCapture closest (.-pointerId event))
(.setPointerCapture target (.-pointerId event))))))
on-pointer-up