Open
Conversation
在更新 scrollToBottom 方法中添加了滚动位置检测,只有当消息列表距离底部小于 50px 时,才自动滚动到底部。 这样既能在用户保持在底部时自动滚动,同时在用户浏览之前的消息时不会强制滚动,改善了用户体验。 修改内容包括: - 在 scrollToBottom 方法内部计算距离底部的距离,并使用 50px 作为阈值; - 在 sendMessage 方法中,通过调用 scrollToBottom 方法来统一判断是否自动滚动。 测试过程中确认: - 用户主动向上滚动查看旧消息时,不会被新的消息打断。 - 在发送新消息时,仍然能够在接近底部时自动滚动以便看到最新内容。 无其他功能上的影响。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当前在消息连续到达时,页面会自动滚动到底部,这会打断用户手动查看之前消息的体验。为了解决这个问题,本次修改对自动滚动逻辑做了优化:
修改内容
scrollToBottom 方法调整:
在计算列表距离底部之后,使用 50px 作为阈值,仅当小于该值时自动滚动到底部。
sendMessage 方法调整:
在流式消息接收过程中以及消息发送完成后,都统一调用 scrollToBottom 方法,从而避免直接滚动到底部的强制行为。
测试建议
预期效果
请审查该 PR 并提出建议,谢谢!