Skip to content

Commit

Permalink
perf: refresh highlight on change
Browse files Browse the repository at this point in the history
  • Loading branch information
eatgrass committed Jan 3, 2024
1 parent 1b13ca4 commit f128dcf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/LyricsMarkdownRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ export default class LyricsMarkdownRender extends MarkdownRenderChild {
}

if (!this.pauseHl) {
if (this.currentHL >= 0) {
let hlels = this.container.findAll('.lyrics-highlighted')
hlels.forEach((el) => {
//remove highlight
lyrics.forEach((el, index) => {
if (index !== hl) {
el.removeClass('lyrics-highlighted')
})
}
}
})

if (hl >= 0) {
const hlel = lyrics.item(hl)
if (hlel) {
if (hlel && !hlel.hasClass('lyrics-highlighted')) {
hlel.addClass('lyrics-highlighted')
if (this.autoScroll) {
hlel.scrollIntoView({
Expand Down

0 comments on commit f128dcf

Please sign in to comment.