1.0.4 • Published 7 years ago

angular-smooth-scroller v1.0.4

Weekly downloads
17
License
-
Repository
github
Last release
7 years ago

angularSmoothScroller

This is an angular service that smoothly scrolls the page or the chosen scrollable element to a given target element vertical position.

Installation

Install it with npm:

npm install angular-smooth-scroller

Install it with bower:

bower install angular-smooth-scroller

Usage

  1. Register the angularSmoothScroller module into your app's module.

    angular.module( 'myApp', [ 'angularSmoothScroller' ] );
  2. Inject the angularSmoothScroller service into your controller:

    myApp.controller( 'AppController', function ( angularSmoothScroller ) {
        // your code here
    } );
  3. Set the scrollable element (default is window):

    angularSmoothScroller.setScrollableContainer( 'content' );
  4. Scroll the scrollable container to the target element:

    angularSmoothScroller.scrollTo( 'targetId', 1000, 100 );

Methods

angularSmoothScroller.setScrollableContainer(elementSelector)

ParamTypeDescriptionDefault ValueOptions
elementSelectorstring | HTMLElementThe element selector or objectwindow--

angularSmoothScroller.scrollTo(el, speed, offset, easingFn)

ParamTypeDescriptionDefault ValueOptions
elstring | HTMLElementThe element selector or objectwindow--
speednumberThe scrolling speed (in ms)2000--
offsetnumberThe distance between the top of the viewport and the target element0--
easingFnstringThe easing function name.easeInOutQuinteaseOutSine, easeInOutSine and easeInOutQuint

@returns Promise

NOTE: The scrollable element must have a vertical scrollbar. Only vertical scrolling is supported ATM.