Scroll to wait and highlight playoffs as well

This commit is contained in:
Daniel Schädler 2025-03-17 22:50:54 +01:00
parent 10d3ba59dd
commit 5dd9c1155f
2 changed files with 17 additions and 8 deletions

View File

@ -73,22 +73,31 @@ export function FavoriteBar({teams}) {
}
});
let scrollTo;
if (lowestStageEl) {
lowestStageEl.scrollIntoView({behavior: 'smooth', block: 'end'});
scrollTo = lowestStageEl;
} else {
const groupElements = document.querySelectorAll('[data-teams]');
groupElements.forEach(groupEl => {
const teamIds = groupEl.getAttribute('data-teams').split(',').map(id => parseInt(id, 10));
if (teamIds.includes(favorite.id)) {
groupEl.scrollIntoView({behavior: 'smooth', block: 'center'});
groupEl.classList.add('highlight');
setTimeout(() => {
groupEl.classList.remove('highlight');
}, 2000);
scrollTo = groupEl;
}
});
}
setIsPulsing(false);
scrollTo.scrollIntoView({behavior: 'smooth', block: 'center'});
let scrollTimeout;
window.addEventListener('scroll', function() {
clearTimeout(scrollTimeout);
scrollTimeout = setTimeout(function() {
setIsPulsing(false);
scrollTo.classList.add('scroll-to-highlight');
setTimeout(() => {
scrollTo.classList.remove('scroll-to-highlight');
}, 2000);
}, 100);
}, {once: true});
};
if (isLoading) {

View File

@ -81,6 +81,6 @@
}
}
.highlight {
.scroll-to-highlight {
animation: blink 1s ease-in-out;
}