Skip to content

Instantly share code, notes, and snippets.

@DominguesM
Created August 17, 2023 20:29
Show Gist options
  • Save DominguesM/de79bf9d9a66729b7feb83ce997e6c2e to your computer and use it in GitHub Desktop.
Save DominguesM/de79bf9d9a66729b7feb83ce997e6c2e to your computer and use it in GitHub Desktop.
window.scroll_flag = true
window.scroll_exit = false
window.scroll_delay = 100
$(".output_scroll").each(function() {
$(this)[0].scrollTop = $(this)[0].scrollHeight;
});
function callScrollToBottom() {
setTimeout(scrollToBottom, window.scroll_delay);
}
function scrollToBottom() {
if (window.scroll_exit) {
return;
}
if (!window.scroll_flag) {
callScrollToBottom();
return;
};
$(".output_scroll").each(function() {
if (!$(this).attr('scroll_checkbox')){
window.scroll_flag = true;
$(this).attr('scroll_checkbox',true);
var div = document.createElement('div');
var checkbox = document.createElement('input');
checkbox.type = "checkbox";
checkbox.onclick = function(){window.scroll_flag = checkbox.checked}
checkbox.checked = "checked"
div.append("Auto-Scroll-To-Bottom: ");
div.append(checkbox);
$(this).parent().before(div);
}
$(this)[0].scrollTop = $(this)[0].scrollHeight;
});
callScrollToBottom();
}
scrollToBottom();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment