Skip to content

Instantly share code, notes, and snippets.

@earlwlkr
Created January 31, 2019 07:42
Show Gist options
  • Save earlwlkr/7e19b0b8ed8147f24002eb0f3240e49b to your computer and use it in GitHub Desktop.
Save earlwlkr/7e19b0b8ed8147f24002eb0f3240e49b to your computer and use it in GitHub Desktop.
{
let scrollDiv = document.getElementById('messageViewContainer').children[0];
let lastHeight = 0;
window.ss = false;
function csr() {
if (window.ss) {
window.ss = false;
return;
}
let newHeight = scrollDiv.scrollHeight;
if (newHeight !== lastHeight) {
scrollDiv.scrollTop = 0;
lastHeight = newHeight;
setTimeout(csr, 150);
} else {
console.error('stopped auto scroll');
}
}
csr();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment