chore: comments

This commit is contained in:
Tristan Yang
2023-03-07 22:49:34 +08:00
parent d9343ec795
commit c8850e8c6d
+3 -3
View File
@@ -42,7 +42,7 @@ const MessageFeed = ({ context, id }: Props) => {
}; };
}); });
useEffect(() => { useEffect(() => {
// 上下文有变动,则滚动到底部 // context changed, scroll to bottom
console.log("listRef", listRef); console.log("listRef", listRef);
if (listRef && listRef.current) { if (listRef && listRef.current) {
const list = listRef.current; const list = listRef.current;
@@ -58,7 +58,7 @@ const MessageFeed = ({ context, id }: Props) => {
}, [context, id]); }, [context, id]);
useEffect(() => { useEffect(() => {
// 需要检测滚动位置,如果距离底部超过阈值,则不滚到底部 // check current scroll position first, scroll to bottom only when under the trigger number
if (ref && ref.current) { if (ref && ref.current) {
const container = ref.current; const container = ref.current;
const { scrollHeight, scrollTop, offsetHeight } = container; const { scrollHeight, scrollTop, offsetHeight } = container;
@@ -94,7 +94,7 @@ const MessageFeed = ({ context, id }: Props) => {
onViewportIndexesChange={handleMessageListChange} onViewportIndexesChange={handleMessageListChange}
overscan={10} overscan={10}
// itemSize={100} // itemSize={100}
initialPrerender={30} initialPrerender={40}
scrollThreshold={2000} scrollThreshold={2000}
ref={listRef} ref={listRef}
viewportRef={ref} viewportRef={ref}