Fixed auto scroll

This commit is contained in:
Zakary Timson 2022-10-30 08:23:36 -04:00
parent 11729f0281
commit eb02a6302a

View File

@ -23,11 +23,9 @@ export class NavbarComponent implements AfterViewInit, OnDestroy {
constructor(private route: ActivatedRoute, private router: Router) { }
ngAfterViewInit() {
this.sub = combineLatest([this.router.events.pipe(filter(e => e instanceof NavigationEnd)), this.route.fragment]).subscribe(([url, frag]) => {
console.log('fire', frag);
if(frag) this.scroll(frag);
else this.scroll('top');
else this.scrollTop();
});
}
@ -40,4 +38,9 @@ export class NavbarComponent implements AfterViewInit, OnDestroy {
if(el) el.scrollIntoView({behavior: 'smooth'});
else setTimeout(() => this.scroll(id), 500);
}
scrollTop() {
const container = document.getElementsByClassName('app-container')[0];
container.scrollTo(0, 0);
}
}