Skip to content

Commit

Permalink
fix: reduce interval to set highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed Oct 18, 2023
1 parent 1c4f410 commit 1a32bd4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/higlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export const highlightElement = ({
context = document,
property = 'stroke',
}) => {
setTimeout(() => {
const element = context.querySelector(selector)
const fillColor = isHighlightable(songStateData) ? '#1ed760' : 'currentColor'
let element
const timer = setInterval(() => {
if (element) { clearInterval(timer); return }

element = context.querySelector(selector)
if (!element) return

const fillColor = isHighlightable(songStateData) ? '#1ed760' : 'currentColor'
element.style[property] = fillColor
}, 1000)
}, 250)
}

0 comments on commit 1a32bd4

Please sign in to comment.