From bf37ca8d09a87a8ac8f00f22ee221db455b15ea5 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 3 Apr 2022 20:28:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=99=AE=E9=80=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=A7=A6=E9=A1=B6=E5=8A=A0=E8=BD=BD=E6=9B=B4=E5=A4=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChatBox/ChatMessageList/NormalList.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/components/ChatBox/ChatMessageList/NormalList.tsx b/web/src/components/ChatBox/ChatMessageList/NormalList.tsx index 3130b9fc..2e443d74 100644 --- a/web/src/components/ChatBox/ChatMessageList/NormalList.tsx +++ b/web/src/components/ChatBox/ChatMessageList/NormalList.tsx @@ -29,10 +29,20 @@ export const NormalMessageList: React.FC = React.memo( return; } - if (containerRef.current?.scrollTop === 0) { + if (!containerRef.current) { + return; + } + + if (containerRef.current.scrollTop === 0) { onUpdateReadedMessageRef.current( props.messages[props.messages.length - 1]._id ); + } else if ( + -containerRef.current.scrollTop + containerRef.current.clientHeight === + containerRef.current.scrollHeight + ) { + // 滚动条碰触到最顶部 + props.onLoadMore(); } }, [props.messages]);