Skip to content

Commit

Permalink
fix: update fakelogoInfo on image load
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchan32 committed Apr 13, 2024
1 parent 710aba1 commit 25f496a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/LogoAndRegister/LogoAndRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function LogoAndRegister({
const lastScrollTopRef = useRef(0);

useEffect(() => {
const fakeLogoInfo = fakeLogoRef.current?.getBoundingClientRect();
let fakeLogoInfo: DOMRect | undefined = undefined;
let initialLogoWidth = 0;
const navRightValue = navRef.current
? parseInt(
Expand All @@ -35,9 +35,10 @@ export default function LogoAndRegister({
const registerInfo = registerRef.current?.getBoundingClientRect();
const initialRegisterWidth = registerInfo!.width;

if (logoRef.current && fakeLogoInfo && fakeLogoRef.current) {
if (logoRef.current && fakeLogoRef.current) {
fakeLogoRef.current.onload = () => {
console.log('onload triggered');
fakeLogoInfo = fakeLogoRef.current!.getBoundingClientRect();
initialLogoWidth =
parseInt(window.getComputedStyle(fakeLogoRef.current!).width) || 0;
logoRef.current!.style.width = initialLogoWidth + 'px';
Expand Down

0 comments on commit 25f496a

Please sign in to comment.