mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-09 08:45:45 +02:00
perf: optimize ResizeObserver to only observe necessary element
Change ResizeObserver from observing document.body (too broad) to only observing the segment element. This reduces unnecessary position update callbacks when unrelated parts of the page resize.
This commit is contained in:
parent
0068f7cd4d
commit
8a6a348771
@ -166,11 +166,14 @@ function initSidebarToggle(elFileView: HTMLElement): void {
|
||||
hideSidebar();
|
||||
}
|
||||
|
||||
// Update sidebar position on resize/scroll to keep aligned with file content
|
||||
// Update sidebar position on resize to keep aligned with file content
|
||||
// Only observe the segment element to avoid unnecessary updates from unrelated page changes
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
updatePosition();
|
||||
});
|
||||
resizeObserver.observe(document.body);
|
||||
if (segment) {
|
||||
resizeObserver.observe(segment);
|
||||
}
|
||||
|
||||
// Update position using IntersectionObserver instead of scroll event
|
||||
// This provides better performance and avoids scroll event issues
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user