From c8850e8c6d9ee75271a08dd8e7d486795c0fdab8 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Tue, 7 Mar 2023 22:49:34 +0800 Subject: [PATCH] chore: comments --- src/routes/chat/Layout/MessageFeed.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/chat/Layout/MessageFeed.tsx b/src/routes/chat/Layout/MessageFeed.tsx index a55c3d57..e5428a4e 100644 --- a/src/routes/chat/Layout/MessageFeed.tsx +++ b/src/routes/chat/Layout/MessageFeed.tsx @@ -42,7 +42,7 @@ const MessageFeed = ({ context, id }: Props) => { }; }); useEffect(() => { - // 上下文有变动,则滚动到底部 + // context changed, scroll to bottom console.log("listRef", listRef); if (listRef && listRef.current) { const list = listRef.current; @@ -58,7 +58,7 @@ const MessageFeed = ({ context, id }: Props) => { }, [context, id]); useEffect(() => { - // 需要检测滚动位置,如果距离底部超过阈值,则不滚到底部 + // check current scroll position first, scroll to bottom only when under the trigger number if (ref && ref.current) { const container = ref.current; const { scrollHeight, scrollTop, offsetHeight } = container; @@ -94,7 +94,7 @@ const MessageFeed = ({ context, id }: Props) => { onViewportIndexesChange={handleMessageListChange} overscan={10} // itemSize={100} - initialPrerender={30} + initialPrerender={40} scrollThreshold={2000} ref={listRef} viewportRef={ref}