Skip to content

Instantly share code, notes, and snippets.

@Landish
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Landish/136ffad004ba30650440 to your computer and use it in GitHub Desktop.
Save Landish/136ffad004ba30650440 to your computer and use it in GitHub Desktop.
Cross-Platform Javascript Disable/Enable Mousewheel

##Disable

document.onmousewheel = function(){ stopWheel(); } /* IE7, IE8 */
if(document.addEventListener){ /* Chrome, Safari, Firefox */
    document.addEventListener('DOMMouseScroll', stopWheel, false);
}
 
function stopWheel(e){
    if(!e){ e = window.event; } /* IE7, IE8, Chrome, Safari */
    if(e.preventDefault) { e.preventDefault(); } /* Chrome, Safari, Firefox */
    e.returnValue = false; /* IE7, IE8 */
}

Enable

document.onmousewheel = null;  /* IE7, IE8 */
if(document.addEventListener){ /* Chrome, Safari, Firefox */
    document.removeEventListener('DOMMouseScroll', stopWheel, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment