This commit is contained in:
parent
af7206cd6c
commit
b2391b058b
@ -9,9 +9,10 @@ const runChat = async () => {
|
|||||||
const { scrollTop, scrollHeight, clientTop } = document.getElementById(
|
const { scrollTop, scrollHeight, clientTop } = document.getElementById(
|
||||||
"chat-container",
|
"chat-container",
|
||||||
) ?? { scrollTop: 0, scrollHeight: 0, clientTop: 0};
|
) ?? { scrollTop: 0, scrollHeight: 0, clientTop: 0};
|
||||||
const scrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop;
|
const scrollTopMax = scrollHeight - clientTop;
|
||||||
const isAtEdge = scrollTop > (0.92 * scrollTopMax) || scrollTop === 0;
|
const isAtEdge = scrollTop > (0.92 * scrollTopMax) || scrollTop === 0;
|
||||||
document.getElementById("messages").innerHTML = html;
|
document.getElementById("messages").innerHTML = html;
|
||||||
|
if (!document.getElementById("chat-container")) return;
|
||||||
const emplacedScrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop;
|
const emplacedScrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop;
|
||||||
if (isAtEdge) {
|
if (isAtEdge) {
|
||||||
document.getElementById("chat-container").scrollTop = scrollTopMax;
|
document.getElementById("chat-container").scrollTop = scrollTopMax;
|
||||||
|
Loading…
Reference in New Issue
Block a user