Any suggestions for how to listen for mousedown on $(document)
except a div's overflow:scroll scrollbar?
I am not sure what element the scrollbar is in order to refer to it...
Any suggestions for how to listen for mousedown on $(document)
except a div's overflow:scroll scrollbar?
I am not sure what element the scrollbar is in order to refer to it...
You can check the target yourself with :
$(document).on('mousedown', function(e) {
console.log(e.target);
});
The scrollbar is'nt really an element, and click handlers won't work, but it seems mousedown is fired, but will just give you the element the scrollbar belongs to.
To exclude just the scrollbar I'm guessing you will have to figure out it's size, and then check the mouse position on mousedown to see if it's within the scrollbar area.
<div class='scrollHolder' style='overflow:scroll;'>
<div class='scrollContent'>
</div>
</div>
$(document).on( "mousedown", function( event )
{
var onScrollbar = false;
if (event.target.className == "scrollHolder")
{
var s_c = $(event.target).children(".scrollContent");
if (event.pageX-s_c.offset().left > s_c.innerWidth())
{
onScrollbar = true;
}
}
});