From 4ccc7bae40d43ac8985534d7fef2d4ef89031418 Mon Sep 17 00:00:00 2001 From: sahil Date: Wed, 5 Nov 2025 18:59:20 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20[Bug]=20=20Fixes=20#2435?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/artboard/src/pages/artboard.tsx | 15 +++++++++------ libs/utils/src/namespaces/tests/fonts.test.ts | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/artboard/src/pages/artboard.tsx b/apps/artboard/src/pages/artboard.tsx index e0c3b660..4b7e07b4 100644 --- a/apps/artboard/src/pages/artboard.tsx +++ b/apps/artboard/src/pages/artboard.tsx @@ -1,8 +1,8 @@ +import { isLocalFont } from "@reactive-resume/utils"; import { useEffect, useMemo } from "react"; import { Helmet } from "react-helmet-async"; import { Outlet } from "react-router"; import webfontloader from "webfontloader"; -import { isLocalFont } from "@reactive-resume/utils"; import { useArtboardStore } from "../store/artboard"; @@ -21,11 +21,14 @@ export const ArtboardPage = () => { useEffect(() => { const family = metadata.typography.font.family; if (isLocalFont(family)) { - const width = window.document.body.offsetWidth; - const height = window.document.body.offsetHeight; - const message = { type: "PAGE_LOADED", payload: { width, height } }; - window.postMessage(message, "*"); - return; + let frame = 0; + frame = requestAnimationFrame(() => { + const width = window.document.body.offsetWidth; + const height = window.document.body.offsetHeight; + const message = { type: "PAGE_LOADED", payload: { width, height } }; + window.postMessage(message, "*"); + }); + return () => { cancelAnimationFrame(frame); }; } webfontloader.load({ diff --git a/libs/utils/src/namespaces/tests/fonts.test.ts b/libs/utils/src/namespaces/tests/fonts.test.ts index ec1832e7..bf408afb 100644 --- a/libs/utils/src/namespaces/tests/fonts.test.ts +++ b/libs/utils/src/namespaces/tests/fonts.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from "vitest"; +import { describe, expect,it } from "vitest"; + import { isLocalFont, localFonts } from "../fonts"; describe("isLocalFont", () => {