feat: skip css updates if progress hasn't changed

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2346>
environments/review-docs-fix-d-jlladr/deployments/17321
Kasper Seweryn 2023-03-03 09:13:40 +01:00 zatwierdzone przez Georg krause
rodzic b74c38ac1a
commit 248fb1046e
1 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -167,12 +167,20 @@ export const usePlayer = createGlobalState(() => {
}, 1000)
// Progress
let lastProgress = 0
useRafFn(() => {
const sound = currentSound.value
document.documentElement.style.setProperty('--fw-track-progress', sound
? `${(sound.currentTime / sound.duration * 100).toFixed(Math.log(window.innerWidth))}%`
: '0'
)
const progress = sound
? +(sound.currentTime / sound.duration * 100).toFixed(Math.log(window.innerWidth))
: 0
if (progress !== lastProgress) {
lastProgress = !isNaN(progress)
? progress
: 0
document.documentElement.style.setProperty('--fw-track-progress', `${lastProgress}%`)
}
})
// Loading