summaryrefslogtreecommitdiff
path: root/static/js/components/chat.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/components/chat.js')
-rw-r--r--static/js/components/chat.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/static/js/components/chat.js b/static/js/components/chat.js
index bdc8ad1..e5d1185 100644
--- a/static/js/components/chat.js
+++ b/static/js/components/chat.js
@@ -6,14 +6,14 @@ const runChat = async () => {
r.text(),
);
- const { scrollTop, scrollHeight } = document.getElementById(
+ const { scrollTop, scrollTopMax } = document.getElementById(
"chat-container",
) ?? { scrollTop: 0 };
- const isAtEdge = scrollTop === scrollHeight || scrollTop === 0;
+ const isAtEdge = scrollTop > (0.92 * scrollTopMax) || scrollTop === 0;
document.getElementById("messages").innerHTML = html;
if (isAtEdge) {
document.getElementById("chat-container").scrollTop =
- document.getElementById("chat-container").scrollHeight;
+ document.getElementById("chat-container").scrollTopMax;
} else {
// save the position.
document.getElementById("chat-container").scrollTop = scrollTop;