fix(ui): replace smooth scroll with instant for back-to-top to avoid VirtualScroller conflict

The back-to-top button used scrollTo({top:0, behavior:'smooth'}) which
conflicts with VirtualScroller's DOM manipulations during the smooth
scroll animation. Each animation frame triggered handleScroll() ->
scheduleRender() -> renderItems(), causing the browser to interrupt
the smooth scroll animation mid-way, resulting in only ~1 page of
upward scroll instead of reaching the top.

Root cause: commit 311e89e9 fixed VirtualScroller to listen on the
correct scroll container (.page-content), but this meant every scroll
event during smooth animation now triggers expensive DOM operations
that abort the browser's compositor-thread smooth scroll animation.

Fix: use instant scroll (scrollTop = 0) so the position is set
immediately without triggering frame-by-frame VirtualScroller
interference.
This commit is contained in:
Will Miao
2026-06-26 16:31:31 +08:00
parent c1bf9c6221
commit a429e6b1c3

View File

@@ -384,12 +384,9 @@ export function initBackToTop() {
}
};
// Smooth scroll to top
// Scroll to top
button.addEventListener('click', () => {
scrollContainer.scrollTo({
top: 0,
behavior: 'smooth'
});
scrollContainer.scrollTop = 0;
});
// Listen for scroll events on the scrollable container