fix: current lyric class apply on multiple lines of lyrics which has same content
This commit is contained in:
parent
4422937707
commit
b9243b35a6
@ -11,8 +11,8 @@
|
|||||||
let _refs: any[] = [];
|
let _refs: any[] = [];
|
||||||
$: refs = _refs.filter(Boolean);
|
$: refs = _refs.filter(Boolean);
|
||||||
|
|
||||||
function getClass(lyric: string, progress: number) {
|
function getClass(lyricIndex: number, progress: number) {
|
||||||
if (lyric === currentLyric.text) return 'current-lyric';
|
if (lyricIndex === currentLyricIndex) return 'current-lyric';
|
||||||
else if (progress > currentLyric.endSeconds) return 'after-lyric';
|
else if (progress > currentLyric.endSeconds) return 'after-lyric';
|
||||||
else return 'previous-lyric';
|
else return 'previous-lyric';
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@
|
|||||||
{#if lyrics && originalLyrics}
|
{#if lyrics && originalLyrics}
|
||||||
<div class="lyrics" style="overflow-y: auto">
|
<div class="lyrics" style="overflow-y: auto">
|
||||||
{#each lyrics as lyric, i}
|
{#each lyrics as lyric, i}
|
||||||
<p bind:this={_refs[i]} class={getClass(lyric, progress)}>
|
<p bind:this={_refs[i]} class={getClass(i, progress)}>
|
||||||
{lyric}
|
{lyric}
|
||||||
</p>
|
</p>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
Reference in New Issue
Block a user