Created
November 22, 2012 23:55
-
-
Save jhthorsen/4133369 to your computer and use it in GitHub Desktop.
disable outer scroll
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($) { | |
$.fn.disableOuterScroll = function() { | |
return this.bind('mousewheel DOMMouseScroll', function(e) { | |
var scrollTo = null; | |
if(e.type == 'mousewheel') { | |
scrollTo = (e.originalEvent.wheelDelta * -1); | |
} | |
else if(e.type == 'DOMMouseScroll') { | |
scrollTo = 40 * e.originalEvent.detail; | |
} | |
if(scrollTo) { | |
e.preventDefault(); | |
$(this).scrollTop(scrollTo + $(this).scrollTop()); | |
} | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment