Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable horizontal scrolling by clicking the mouse wheel in the element with overflow-x:hidden

How can I determine the possibility of horizontal scrolling by clicking the mouse wheel and disable it in the element with overflow-x:hidden (using JavaScript or jQuery)? Scrolling is impossible in Firefox but possible in IE, Chrome and Safari. Code example:

<div style="overflow-x:hidden; overflow-y:auto;">...</div>

Screenshots:

FirefoxChromeSafariIE

like image 814
volkut Avatar asked Nov 16 '12 14:11

volkut


Video Answer


1 Answers

Perfectly possible, but not best practise (I presume you have a really good reason for wanting to do it, though):

$('#yourDivId').on('scroll', function(){
    $('#container').scrollLeft(0);
});​

See http://jsfiddle.net/q5CTS/3/ for a working snippet.

like image 128
MassivePenguin Avatar answered Nov 09 '22 12:11

MassivePenguin