prevent scrolling to new message when the user scrolled up

This commit is contained in:
marlon-erler
2024-07-09 18:35:48 +02:00
parent f523b621aa
commit a1a9fd073c
2 changed files with 14 additions and 2 deletions
+6 -1
View File
@@ -453,6 +453,7 @@
isoDate: (/* @__PURE__ */ new Date()).toISOString()
};
const messageString = JSON.stringify(messageObject);
console.log(messageString);
UDN.sendMessage(joinedChannelName, messageString);
this.composingMessage.value = "";
};
@@ -908,7 +909,11 @@
"children:append": [chat.messages, messageConverter]
}
);
chat.messages.handleAddition(() => listElement.scrollTop = listElement.scrollHeight);
chat.messages.handleAddition(() => {
const scrollFromBottom = listElement.scrollHeight - (listElement.scrollTop + listElement.offsetHeight);
if (scrollFromBottom > 400) return;
listElement.scrollTop = listElement.scrollHeight;
});
return listElement;
}