mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 05:39:46 +02:00
fix: use requestAnimationFrame for smooth sidebar scroll tracking
This commit is contained in:
1 file changed
+9
-2
@@ -165,8 +165,15 @@ function initSidebarToggle(elFileView: HTMLElement): void {
|
|||||||
});
|
});
|
||||||
resizeObserver.observe(document.body);
|
resizeObserver.observe(document.body);
|
||||||
|
|
||||||
// Update position on scroll
|
// Update position on scroll - use requestAnimationFrame for smooth updates
|
||||||
window.addEventListener('scroll', updatePosition, {passive: true});
|
let scrollRafId: number | null = null;
|
||||||
|
window.addEventListener('scroll', () => {
|
||||||
|
if (scrollRafId !== null) return; // Already scheduled
|
||||||
|
scrollRafId = requestAnimationFrame(() => {
|
||||||
|
updatePosition();
|
||||||
|
scrollRafId = null;
|
||||||
|
});
|
||||||
|
}, {passive: true});
|
||||||
|
|
||||||
toggleBtn.addEventListener('click', () => {
|
toggleBtn.addEventListener('click', () => {
|
||||||
const isCurrentlyVisible = !sidebar.classList.contains('sidebar-panel-hidden');
|
const isCurrentlyVisible = !sidebar.classList.contains('sidebar-panel-hidden');
|
||||||
|
|||||||
Reference in new issue
Block a user