Right now I'm stopping drag events on mouse up, like so:
$(document).mouseup(_onMouseUp);
However I need to capture mouse up events when the mouse leaves the browser window, similar to releaseOutside
in Flash.
Is this possible in JS?
You can capture mouseup events outside the browser window in every major browser: Chrome, Edge and Firefox.
You just need to attach the listener to the 'window' object, like this:
window.addEventListener('mouseup',
() => console.log('mouse up captured outside the window'));
https://codepen.io/fredrikborgstrom/pen/vRBaZw
or in your case, using jQuery, it would be:
$(window).mouseup(_onMouseUp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With