mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
fix: throttle scroll to bottom
This commit is contained in:
parent
4ce60537ca
commit
4cd0ff2682
2 changed files with 4 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
||||
import Spinner from '../svg/Spinner';
|
||||
import { throttle } from 'lodash';
|
||||
import { CSSTransition } from 'react-transition-group';
|
||||
import ScrollToBottom from './ScrollToBottom';
|
||||
import MultiMessage from './MultiMessage';
|
||||
|
|
@ -34,10 +35,11 @@ export default function Messages({ messages, messageTree }) {
|
|||
};
|
||||
}, [messages]);
|
||||
|
||||
const scrollToBottom = useCallback(() => {
|
||||
const scrollToBottom = useCallback(throttle(() => {
|
||||
console.log('scrollToBottom');
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
setShowScrollButton(false);
|
||||
}, [messagesEndRef]);
|
||||
}, 750), [messagesEndRef]);
|
||||
|
||||
const handleScroll = () => {
|
||||
const { scrollTop, scrollHeight, clientHeight } = scrollableRef.current;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue