perf(ui): debounce window resize event for sidebar responsiveness

Debounce the window resize event listener with a 150ms timeout to prevent excessive executions, improving performance during window resizing.
This commit is contained in:
jgor20
2026-01-11 14:51:07 +00:00
parent dd7bfe724e
commit 10cbe2125a

View File

@@ -67,7 +67,12 @@ document.addEventListener('alpine:init', () => {
// Handle responsive sidebar transitions
let lastWidth = window.innerWidth;
let resizeTimeout = null;
window.addEventListener('resize', () => {
if (resizeTimeout) clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
const currentWidth = window.innerWidth;
const lgBreakpoint = 1024;
@@ -82,6 +87,7 @@ document.addEventListener('alpine:init', () => {
}
lastWidth = currentWidth;
}, 150);
});
// Theme setup