From 78cf146a9297c7c8fa7d95438de4102de6114e61 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 25 Dec 2021 15:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E6=BB=9A=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer-lyric/components/core/Lyric.vue | 8 +++++++- src/renderer/utils/compositions/useLyric.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer-lyric/components/core/Lyric.vue b/src/renderer-lyric/components/core/Lyric.vue index 662af1ba14..84b1f28dfb 100644 --- a/src/renderer-lyric/components/core/Lyric.vue +++ b/src/renderer-lyric/components/core/Lyric.vue @@ -14,6 +14,7 @@ import { scrollTo } from '@renderer/utils' import Lyric from '@renderer/utils/lyric-font-player' let cancelScrollFn = null +let delayScrollTimeout export default { props: { @@ -126,7 +127,8 @@ export default { if (n < 0) return if (n == 0 && this.isSetedLines) return this.isSetedLines = false if (o == null || n - o != 1) return this.handleScrollLrc() - setTimeout(() => { + delayScrollTimeout = setTimeout(() => { + delayScrollTimeout = null this.handleScrollLrc(600) }, 600) }, @@ -251,6 +253,10 @@ export default { this.lyricEvent.msDownY = y this.lyricEvent.msDownScrollY = this.$refs.dom_lyric.scrollTop } else { + if (delayScrollTimeout) { + clearTimeout(delayScrollTimeout) + delayScrollTimeout = null + } this.winEvent.isMsDown = true this.winEvent.msDownX = x this.winEvent.msDownY = y diff --git a/src/renderer/utils/compositions/useLyric.js b/src/renderer/utils/compositions/useLyric.js index bad6dc323c..eb728cfa63 100644 --- a/src/renderer/utils/compositions/useLyric.js +++ b/src/renderer/utils/compositions/useLyric.js @@ -40,6 +40,10 @@ export default ({ isPlay, lyric }) => { } const handleLyricMouseDown = event => { // console.log(event) + if (delayScrollTimeout) { + clearTimeout(delayScrollTimeout) + delayScrollTimeout = null + } isMsDown.value = true msDownY = event.clientY msDownScrollY = dom_lyric.value.scrollTop @@ -103,12 +107,14 @@ export default ({ isPlay, lyric }) => { } } + let delayScrollTimeout const scrollLine = (line, oldLine) => { if (line < 0) return if (line == 0 && isSetedLines) return isSetedLines = false if (oldLine == null || line - oldLine != 1) return handleScrollLrc() - setTimeout(() => { + delayScrollTimeout = setTimeout(() => { + delayScrollTimeout = null handleScrollLrc(600) }, 600) }