迁移聊天室底部滚动工具
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user