From c4d5331c03e223b84963b81b98e36a1d71fa3338 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:21:52 -0700 Subject: [PATCH] Fix autoscroll after fonts load --- js/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/main.js b/js/main.js index c44c144e..c805fc9a 100644 --- a/js/main.js +++ b/js/main.js @@ -1086,3 +1086,17 @@ chatInput.addEventListener("input", () => { // Update wasAtBottom when user scrolls targetElement.addEventListener("scroll", checkIfAtBottom); + +//------------------------------------------------ +// Fix autoscroll after fonts load +//------------------------------------------------ +document.fonts.addEventListener("loadingdone", (event) => { + setTimeout(() => { + if (!window.isScrolled) { + const maxScroll = targetElement.scrollHeight - targetElement.clientHeight; + if (targetElement.scrollTop < maxScroll - 5) { + targetElement.scrollTop = maxScroll; + } + } + }, 50); +});