Customizable angular module to animate scroll event to an element. Compatible with Angular 2.x onwards
npm install ng-animate-scrollFirst you need to install the npm module:
``sh`
npm i ng-animate-scroll --save
: Find an element using its ID and scrolls to it smoothly. Duration of the animation is optional and has default of 750 ms.$3
`ts
import { Component } from '@angular/core';
import { NgAnimateScrollService } from 'ng-animate-scroll';@Component({
selector: 'app',
template:
})
export class AppComponent { constructor(private animateScrollService: NgAnimateScrollService) {
}
navigateToHeader(duration?:number) {
this.animateScrollService.scrollToElement('header', duration)
}
}
``