Skip to content

Instantly share code, notes, and snippets.

@KristobalJunta
Created August 25, 2015 11:36
Show Gist options
  • Save KristobalJunta/8313cb7fd47c9fdfe1c3 to your computer and use it in GitHub Desktop.
Save KristobalJunta/8313cb7fd47c9fdfe1c3 to your computer and use it in GitHub Desktop.
A JS to toggle scrolling w/o hiding scrollbar
// 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