From 1c52633f96fee38be6d809ab9a6b3c3393fc7ac3 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Fri, 28 Aug 2026 11:06:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(frontend)=20responsive=20thr?= =?UTF-8?q?ottling=20instead=20of=20debouncing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We changed the responsive store to use throttling instead of debouncing for the window resize event. This change ensures that the store updates more consistently during rapid window resizing, providing a smoother user experience. --- .../apps/impress/src/stores/useResponsiveStore.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/apps/impress/src/stores/useResponsiveStore.tsx b/src/frontend/apps/impress/src/stores/useResponsiveStore.tsx index d69ae69c5..1b74e1c36 100644 --- a/src/frontend/apps/impress/src/stores/useResponsiveStore.tsx +++ b/src/frontend/apps/impress/src/stores/useResponsiveStore.tsx @@ -42,6 +42,8 @@ export const useResponsiveStore = create((set) => ({ screenWidth: initialState.screenWidth, setScreenSize: (size: ScreenSize) => set(() => ({ screenSize: size })), initializeResizeListener: () => { + let pendingResize = false; + const resizeHandler = () => { const width = window.innerWidth; if (width < BREAKPOINTS.SMALL_MOBILE) { @@ -89,10 +91,16 @@ export const useResponsiveStore = create((set) => ({ let resizeTimeout: ReturnType | undefined; const debouncedResizeHandler = () => { + if (pendingResize) { + return; + } + + pendingResize = true; clearTimeout(resizeTimeout); resizeTimeout = setTimeout(() => { resizeHandler(); - }, 300); + pendingResize = false; + }, 200); }; window.addEventListener('resize', debouncedResizeHandler);