Re add scroll to bottom

This commit is contained in:
Raven Scott 2024-06-04 01:00:24 -04:00
parent ef312ad068
commit 6463f2e526

7
app.js
View File

@ -237,6 +237,12 @@ function sendMessage(e) {
} }
} }
function scrollToBottom() {
var container = document.getElementById("messages-container");
container.scrollTop = container.scrollHeight;
}
function onMessageAdded(from, message, avatar) { function onMessageAdded(from, message, avatar) {
const $div = document.createElement('div'); const $div = document.createElement('div');
$div.classList.add('message'); $div.classList.add('message');
@ -265,6 +271,7 @@ function onMessageAdded(from, message, avatar) {
$div.appendChild($content); $div.appendChild($content);
document.querySelector('#messages').appendChild($div); document.querySelector('#messages').appendChild($div);
scrollToBottom();
} }
async function updateIcon(username, avatarBuffer) { async function updateIcon(username, avatarBuffer) {