Skip to content

Instantly share code, notes, and snippets.

@danielrw7
Created August 29, 2016 20:01
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 danielrw7/8b5a308e6d3a6ce6c30f02704cb40e90 to your computer and use it in GitHub Desktop.
Save danielrw7/8b5a308e6d3a6ce6c30f02704cb40e90 to your computer and use it in GitHub Desktop.
var scrollLock = {
scrollTop: 0,
lock: function(scrollTop) {
if (typeof scrollTop == "number") {
this.scrollTop = scrollTop;
}
$(window).on("scroll", this.onScroll);
},
unlock: function() {
$(window).off("scroll", this.onScroll);
}
};
scrollLock.onScroll = (function() {
$(window).scrollTop(this.scrollTop);
}).bind(scrollLock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment