Created
May 12, 2020 20:56
-
-
Save dsebastien/53b71a7bf5473985d8c459159080da51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@Component( | |
{ | |
selector: "app-root", | |
templateUrl: "./app.component.html", | |
styleUrls: ["./app.component.scss"], | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
encapsulation: ViewEncapsulation.None, | |
}) | |
export class AppComponent implements AfterViewInit { | |
... | |
@ViewChild("mainContent") | |
private mainContentElement!: ElementRef<HTMLElement>; | |
... | |
constructor( | |
... | |
@Inject(ROUTER_SCROLL_SERVICE) | |
private readonly routerScrollService: RouterScrollService, | |
... | |
) { ... } | |
... | |
ngAfterViewInit() { | |
if (this.mainContentElement) { | |
this.routerScrollService.setCustomViewportToScroll(this.mainContentElement.nativeElement); | |
} else { | |
this.logger.error( | |
"The main content element could not be found. Was it renamed? It is required here to ensure that scrolling works as expected!", | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment