fix(nuxt): only request animation frame on client (#25569)

This commit is contained in:
Julien Huang 2024-02-01 19:14:11 +01:00 committed by GitHub
parent 2364aabe93
commit 10f2356ab4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,7 +79,9 @@ function createLoadingIndicator (opts: Partial<LoadingIndicatorOpts> = {}) {
function clear () { function clear () {
clearTimeout(_throttle) clearTimeout(_throttle)
cancelAnimationFrame(rafId) if (import.meta.client) {
cancelAnimationFrame(rafId)
}
_throttle = null _throttle = null
} }
@ -93,7 +95,9 @@ function createLoadingIndicator (opts: Partial<LoadingIndicatorOpts> = {}) {
startTimeStamp ??= timeStamp startTimeStamp ??= timeStamp
const elapsed = timeStamp - startTimeStamp const elapsed = timeStamp - startTimeStamp
progress.value = Math.max(0, Math.min(100, getProgress(duration, elapsed))) 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) { if (import.meta.client) {