Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get mouse position over scrollbar in Chrome

I need to detect when the cursor is hovering over the scrollbar. I'm using Chrome and jQuery. This works in Firefox but not in Chrome: http://jsfiddle.net/HQrrq/1/

The essence is:

$(document).mousemove(function(mouseMoveEvent){
        console.log(mouseMoveEvent.pageY);
});

So, simple question: how to I get the mouse position when hovering over the document scrollbar in Chrome?

like image 832
Spork Avatar asked Jan 30 '26 05:01

Spork


1 Answers

Could be a kind of workaround: {looks like need to handle some window resize too!}

http://jsfiddle.net/HQrrq/3/

var loremContainer = $('#loremContainer')[0],
    scrollbarWidth = loremContainer.offsetWidth - loremContainer.clientWidth,
    scrollbarHeight = loremContainer.offsetHeight - loremContainer.clientHeight;

$('#loremContainer').height($(window).height() - scrollbarHeight).width($(window).width() - scrollbarWidth);
like image 120
A. Wolff Avatar answered Jan 31 '26 19:01

A. Wolff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!