From a8a8d7e4e4ad376855fdbab9c8a7054438496fe4 Mon Sep 17 00:00:00 2001 From: tobenot <42083410+tobenot@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=BB=9A=E5=8A=A8=E9=80=BB=E8=BE=91=EF=BC=9A=E4=BB=85?= =?UTF-8?q?=E5=BD=93=E6=8E=A5=E8=BF=91=E5=BA=95=E9=83=A8=EF=BC=88=E8=B7=9D?= =?UTF-8?q?=E7=A6=BB=20<=2050px=EF=BC=89=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在更新 scrollToBottom 方法中添加了滚动位置检测,只有当消息列表距离底部小于 50px 时,才自动滚动到底部。 这样既能在用户保持在底部时自动滚动,同时在用户浏览之前的消息时不会强制滚动,改善了用户体验。 修改内容包括: - 在 scrollToBottom 方法内部计算距离底部的距离,并使用 50px 作为阈值; - 在 sendMessage 方法中,通过调用 scrollToBottom 方法来统一判断是否自动滚动。 测试过程中确认: - 用户主动向上滚动查看旧消息时,不会被新的消息打断。 - 在发送新消息时,仍然能够在接近底部时自动滚动以便看到最新内容。 无其他功能上的影响。 --- index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index deabf4d..8d6cc2b 100644 --- a/index.html +++ b/index.html @@ -1301,7 +1301,12 @@