Fixed auto scroll
This commit is contained in:
		@@ -23,11 +23,9 @@ export class NavbarComponent implements AfterViewInit, OnDestroy {
 | 
				
			|||||||
	constructor(private route: ActivatedRoute, private router: Router) { }
 | 
						constructor(private route: ActivatedRoute, private router: Router) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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', frag);
 | 
					 | 
				
			||||||
			if(frag) this.scroll(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'});
 | 
							if(el) el.scrollIntoView({behavior: 'smooth'});
 | 
				
			||||||
		else setTimeout(() => this.scroll(id), 500);
 | 
							else setTimeout(() => this.scroll(id), 500);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						scrollTop() {
 | 
				
			||||||
 | 
							const container = document.getElementsByClassName('app-container')[0];
 | 
				
			||||||
 | 
							container.scrollTo(0, 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user