This is an angular service that smoothly scrolls the page or the chosen scrollable element to a given target element vertical position.
Install it with npm:
npm install angular-smooth-scroller
Install it with bower:
bower install angular-smooth-scroller
-
Register the
angularSmoothScroller
module into your app's module.angular.module( 'myApp', [ 'angularSmoothScroller' ] );
-
Inject the
angularSmoothScroller
service into your controller:myApp.controller( 'AppController', function ( angularSmoothScroller ) { // your code here } );
-
Set the scrollable element (default is
window
):angularSmoothScroller.setScrollableContainer( 'content' );
-
Scroll the scrollable container to the target element:
angularSmoothScroller.scrollTo( 'targetId', 1000, 100 );
Param | Type | Description | Default Value | Options |
---|---|---|---|---|
elementSelector | `string | HTMLElement` | The element selector or object | window |
Param | Type | Description | Default Value | Options |
---|---|---|---|---|
el | `string | HTMLElement` | The element selector or object | window |
speed | number |
The scrolling speed (in ms) | 2000 |
-- |
offset | number |
The distance between the top of the viewport and the target element | 0 |
-- |
easingFn | string |
The easing function name. | easeInOutQuint |
easeOutSine , easeInOutSine and easeInOutQuint |
@returns Promise
NOTE: The scrollable element must have a vertical scrollbar. Only vertical scrolling is supported ATM.