ibspoof / ng-iScroll

AngularJS (1.2+) directive that enables iScroll 5.x to work
143 stars 72 forks source link

ng-iScroller v1.3

AngularJS Module that enables iScroll 5.x to work using a directive

Demos

See demo/ Directory Note: Recommended to be used with iOS or Android devices only

Dependencies

Installation

Reporting Issues

Features

Usage

Options

HTML Directive Settings

Binding Delay: If you want to delay the iScroll binding due to having animations or using another JS Library to modify the Angular view you can add a timeout value by using the attribute ng-iscroll-delay='{delayInMiliseconds}'. The default delay is 5ms.

Forms: Forms within an iScroll has certain issues with editing Text values or Select boxes. To enable support for forms add the following option to the wrapper div: ng-iscroll-form='true' the default is set to 'false'

Naming of Instance: When multiple iScrolls are present on a single page and each needs different runtime settings or functions there is a need to identify each instance. This is done either by setting the 'ng-iscroll="{instanceName}"' or if not set it will default to the id of the div.

Note: This breaks version 1.0's usage of the ng-iscroll value to define the delay in dom binding. Please update your code to use ng-iscroll-delay to change the default delay.

See demos/ directory for examples of both

Angular Controller Settings

iScroll exposes both runtime and other functions that can change the appearance or behavior of the iScroll. These can be set via the AppController to further configure iScroll.

Example:

HTML:

<div id="wrapper" ng-iscroll='wrapper' ng-iscroll-delay='50'>
    <button ng-click="refreshiScroll()">Refresh</button>
</div>

AppController:

$scope.$parent.myScrollOptions = {
    'wrapper': {
        snap: false,
        onScrollEnd: function ()
        {
            alert('finshed scrolling wrapper');
    }},
};

$scope.refreshiScroll = function ()
{
    $scope.$parent.myScroll['wrapper'].refresh();
    alert('wrapper refreshed');
};

The default settings for ng-iScroll are the following:

The above can be overridden using the $scope.$parent.myScrollOptions option in your Controller.

For more examples see the demo directory.

License

ng-IScroll is released under the MIT License.

Special Thanks

Thanks to the following help for submitting bugs and suggesting new features:

Rodrigo Mesquita de Abreu

Robert

Andre Meyering

Brandon Benson