An open API service indexing awesome lists of open source software.

https://github.com/jasonboy/angular-lazyload

∞Angular directive for infinite loading
https://github.com/jasonboy/angular-lazyload

angular directive infinite-scroll lazyload

Last synced: 12 months ago
JSON representation

∞Angular directive for infinite loading

Awesome Lists containing this project

README

          

# angular-lazyload
Angular directive for lazy loading, especially for mobile when working with pagination, slide up to load more

[![angular-lazyload-demo](https://github.com/JasonBoy/angular-lazyload/blob/master/demo/angular-lazyload.gif)](https://github.com/JasonBoy/angular-lazyload/blob/master/demo/angular-lazyload.gif)

### Install

`npm install angular-lazyload --save`

### Usage

`

` or
`

custom loading style...

` or
``

```javascript
angular.module('myModule', ['lazyload'])
.controller('Demo', function($scope){
function loadMore() {
//loading more data
$scope.$broadcast('lazyLoadingFinished');//notify the directive to finish the current loading
if(noMore) {
$scope.$broadcast('allLoaded'); //all data loaded, remove all the touch events
}
};
//listen on the user touch event, which will be fired from the directive
$scope.$on('lazyLoading', function(){
loadMore();
});
});
```

### Directive Options

**loadingText**: '@', content to display when loading the data, default is 'loading...', if the element with the `lazyload` directive has inner html, it will use the inner html instead of the `loadingText`, with inner html, you can add complex loading styles, such as loading gif.

**offsetBottom**: '@', loading div's offset to the window bottom, default: 10px, which means when the offset to the bottom >= 10px, you are about to reload data.

**waitDuration**: '@', display the loading text with `waitDuration`ms to prevent loading too often, default: 500ms.

**scale**: '@', the scale in your `viewport` in `meta` tag, default is 1.

### Events

**lazyLoading**: when you get this event, you should load data now.

**lazyLoadingFinished**: you should notify the directive to finish the current loading.

**allLoaded**: you should notify the directive to finish the lifecycle after you get all data.

### Demo

`npm install`, then see demo in `demo` dir.

### License

MIT