Skip to content

Instantly share code, notes, and snippets.

@dbarria
Last active May 18, 2017 01:35
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 dbarria/456e52fdb07e1dc4b8e0407807896e12 to your computer and use it in GitHub Desktop.
Save dbarria/456e52fdb07e1dc4b8e0407807896e12 to your computer and use it in GitHub Desktop.
$.finishScroll = false;
$.scrollFullPage = function() {
var scroll = 0;
var time = 0;
var body = document.body,
html = document.documentElement;
var realHeight = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
while(scroll < realHeight){
time = time + 1600;
scroll = scroll + $(window).height();
(function(scroll, time){
setTimeout(function() {
console.log($.finishScroll);
$.smoothScroll({
speed: 800,
afterScroll: function() {
if(scroll >= realHeight){
$.finishScroll = true;
}
}
},'+=' + $(window).height())
}, time);
})(scroll, time);
}
}
$.scrollFullPage();
$.finishScroll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment