迁移聊天室底部滚动工具

This commit is contained in:
2026-04-25 19:47:26 +08:00
parent 62bd92c1c6
commit c8a9c92b56
3 changed files with 36 additions and 2 deletions
+16
View File
@@ -117,3 +117,19 @@ export function toggleAutoScroll(getCurrent, setCurrent) {
return nextEnabled;
}
/**
* 在允许自动滚屏时,把聊天容器滚动到最新消息。
* Blade 仍负责传入真实容器和开关读取器,避免工具函数直接依赖大脚本闭包。
*
* @param {HTMLElement|null|undefined} container 聊天消息容器
* @param {() => boolean} shouldScroll 判断当前是否允许自动滚屏
* @returns {void}
*/
export function scrollChatToBottom(container, shouldScroll) {
if (!container || !(typeof shouldScroll === "function" ? shouldScroll() : true)) {
return;
}
container.scrollTop = container.scrollHeight;
}