feat: skip css updates if progress hasn't changed
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2346>
This commit is contained in:
parent
bbe2375f6b
commit
8ce20c5621
|
@ -167,12 +167,20 @@ export const usePlayer = createGlobalState(() => {
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
// Progress
|
// Progress
|
||||||
|
let lastProgress = 0
|
||||||
useRafFn(() => {
|
useRafFn(() => {
|
||||||
const sound = currentSound.value
|
const sound = currentSound.value
|
||||||
document.documentElement.style.setProperty('--fw-track-progress', sound
|
const progress = sound
|
||||||
? `${(sound.currentTime / sound.duration * 100).toFixed(Math.log(window.innerWidth))}%`
|
? +(sound.currentTime / sound.duration * 100).toFixed(Math.log(window.innerWidth))
|
||||||
: '0'
|
: 0
|
||||||
)
|
|
||||||
|
if (progress !== lastProgress) {
|
||||||
|
lastProgress = !isNaN(progress)
|
||||||
|
? progress
|
||||||
|
: 0
|
||||||
|
|
||||||
|
document.documentElement.style.setProperty('--fw-track-progress', `${lastProgress}%`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Loading
|
// Loading
|
||||||
|
|
Loading…
Reference in New Issue