pull/733/head
lyswhut 2021-12-24 19:31:50 +08:00
parent d8dfbf6995
commit b867167b78
1 changed files with 4 additions and 1 deletions

View File

@ -40,6 +40,7 @@ export default {
let barHeight
let x = 0
let isPlaying = false
let animationFrameId
const theme = useRefGetter('theme')
// const setting = useRefGetter('setting')
@ -50,7 +51,8 @@ export default {
// https://codepen.io/nfj525/pen/rVBaab
const renderFrame = () => {
if (isPlaying) window.requestAnimationFrame(renderFrame)
animationFrameId = null
if (isPlaying) animationFrameId = window.requestAnimationFrame(renderFrame)
x = 0
@ -84,6 +86,7 @@ export default {
renderFrame()
}
const handlePause = () => {
if (animationFrameId) window.cancelAnimationFrame(animationFrameId)
isPlaying = false
}