fix: 歌词滚动异常

- 这屎山代码快要看不懂了 😂
This commit is contained in:
imsyy
2023-03-28 15:52:02 +08:00
parent 85ec29d874
commit 33831ee861
2 changed files with 13 additions and 4 deletions

View File

@@ -88,6 +88,7 @@
? { textAlign: 'center', paddingRight: '0' }
: null
"
@mouseenter="lrcMouseStatus = true"
@mouseleave="lrcAllLeave"
>
<div class="placeholder"></div>
@@ -203,10 +204,10 @@ const jumpTime = (time) => {
};
// 鼠标移出歌词区域
const lrcMouseStatus = ref(false);
const lrcAllLeave = () => {
if (!music.playState) {
lyricsScroll(music.getPlaySongLyricIndex);
}
lrcMouseStatus.value = false;
lyricsScroll(music.getPlaySongLyricIndex);
};
// 全屏切换
@@ -241,7 +242,7 @@ const lyricsScroll = (index) => {
const el = document.getElementById(
`lrc${type === "center" ? index : index - 2}`
);
if (el) {
if (el && !lrcMouseStatus.value) {
el.scrollIntoView({
behavior: "smooth",
block: type,

View File

@@ -333,7 +333,13 @@ const songPlay = () => {
};
// 音乐渐入渐出
const isFading = ref(false);
const songInOrOut = (type) => {
if (isFading.value) {
return;
}
isFading.value = true;
if (type === "play") {
let volume = 0;
$player.play();
@@ -341,6 +347,7 @@ const songInOrOut = (type) => {
// 如果音量已经到达当前音量,则停止渐入
if (volume >= persistData.value.playVolume) {
clearInterval(interval);
isFading.value = false;
return;
}
// 增加音量
@@ -357,6 +364,7 @@ const songInOrOut = (type) => {
if (volume <= 0) {
clearInterval(interval);
$player.pause();
isFading.value = false;
return;
}
// 减小音量