diff --git a/src/app/components/navbar/navbar.component.ts b/src/app/components/navbar/navbar.component.ts index e9b66cc..36a8a7d 100644 --- a/src/app/components/navbar/navbar.component.ts +++ b/src/app/components/navbar/navbar.component.ts @@ -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); + } }