Fixed scroll to top
This commit is contained in:
parent
57c6480877
commit
17ab9b874d
@ -25,6 +25,7 @@ export class NavbarComponent implements AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.sub = combineLatest([this.router.events.pipe(filter(e => e instanceof NavigationEnd)), this.route.fragment]).subscribe(([url, frag]) => {
|
this.sub = combineLatest([this.router.events.pipe(filter(e => e instanceof NavigationEnd)), this.route.fragment]).subscribe(([url, frag]) => {
|
||||||
|
console.log('fire');
|
||||||
if(frag) this.scroll(frag);
|
if(frag) this.scroll(frag);
|
||||||
else this.scrollTop();
|
else this.scrollTop();
|
||||||
});
|
});
|
||||||
@ -41,7 +42,6 @@ export class NavbarComponent implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scrollTop() {
|
scrollTop() {
|
||||||
const container = document.getElementsByClassName('app-container')[0];
|
window.scrollTo(0, 0);
|
||||||
container.scrollTo(0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user