import {ChangeDetectionStrategy, Component, OnInit, inject} from '@angular/core';
import {fader} from './animations';
import {ScrollService} from './services/scroll.service';
import {register} from 'swiper/element/bundle';
import {RouterOutlet} from '@angular/router';
import {NavigationComponent} from './widget-modules/components/application-frame/navigation/navigation.component';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less'],
  animations: [fader],
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [RouterOutlet, NavigationComponent],
})
export class AppComponent implements OnInit {
  private scrollService = inject(ScrollService);

  public constructor() {
    register();
  }

  public ngOnInit(): void {
    setTimeout(() => document.querySelector('#load-bg')?.classList.add('hidden'), 1000);
    setTimeout(() => document.querySelector('#load-bg')?.remove(), 5000);
  }

  public onScoll($event: {srcElement: {scrollTop: number}}): void {
    this.scrollService.saveScrollPosition($event.srcElement.scrollTop);
  }
}
