浏览代码

fix: chat scroll (#2981)

tags/0.5.11
zxhlyh 1年前
父节点
当前提交
61f5de9662
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11
    3
      web/app/components/base/chat/chat/index.tsx

+ 11
- 3
web/app/components/base/chat/chat/index.tsx 查看文件

@@ -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))

正在加载...
取消
保存