Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const Chat = React.forwardRef<HTMLDivElement, ChatProps>((props, ref) =>
rightAction,
Composer = DComposer,
isX,
nearBottomThreshold
} = props;
const [currentColorScheme, setCurrentColorScheme] = useState<'light' | 'dark'>('light');

Expand Down Expand Up @@ -252,6 +253,7 @@ export const Chat = React.forwardRef<HTMLDivElement, ChatProps>((props, ref) =>
onScroll={onScroll}
onBackBottomShow={onBackBottomShow}
onBackBottomClick={onBackBottomClick}
nearBottomThreshold={nearBottomThreshold}
/>
<div className="ChatFooter">
{renderQuickReplies ? (
Expand Down
4 changes: 3 additions & 1 deletion src/components/MessageContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface MessageContainerProps {
renderBeforeMessageList?: () => React.ReactNode;
onBackBottomShow?: () => void;
onBackBottomClick?: () => void;
nearBottomThreshold?: number;
}

export interface MessageContainerHandle {
Expand All @@ -43,6 +44,7 @@ export const MessageContainer = React.forwardRef<MessageContainerHandle, Message
renderMessageContent,
onBackBottomShow,
onBackBottomClick,
nearBottomThreshold = 2
} = props;

const [showBackBottom, setShowBackBottom] = useState(false);
Expand Down Expand Up @@ -126,7 +128,7 @@ export const MessageContainer = React.forwardRef<MessageContainerHandle, Message
if (lastMessage.position === 'right') {
// 自己发的消息,强制滚动到底部
scrollToEnd({ force: true });
} else if (isNearBottom(wrapper, 2)) {
} else if (isNearBottom(wrapper, nearBottomThreshold)) {
const animated = !!wrapper.scrollTop;
scrollToEnd({ animated, force: true });
} else {
Expand Down