This repository has been archived on 2025-06-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
casino/frontend/src/app/feature/landing/landing.component.ts

56 lines
1.3 KiB
TypeScript

import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { NgFor } from '@angular/common';
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
import { RouterLink } from '@angular/router';
@Component({
selector: 'app-landing-page',
standalone: true,
imports: [NavbarComponent, NgFor, RouterLink],
templateUrl: './landing.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LandingComponent implements OnInit, OnDestroy {
currentSlide = 0;
private autoplayInterval: ReturnType<typeof setInterval> | undefined;
ngOnInit() {
this.startAutoplay();
}
ngOnDestroy() {
this.stopAutoplay();
}
prevSlide() {
this.currentSlide = this.currentSlide === 0 ? 1 : 0;
this.resetAutoplay();
}
nextSlide() {
this.currentSlide = this.currentSlide === 1 ? 0 : 1;
this.resetAutoplay();
}
goToSlide(index: number) {
this.currentSlide = index;
this.resetAutoplay();
}
private startAutoplay() {
this.autoplayInterval = setInterval(() => {
this.nextSlide();
}, 5000);
}
private stopAutoplay() {
if (this.autoplayInterval) {
clearInterval(this.autoplayInterval);
}
}
private resetAutoplay() {
this.stopAutoplay();
this.startAutoplay();
}
}