Refactor randomize slide images on init
This commit is contained in:
parent
de989ad5a0
commit
c628f1e05b
|
|
@ -12,10 +12,6 @@ export class HomeComponent implements OnInit {
|
|||
constructor(private titleService: Title) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.titleService.setTitle('Survival Minecraft Server on ' + ALTITUDE_VERSION + ' | Altitude Community');
|
||||
}
|
||||
|
||||
private slides: string[] = ["/public/img/backgrounds/caruselimage2.png",
|
||||
"/public/img/backgrounds/caruselimage4.png",
|
||||
"/public/img/backgrounds/caruselimage1.png",
|
||||
|
|
@ -23,6 +19,23 @@ export class HomeComponent implements OnInit {
|
|||
"/public/img/backgrounds/caruselimage3.png"
|
||||
];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.titleService.setTitle('Survival Minecraft Server on ' + ALTITUDE_VERSION + ' | Altitude Community');
|
||||
this.randomizeSlides()
|
||||
}
|
||||
|
||||
|
||||
private randomizeSlides(): void {
|
||||
const array = [...this.slides];
|
||||
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
|
||||
this.slides = array;
|
||||
}
|
||||
|
||||
private slideIndex = 0;
|
||||
|
||||
get slide(): string {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user