Skip to content

Instantly share code, notes, and snippets.

@appel
Forked from theftprevention/jquery-scrolllock.js
Last active August 29, 2015 14:22
Show Gist options
  • Save appel/0a675f1f30a37c01763c to your computer and use it in GitHub Desktop.
Save appel/0a675f1f30a37c01763c to your computer and use it in GitHub Desktop.
$.fn.scrollLock=function(){return $(this).on("DOMMouseScroll mousewheel",function(h){var g=$(this),f=this.scrollTop,d=this.scrollHeight,b=g.height(),i=h.originalEvent.wheelDelta,a=i>0,c=function(){h.stopPropagation();h.preventDefault();h.returnValue=false;return false};if(!a&&-i>d-b-f){g.scrollTop(d);return c()}else{if(a&&i>f){g.scrollTop(0);return c()}}})};$.fn.scrollRelease=function(){return $(this).off("DOMMouseScroll mousewheel")};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment