Skip to content

Instantly share code, notes, and snippets.

@jhthorsen
Created November 22, 2012 23:55
Show Gist options
  • Save jhthorsen/4133369 to your computer and use it in GitHub Desktop.
Save jhthorsen/4133369 to your computer and use it in GitHub Desktop.
disable outer scroll
(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