fix: chat scroll (#2981)

This commit is contained in:
zxhlyh 2024-03-26 16:19:41 +08:00 committed by GitHub
parent 40dbf30784
commit 61f5de9662
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,6 @@ import {
useRef,
} from 'react'
import { useTranslation } from 'react-i18next'
import { useThrottleEffect } from 'ahooks'
import { debounce } from 'lodash-es'
import type {
ChatConfig,
@ -92,10 +91,19 @@ const Chat: FC<ChatProps> = ({
chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px`
}, [])
useThrottleEffect(() => {
useEffect(() => {
handleScrolltoBottom()
handleWindowResize()
}, [chatList], { wait: 500 })
}, [handleScrolltoBottom, handleWindowResize])
useEffect(() => {
if (chatContainerRef.current) {
requestAnimationFrame(() => {
handleScrolltoBottom()
handleWindowResize()
})
}
})
useEffect(() => {
window.addEventListener('resize', debounce(handleWindowResize))