Skip to content

Commit

Permalink
allow lyric scrolling over time when manual scroll offset is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Feb 8, 2024
1 parent 2761a4e commit 636ab32
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/renderer/page/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@
<p>歌词加载中 ...</p>
</div>
<div v-show="!ui.lyricLoading"
class="scroller-wrapper"
@mousewheel="handleMouseScroll"
@mouseenter="lyricMouseIn=true"
@mouseleave="lyricMouseIn=false">
class="scroller-wrapper"
@mousewheel="handleMouseScroll"
@mouseenter="lyricMouseIn = true"
@mouseleave="lyricMouseIn = false">
<div class="scroller"
:style="lyricScrollerStyle">
<template v-if="lyricToShow">
Expand Down Expand Up @@ -468,7 +468,7 @@ export default {
if (typeof this.ui.lyric.txtLyric === 'string' || !this.$refs.lyric || this.$refs.lyric.length === 0) {
return;
}
const currentLyricElem = this.$refs.lyric[Math.max(this.currentLyricIndex,0)];
const currentLyricElem = this.$refs.lyric[Math.max(this.currentLyricIndex, 0)];
const lastElem = this.$refs.lyric[this.$refs.lyric.length - 1];
const currentToTopOffset = currentLyricElem.offsetTop;
const currentToBottomOffset = currentLyricElem.offsetTop - lastElem.offsetTop;
Expand All @@ -478,8 +478,7 @@ export default {
}
else if (willingOffset < currentToBottomOffset) {
this.lyricScrollOffset = currentToBottomOffset;
}
else {
} else {
this.lyricScrollOffset = willingOffset;
}
},
Expand Down Expand Up @@ -532,10 +531,10 @@ export default {
// reset lyric position
this.currentLyricIndex = -1;
},
['currentLyricIndex'](o, n) {
if (this.lyricMouseIn) {
['currentLyricIndex'](val, oldVal) {
if (this.lyricMouseIn && this.lyricScrollOffset !== 0) {
const lyrics = this.$refs.lyric;
const diff = lyrics[n].offsetTop - lyrics[o].offsetTop;
const diff = lyrics[oldVal].offsetTop - lyrics[val].offsetTop;
this.lyricScrollOffset -= diff;
} else {
this.lyricScrollOffset = 0;
Expand All @@ -557,6 +556,7 @@ export default {
}
},
deactivated() {
this.lyricMouseIn = false;
this.isActive = false;
}
};
Expand Down

0 comments on commit 636ab32

Please sign in to comment.