0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-08 11:13:32 +02:00

fix: use requestAnimationFrame for smooth sidebar scroll tracking

This commit is contained in:
hamki 2026-01-16 04:20:34 +08:00
parent 37afd14208
commit b3063c75da
No known key found for this signature in database
GPG Key ID: 092D4EC7F4DECB68

View File

@ -165,8 +165,15 @@ function initSidebarToggle(elFileView: HTMLElement): void {
});
resizeObserver.observe(document.body);
// Update position on scroll
window.addEventListener('scroll', updatePosition, {passive: true});
// Update position on scroll - use requestAnimationFrame for smooth updates
let scrollRafId: number | null = null;
window.addEventListener('scroll', () => {
if (scrollRafId !== null) return; // Already scheduled
scrollRafId = requestAnimationFrame(() => {
updatePosition();
scrollRafId = null;
});
}, {passive: true});
toggleBtn.addEventListener('click', () => {
const isCurrentlyVisible = !sidebar.classList.contains('sidebar-panel-hidden');