Reputation: 192
I want to trigger mousemove event if i went outside the element
Sandbox: https://codesandbox.io/s/smoosh-morning-r7lv24?file=/src/Range/Range.js
I want that when I click on the Thumb, it moves, even if I go outside the block
Upvotes: 0
Views: 1458
Reputation: 405
I have modified your sandbox to allow moving the rail outside the component
Sandbox: link here
You need to attach listeners when the mouse is down and remove them when mouse is up. These listeners should be attached to the document so you can still listen outside the component. You can also improve this further to remove listeners when component is unmounted or when window is blurred.
Upvotes: 3