fix: call handleScrollFocus before binding scroll event handlers

Call handleScrollFocus before adding scroll event listeners to prevent
handleScrollSave from triggering during initial setup.
This commit is contained in:
Yuyao Huang 2026-05-09 15:33:40 +08:00
parent 14ebbda585
commit eca0cf4193

View File

@ -159,13 +159,13 @@ function initScrollFocus() {
scrollView.removeEventListener("scroll", handleScrollFocus);
scrollView.removeEventListener("scroll", handleScrollSave);
// Initial call to set in-focus class (before binding scroll handler)
handleScrollFocus();
// Bind scroll handlers after initial setup
scrollView.addEventListener("scroll", handleScrollFocus);
scrollView.addEventListener("scroll", handleScrollSave);
// Initial call to set in-focus class (skip saving during init)
isInitializing = true;
handleScrollFocus();
isInitializing = false;
}
function handleScrollFocus() {