Skip to content

Instantly share code, notes, and snippets.

@postpostscript
Created August 29, 2016 20:01
Show Gist options
  • Save postpostscript/8b5a308e6d3a6ce6c30f02704cb40e90 to your computer and use it in GitHub Desktop.
Save postpostscript/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