Skip to content

Instantly share code, notes, and snippets.

@sabapathygithub
Last active July 12, 2024 04:06
Show Gist options
  • Save sabapathygithub/e6ca2c0fd06c21c5fb608b9a172ca3c4 to your computer and use it in GitHub Desktop.
Save sabapathygithub/e6ca2c0fd06c21c5fb608b9a172ca3c4 to your computer and use it in GitHub Desktop.
Auto scroll to bottom of the page in JavaScript with smooth scrolling based on time delay.
function scrollToBottom(timedelay=0) {
var scrollId;
var height = 0;
var minScrollHeight = 100;
scrollId = setInterval(function () {
if (height <= document.body.scrollHeight) {
window.scrollBy(0, minScrollHeight);
}
else {
clearInterval(scrollId);
}
height += minScrollHeight;
}, timedelay);
}
@adrianowerpel
Copy link

Very usefull, thanks!

@ArthurAG77
Copy link

Thx man, helps a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment