-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathscrolling-view.component.ts
More file actions
22 lines (19 loc) · 939 Bytes
/
Copy pathscrolling-view.component.ts
File metadata and controls
22 lines (19 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Component, ViewEncapsulation, ViewChild, ElementRef, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { PageScrollService, PageScrollInstance } from 'ngx-page-scroll-core';
@Component({
selector: 'app-scrolling-view',
templateUrl: 'scrolling-view.component.html',
styleUrls: ['scrolling-view.component.scss'],
})
export class ScrollingViewComponent {
@ViewChild('container', {static: true}) private container: ElementRef;
constructor(private pageScrollService: PageScrollService, @Inject(DOCUMENT) private document: any) {}
public animateScroll(sectionTarget: string): void {
// https://github.com/Nolanus/ngx-page-scroll#service
const pageScrollInstance: PageScrollInstance = new PageScrollInstance({
document: this.document, scrollTarget: sectionTarget, scrollViews: [this.container.nativeElement]
});
this.pageScrollService.start(pageScrollInstance);
}
}