This commit is contained in:
parent
ce0ce143ba
commit
af7206cd6c
@ -6,14 +6,15 @@ const runChat = async () => {
|
|||||||
r.text(),
|
r.text(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { scrollTop, scrollTopMax } = document.getElementById(
|
const { scrollTop, scrollHeight, clientTop } = document.getElementById(
|
||||||
"chat-container",
|
"chat-container",
|
||||||
) ?? { scrollTop: 0 };
|
) ?? { scrollTop: 0, scrollHeight: 0, clientTop: 0};
|
||||||
|
const scrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").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;
|
||||||
|
const emplacedScrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop;
|
||||||
if (isAtEdge) {
|
if (isAtEdge) {
|
||||||
document.getElementById("chat-container").scrollTop =
|
document.getElementById("chat-container").scrollTop = scrollTopMax;
|
||||||
document.getElementById("chat-container").scrollTopMax;
|
|
||||||
} else {
|
} else {
|
||||||
// save the position.
|
// save the position.
|
||||||
document.getElementById("chat-container").scrollTop = scrollTop;
|
document.getElementById("chat-container").scrollTop = scrollTop;
|
||||||
|
Loading…
Reference in New Issue
Block a user