mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Use own scroll to bottom function instead of built-in. Closes #2500
This commit is contained in:
parent
b989e9a462
commit
bb9b8a8123
@ -171,11 +171,15 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const scrollChatToBottom = (ref, behavior = 'smooth') => {
|
const scrollChatToBottom = (ref, behavior = 'smooth') => {
|
||||||
|
setTimeout(() => {
|
||||||
ref.current?.scrollToIndex({
|
ref.current?.scrollToIndex({
|
||||||
index: messages.length - 1,
|
index: messages.length - 1,
|
||||||
behavior,
|
behavior,
|
||||||
});
|
});
|
||||||
|
}, 100);
|
||||||
|
|
||||||
setAtBottom(true);
|
setAtBottom(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -192,6 +196,7 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||||||
() => (
|
() => (
|
||||||
<>
|
<>
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
|
id="virtuoso"
|
||||||
style={{ height }}
|
style={{ height }}
|
||||||
className={styles.virtuoso}
|
className={styles.virtuoso}
|
||||||
ref={chatContainerRef}
|
ref={chatContainerRef}
|
||||||
@ -199,12 +204,12 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||||||
itemContent={(index, message) => getViewForMessage(index, message)}
|
itemContent={(index, message) => getViewForMessage(index, message)}
|
||||||
followOutput={(isAtBottom: boolean) => {
|
followOutput={(isAtBottom: boolean) => {
|
||||||
if (isAtBottom) {
|
if (isAtBottom) {
|
||||||
return 'smooth';
|
scrollChatToBottom(chatContainerRef, 'smooth');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
alignToBottom
|
alignToBottom
|
||||||
atBottomThreshold={50}
|
atBottomThreshold={70}
|
||||||
atBottomStateChange={bottom => {
|
atBottomStateChange={bottom => {
|
||||||
setAtBottom(bottom);
|
setAtBottom(bottom);
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user