From 710aba15e6906c00656f6782b90c57007bb25767 Mon Sep 17 00:00:00 2001 From: Aaron Chan <42254254+aaronchan32@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:40:11 -0700 Subject: [PATCH] fix: update initial logoWidth onload --- src/components/LogoAndRegister/LogoAndRegister.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/LogoAndRegister/LogoAndRegister.tsx b/src/components/LogoAndRegister/LogoAndRegister.tsx index a4a7937..ae6cfe4 100644 --- a/src/components/LogoAndRegister/LogoAndRegister.tsx +++ b/src/components/LogoAndRegister/LogoAndRegister.tsx @@ -24,10 +24,7 @@ export default function LogoAndRegister({ useEffect(() => { const fakeLogoInfo = fakeLogoRef.current?.getBoundingClientRect(); - const initialLogoWidth = - parseInt( - window.getComputedStyle(fakeLogoRef.current!).getPropertyValue('width') - ) || 0; + let initialLogoWidth = 0; const navRightValue = navRef.current ? parseInt( window.getComputedStyle(navRef.current).getPropertyValue('right') @@ -40,6 +37,9 @@ export default function LogoAndRegister({ if (logoRef.current && fakeLogoInfo && fakeLogoRef.current) { fakeLogoRef.current.onload = () => { + console.log('onload triggered'); + initialLogoWidth = + parseInt(window.getComputedStyle(fakeLogoRef.current!).width) || 0; logoRef.current!.style.width = initialLogoWidth + 'px'; logoRef.current!.style.transform = `translate(${fakeLogoInfo.x}px, ${fakeLogoInfo.y - 20}px)`; logoRef.current!.style.opacity = '1';