From f90736f959b5fde62524d2338089d5704c6e80c4 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Mon, 18 Nov 2024 10:16:25 +0100 Subject: [PATCH] Fix globe problems on reload --- src/components/home/section-2/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/home/section-2/index.tsx b/src/components/home/section-2/index.tsx index 451c55f..f37dfdc 100644 --- a/src/components/home/section-2/index.tsx +++ b/src/components/home/section-2/index.tsx @@ -79,11 +79,15 @@ export default function Section2() { }, [isInView]); useEffect(() => { - if (screenWidth || resizableWidth === 0) { + if (globePhase !== 0 && screenWidth) { + // Prevent errors on reload + setResizableWidth(screenWidth); + } else if (screenWidth || resizableWidth === 0) { + // Set the resizable width to initial half the size setResizableWidth(screenWidth / 2); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [screenWidth]); + }, [screenWidth, globePhase]); useMotionValueEvent(scrollYProgress, "change", (latest) => { if (latest >= SECTION_STARTS[0] && latest < SECTION_STARTS[1] && globePhase !== 0) {