refactor: improve code structure and add change detection

This commit is contained in:
Jan-Marlon Leibl 2025-02-05 14:43:04 +01:00 committed by jank1619
parent 50eb399fe2
commit 849a82734a
5 changed files with 41 additions and 11 deletions

View file

@ -93,9 +93,9 @@
<div class="flex items-center justify-center gap-2">
<span
#jackpotCounter
class="text-6xl font-bold text-white tracking-tight animate-pulseGlow drop-shadow-[0_0_8px_rgba(34,197,94,0.3)]"
class="text-6xl font-bold text-white tracking-tight animate-pulseGlow drop-shadow-[0_0_8px_rgba(34,197,94,0.3)] will-change-transform"
>
€{{ currentJackpot$ | async | number }}
€{{ (currentJackpot$ | async) ?? 0 | number }}
</span>
<span class="text-emerald-500 text-lg animate-bounce"></span>
</div>

View file

@ -112,14 +112,20 @@ export class LandingComponent implements OnInit, OnDestroy, AfterViewInit {
private initializeAnimations(): void {
this.animationService.createParticleEffect(this.particleContainer);
this.animationService.animateEntrance(this.heroSection);
const gameCards = this.gamesGrid.nativeElement.querySelectorAll('.game-card');
gameCards.forEach((card: HTMLElement, index: number) => {
this.animationService.animateEntrance(new ElementRef(card), 0.1 * index);
});
autoAnimate(this.winnersMarquee.nativeElement);
const gameCards = this.gamesGrid?.nativeElement.querySelectorAll('.game-card');
if (gameCards) {
gameCards.forEach((card: HTMLElement, index: number) => {
this.animationService.animateEntrance(new ElementRef(card), 0.1 * index);
});
}
this.animationService.animateOnScroll(this.gamesGrid, 'slideUp');
this.currentJackpot$.pipe(takeUntil(this.destroy$)).subscribe((value) => {
this.animationService.animateJackpotCounter(this.jackpotCounter, value - 1000, value);
if (this.jackpotCounter && value) {
const prevValue = value - Math.floor(Math.random() * 1000 + 500);
this.animationService.animateJackpotCounter(this.jackpotCounter, prevValue, value);
}
});
}