Skip to content

Instantly share code, notes, and snippets.

@yarliganfatih
Created June 13, 2022 21:07
Show Gist options
  • Save yarliganfatih/2ad1f6f5f5baae451ffa99352bd3a138 to your computer and use it in GitHub Desktop.
Save yarliganfatih/2ad1f6f5f5baae451ffa99352bd3a138 to your computer and use it in GitHub Desktop.
Auto Scroll Infinity Loop
function scrollLoop(delay=5000){ // delay for a animation duration
$('html, body').on('down', function () {
$(this).animate({ scrollTop: $(document).height() - $(window).height() }, delay);
$(this).trigger('up');
});
$('html, body').on('up', function () {
$(this).animate({ scrollTop: 0 }, delay);
$(this).trigger('down');
});
$('html, body').trigger('down'); // start with scroll down
}
scrollLoop(3000); // call Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment