On group scroll highlight group

This commit is contained in:
Daniel Schädler 2025-03-17 22:38:46 +01:00
parent 9a1e77e786
commit 10d3ba59dd
3 changed files with 45 additions and 17 deletions

View File

@ -76,10 +76,17 @@ export function FavoriteBar({teams}) {
if (lowestStageEl) {
lowestStageEl.scrollIntoView({behavior: 'smooth', block: 'end'});
} else {
const groupEl = document.getElementById(`favorite-team-groupstage-${favorite.id}`);
if (groupEl) {
groupEl.scrollIntoView({behavior: 'smooth', block: 'end'});
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);
}
});
}
setIsPulsing(false);
};
@ -101,7 +108,7 @@ export function FavoriteBar({teams}) {
title="{isVisible ? 'Favoriten schließen' : 'Favoriten öffnen'}"
onClick={() => setIsVisible(!isVisible)}
>
<FaHeartCirclePlus />
<FaHeartCirclePlus/>
</Button>
{favorite && (
<Button
@ -110,7 +117,7 @@ export function FavoriteBar({teams}) {
className={isPulsing ? 'pulse-animation' : ''}
innerRef={scrollButtonRef}
>
<FaArrowTurnDown />
<FaArrowTurnDown/>
</Button>
)}
</ButtonGroup>

View File

@ -65,7 +65,7 @@ export class Group extends Component {
}
handleToggle() {
this.setState(prevState => ({ showMatches: !prevState.showMatches }));
this.setState(prevState => ({showMatches: !prevState.showMatches}));
if (this.props.groupRef.current) {
this.props.groupRef.current.scrollIntoView({behavior: 'smooth', block: 'center'});
}
@ -84,9 +84,15 @@ export class Group extends Component {
}
render() {
const teamIds = new Set();
this.state.matches.forEach(match => {
teamIds.add(match.team1.id);
teamIds.add(match.team2.id);
});
const teamIdsString = Array.from(teamIds).join(',');
return (
<Col className="minw-25 py-2" ref={this.props.groupRef}>
<Card>
<Col className="minw-25 py-2">
<Card ref={this.props.groupRef} data-teams={teamIdsString}>
<CardBody className="position-relative">
<h3 className="custom-font">
Gruppe {this.state.number}

View File

@ -69,3 +69,18 @@
outline: none !important;
box-shadow: none !important;
}
@keyframes blink {
0% {
background-color: transparent;
}
50% {
background-color: yellow;
}
100% {
background-color: transparent;
}
}
.highlight {
animation: blink 1s ease-in-out;
}