Last active
October 6, 2015 13:56
-
-
Save 50percentgrey/276381a4bcc8ba4d831e to your computer and use it in GitHub Desktop.
MouseWheel all browsers
This file contains 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
function handle(delta) { | |
if (delta < 0){ | |
/* scrolling up */ | |
} else { | |
/* scrolling down */ | |
} | |
} | |
function wheel(event){var delta=0;if(!event)event=window.event;if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera)delta=-delta;}else if(event.detail){delta=-event.detail/3;}if(delta)handle(delta);if(event.preventDefault)event.preventDefault();event.returnValue=false;}if(window.addEventListener)window.addEventListener('DOMMouseScroll',wheel,false);window.onmousewheel=document.onmousewheel=wheel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment