This commit is contained in:
2026-07-17 22:59:53 +02:00
parent d09cb44fa7
commit 18a871976c
4 changed files with 14 additions and 5 deletions

View File

@@ -120,6 +120,8 @@ class CommentSystem {
if (!document.body.classList.contains('layout-legacy') && !document.body.classList.contains('legacy-view')) return;
const updateBtn = () => {
if (!this.initialLoadDone) return;
const btn = document.querySelector('.scroll-to-bottom');
if (!btn) return;
@@ -128,7 +130,9 @@ class CommentSystem {
const rect = container.getBoundingClientRect();
// Detect if we are at the bottom of the comments section
const isAtBottom = rect.bottom < window.innerHeight + 100;
// We also require window.scrollY > 50 to prevent flickering to 'scroll to top'
// when the page first loads and images haven't fully pushed the container down yet.
const isAtBottom = (rect.bottom < window.innerHeight + 100) && (window.scrollY > 50);
if (isAtBottom) {
btn.classList.add('is-at-bottom');
@@ -673,6 +677,7 @@ class CommentSystem {
this.render(comments, this.user, initialIsSubscribed);
this.initialLoadDone = true;
this.restoreState(state);
if (this.scrollHandler) this.scrollHandler();
this._loadDanmaku(comments);
if (scrollToId) {
@@ -743,6 +748,7 @@ class CommentSystem {
this.reconcile(data.comments, data.user_id, data.is_subscribed);
this.initialLoadDone = true;
this.restoreState(state);
if (this.scrollHandler) this.scrollHandler();
if (scrollToId) {
this.preservingScroll = false;
@@ -772,6 +778,7 @@ class CommentSystem {
this.render(data.comments, data.user_id, data.is_subscribed);
this.initialLoadDone = true;
this.restoreState(state);
if (this.scrollHandler) this.scrollHandler();
this._loadDanmaku(data.comments);
if (scrollToId) {