All Projects → wzr1337 → angular-momentum-scroll

wzr1337 / angular-momentum-scroll

Licence: MIT license
Momentum scroll for AngularJS based on iScroll

Programming Languages

javascript
184084 projects - #8 most used programming language
ApacheConf
554 projects
HTML
75241 projects
CSS
56736 projects

angular-momentum-scroll

AngularJS directive that adds momentum scroll via iScroll (http://cubiq.org).

Demo

Find a demonstration on http://wzr1337.github.com

Usage

  • Include scrollable.js or scrollable.min.js into your page

  • Declare 'angular-momentum-scroll' as a dependency for your angular app: angular.module('myApp', ['angular-momentum-scroll']);

  • Add the scrollable attribute to a container of your choice:

    • the container MUST have set width and height !!
    • in order to scroll horizontally the .scroller class inside of your container MUST have set width and height !!
  • The container takes an additional attribute parameters according to iScroll docs. e.g.

    <div id="my-cont" style="height: 400px; width: 100%;" scrollable 
    parameters="{{ {vScroll : true, snap: '.row'} }}">
  • You can register any of the following handlers by specifying a callback function via attribute:

    • onRefresh
    • onBeforeScrollStart
    • onScrollStart
    • onBeforeScrollMove
    • onScrollMove
    • onBeforeScrollEnd
    • onScrollEnd
    • onTouchEnd
    • onDestroy
    • onZoomStart
    • onZoom
    • onZoomEnd
    <div id="my-cont" style="height: 400px; width: 100%;" scrollable
    parameters="{{ {scrollbars : true, snap: '.row'} }}"
    on-scroll-move="doSometginhg()">...</div>
  • You can bind a variable to the curr-page-x and curr-page-y attribute. The data binding is bidirectional, so that you can scroll programatically as well as being notified on page change.

      <div id="my-cont" style="height: 400px; width: 100%;" scrollable
      parameters="{{ {vScroll : true, snap: '.row'} }}"
      curr-page-y="myPageY">...</div>
  • You can watch isMinY, isMinX and isMaxX, isMAxY to find out, if the scrlller reached its final top or bottom, left or right position. These help you to build an infinitescroll or similar. use them as follows:

    <ol id='mycontainer' scrollable
      parameters="{{ {vScroll:true, scrollbars: true, snap: 'li'} }}"
      curr-page-x="currPageX" curr-page-y="currPageY" curr-x="currX"
      curr-y="currY" is-min-y="isMinY" is-max-y="isMaxY">
      <li class="listitem" ng-repeat="thing in awesomeThings">{{thing}}</li>
    </ol>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].