Slightly more robust autoscroll

This commit is contained in:
oobabooga 2025-07-07 13:23:23 -07:00
parent ca226a54c6
commit 74d98186fc

View file

@ -187,8 +187,11 @@ const observer = new MutationObserver(function(mutations) {
doSyntaxHighlighting(); doSyntaxHighlighting();
if (!window.isScrolled && !isScrollingClassOnly && targetElement.scrollTop !== targetElement.scrollHeight) { if (!window.isScrolled && !isScrollingClassOnly) {
targetElement.scrollTop = targetElement.scrollHeight; const maxScroll = targetElement.scrollHeight - targetElement.clientHeight;
if (maxScroll > 0 && targetElement.scrollTop < maxScroll - 1) {
targetElement.scrollTop = maxScroll;
}
} }
const chatElement = document.getElementById("chat"); const chatElement = document.getElementById("chat");