From 10f2356ab4b055221d5d63712a98ba6d8cdc25a4 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Thu, 1 Feb 2024 19:14:11 +0100 Subject: [PATCH] fix(nuxt): only request animation frame on client (#25569) --- packages/nuxt/src/app/composables/loading-indicator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/composables/loading-indicator.ts b/packages/nuxt/src/app/composables/loading-indicator.ts index 10f4226c6e..2003f68841 100644 --- a/packages/nuxt/src/app/composables/loading-indicator.ts +++ b/packages/nuxt/src/app/composables/loading-indicator.ts @@ -79,7 +79,9 @@ function createLoadingIndicator (opts: Partial = {}) { function clear () { clearTimeout(_throttle) - cancelAnimationFrame(rafId) + if (import.meta.client) { + cancelAnimationFrame(rafId) + } _throttle = null } @@ -93,7 +95,9 @@ function createLoadingIndicator (opts: Partial = {}) { startTimeStamp ??= timeStamp const elapsed = timeStamp - startTimeStamp progress.value = Math.max(0, Math.min(100, getProgress(duration, elapsed))) - rafId = requestAnimationFrame(step) + if (import.meta.client) { + rafId = requestAnimationFrame(step) + } } if (import.meta.client) {