diff --git a/js/components/FavoriteBar.js b/js/components/FavoriteBar.js index 21bcd52..3ed05d3 100644 --- a/js/components/FavoriteBar.js +++ b/js/components/FavoriteBar.js @@ -114,13 +114,16 @@ export function FavoriteBar({teams}) { scrollTo.classList.add('scroll-to-highlight'); setTimeout(() => { scrollTo.classList.remove('scroll-to-highlight'); - }, 2000); + }, 1005); window.removeEventListener('scroll', handleScroll); }, 100); }; scrollTo.scrollIntoView({behavior: 'smooth', block: 'center'}); // Smoothly scroll to the target element + // scroll up a tiny amount to reset the scroll event listener if user is already on the element + window.scrollBy(0, 1); + // Add a scroll event listener to start the highlighting after scrolling only window.addEventListener('scroll', handleScroll); };