mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
fix(nuxt): only request animation frame on client (#25569)
This commit is contained in:
parent
2364aabe93
commit
10f2356ab4
@ -79,7 +79,9 @@ function createLoadingIndicator (opts: Partial<LoadingIndicatorOpts> = {}) {
|
|||||||
|
|
||||||
function clear () {
|
function clear () {
|
||||||
clearTimeout(_throttle)
|
clearTimeout(_throttle)
|
||||||
|
if (import.meta.client) {
|
||||||
cancelAnimationFrame(rafId)
|
cancelAnimationFrame(rafId)
|
||||||
|
}
|
||||||
_throttle = null
|
_throttle = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +95,10 @@ 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)))
|
||||||
|
if (import.meta.client) {
|
||||||
rafId = requestAnimationFrame(step)
|
rafId = requestAnimationFrame(step)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (import.meta.client) {
|
if (import.meta.client) {
|
||||||
rafId = requestAnimationFrame(step)
|
rafId = requestAnimationFrame(step)
|
||||||
|
Loading…
Reference in New Issue
Block a user