chat scroll
This commit is contained in:
parent
80be74782c
commit
003391e60e
1 changed files with 16 additions and 1 deletions
|
|
@ -354,6 +354,11 @@ function formatDate(isoString) {
|
|||
return d.toLocaleDateString();
|
||||
}
|
||||
|
||||
function scrollMessagesToBottom() {
|
||||
if (!el.messageList) return;
|
||||
el.messageList.scrollTop = el.messageList.scrollHeight;
|
||||
}
|
||||
|
||||
let audioCtx = null;
|
||||
|
||||
// Global interaction listener to unlock AudioContext (autoplay policy)
|
||||
|
|
@ -628,7 +633,17 @@ function renderMessages(messages) {
|
|||
state.lastMessageId = messages[0].id;
|
||||
}
|
||||
|
||||
el.messageList.scrollTop = el.messageList.scrollHeight;
|
||||
scrollMessagesToBottom();
|
||||
requestAnimationFrame(() => {
|
||||
scrollMessagesToBottom();
|
||||
});
|
||||
|
||||
// GIF/image height resolves after initial paint; keep chat pinned to latest.
|
||||
for (const gifImage of el.messageList.querySelectorAll(".msg-gif img")) {
|
||||
if (gifImage.complete) continue;
|
||||
gifImage.addEventListener("load", scrollMessagesToBottom, { once: true });
|
||||
gifImage.addEventListener("error", scrollMessagesToBottom, { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
function renderMembers() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue