scroll chats to bottom when opening tools
This commit is contained in:
@@ -2,6 +2,7 @@ import * as React from "bloatless-react";
|
||||
|
||||
import { Chat, ChatMessage } from "../Model/chatModel";
|
||||
|
||||
import { isShowingChatTools } from "../Model/model";
|
||||
import { translation } from "../translations";
|
||||
|
||||
export function ThreadView(chat: Chat) {
|
||||
@@ -123,17 +124,22 @@ export function ThreadView(chat: Chat) {
|
||||
);
|
||||
|
||||
function scrollToBottom() {
|
||||
listWrapper.scrollTop = listWrapper.scrollHeight;
|
||||
}
|
||||
|
||||
function scrollToBottomIfAppropriate() {
|
||||
const scrollFromBottom =
|
||||
listWrapper.scrollHeight -
|
||||
(listWrapper.scrollTop + listWrapper.offsetHeight);
|
||||
if (scrollFromBottom > 400) return;
|
||||
|
||||
listWrapper.scrollTop = listWrapper.scrollHeight;
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
chat.messages.handleAddition(scrollToBottom);
|
||||
chat.outbox.handleAddition(scrollToBottom);
|
||||
setTimeout(() => (listWrapper.scrollTop = listWrapper.scrollHeight), 50);
|
||||
chat.messages.handleAddition(scrollToBottomIfAppropriate);
|
||||
chat.outbox.handleAddition(scrollToBottomIfAppropriate);
|
||||
isShowingChatTools.subscribe(() => scrollToBottom());
|
||||
setTimeout(() => scrollToBottom(), 50);
|
||||
|
||||
return listWrapper;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user