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
+8 -1
View File
@@ -65,6 +65,13 @@ export function ThreadView(chat: Chat) {
children:append={[chat.messages, messageConverter]}
></div>
);
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;
}