Reputation: 133
For window scrolling, Currently I am using window.scrollTo() in angular2. Is any other way to achieve smooth scrolling in angular2.
Upvotes: 0
Views: 1384
Reputation: 190
Works only for Chrome, Firefox, Opera:
html{
scroll-behavior: smooth;
}
Works on all browsers: npm install scroll-behaviour
component.ts
smoothScroll(element) {
(document.querySelector(element)).scrollIntoView({behavior: 'smooth', block: 'start'});
}
component.html
<a (click)="smoothScroll('#about-sector')"> About</a>
Upvotes: 1