From 599ad477d24fcf85f6eb82e53d7ee472659ad84e Mon Sep 17 00:00:00 2001 From: Malcolm Smith <20709258+msmithNI@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:41:47 -0500 Subject: [PATCH] Tweak startup scripts --- .../NimbleBlazor/wwwroot/NimbleBlazor.lib.module.js | 12 +++++++++--- .../wwwroot/SprightBlazor.lib.module.js | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/blazor-workspace/NimbleBlazor/wwwroot/NimbleBlazor.lib.module.js b/packages/blazor-workspace/NimbleBlazor/wwwroot/NimbleBlazor.lib.module.js index ae32235cea..4f6cf5cee8 100644 --- a/packages/blazor-workspace/NimbleBlazor/wwwroot/NimbleBlazor.lib.module.js +++ b/packages/blazor-workspace/NimbleBlazor/wwwroot/NimbleBlazor.lib.module.js @@ -163,6 +163,12 @@ function registerNimbleEvents(Blazor) { }); } +function handleRuntimeStarted() { + window.requestAnimationFrame(() => { + window.NimbleBlazor.hasRuntimeStarted = true; + }); +} + // Blazor Web Apps export function afterWebStarted(Blazor) { registerNimbleEvents(Blazor); @@ -171,11 +177,11 @@ export function afterWebStarted(Blazor) { } export function afterServerStarted(_Blazor) { - window.NimbleBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } export function afterWebAssemblyStarted(_Blazor) { - window.NimbleBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } // Blazor Server/WebAssembly/Hybrid apps @@ -186,7 +192,7 @@ export function afterStarted(Blazor) { registerNimbleEvents(Blazor); } - window.NimbleBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } if (window.NimbleBlazor) { diff --git a/packages/blazor-workspace/SprightBlazor/wwwroot/SprightBlazor.lib.module.js b/packages/blazor-workspace/SprightBlazor/wwwroot/SprightBlazor.lib.module.js index 4989ccf2b2..3e41a1d69d 100644 --- a/packages/blazor-workspace/SprightBlazor/wwwroot/SprightBlazor.lib.module.js +++ b/packages/blazor-workspace/SprightBlazor/wwwroot/SprightBlazor.lib.module.js @@ -34,6 +34,12 @@ export function registerSprightEvents(Blazor) { */ } +function handleRuntimeStarted() { + window.requestAnimationFrame(() => { + window.NimbleBlazor.hasRuntimeStarted = true; + }); +} + // Blazor Web Apps export function afterWebStarted(Blazor) { registerSprightEvents(Blazor); @@ -42,11 +48,11 @@ export function afterWebStarted(Blazor) { } export function afterServerStarted(_Blazor) { - window.SprightBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } export function afterWebAssemblyStarted(_Blazor) { - window.SprightBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } // Blazor Server/WebAssembly/Hybrid apps @@ -57,7 +63,7 @@ export function afterStarted(Blazor) { registerSprightEvents(Blazor); } - window.NimbleBlazor.hasRuntimeStarted = true; + handleRuntimeStarted(); } if (window.SprightBlazor) {