Created
August 25, 2015 11:36
-
-
Save KristobalJunta/8313cb7fd47c9fdfe1c3 to your computer and use it in GitHub Desktop.
A JS to toggle scrolling w/o hiding scrollbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable scrolling without hiding scrolbar | |
document.onmousewheel=document.onwheel=function(){ | |
return false; | |
}; | |
document.addEventListener("MozMousePixelScroll",function(){return false},false); | |
document.onkeydown=function(e) { | |
if (e.keyCode>=33&&e.keyCode<=40) return false; | |
} | |
// enabling in again | |
document.onmousewheel=document.onwheel=function(){ | |
return true; | |
}; | |
document.addEventListener("MozMousePixelScroll",function(){return true},true); | |
document.onkeydown=function(e) { | |
if (e.keyCode>=33&&e.keyCode<=40) return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment