Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Dec 24, 2021
1 parent d8dfbf6 commit b867167
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderer/components/common/AudioVisualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
let barHeight
let x = 0
let isPlaying = false
let animationFrameId
const theme = useRefGetter('theme')
// const setting = useRefGetter('setting')
Expand All @@ -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
Expand Down Expand Up @@ -84,6 +86,7 @@ export default {
renderFrame()
}
const handlePause = () => {
if (animationFrameId) window.cancelAnimationFrame(animationFrameId)
isPlaying = false
}
Expand Down

0 comments on commit b867167

Please sign in to comment.