Skip to content

Commit

Permalink
fix: update initial logoWidth onload
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchan32 committed Apr 13, 2024
1 parent e9a6108 commit 710aba1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/LogoAndRegister/LogoAndRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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';
Expand Down

0 comments on commit 710aba1

Please sign in to comment.