Skip to content

Commit 7346414

Browse files
committed
docs(InfiniteScroll): add correct documentation
1 parent bd6a806 commit 7346414

File tree

3 files changed

+34
-45
lines changed

3 files changed

+34
-45
lines changed

README.md

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
[![Build Status][travis-badge]][travis-badge-url]
33
[![Coverage Status][coveralls-badge]][coveralls-badge-url]
44

5-
A simple progressive/responsive/lazy loading image library for [Angular (2/4+)][angular] that detects browser size and loads the appropriate image only when the element is in view. This package requires [angular-inviewport][angular-inviewport]
6-
7-
<img src="https://raw.githubusercontent.com/thisissoon/angular-infinite-scroll/master/src/demo/example.gif" alt="example">
5+
Simple, lightweight infinite scrolling directive for [Angular (2/4+)][angular] with no other dependencies which emits and event when element has scrolled to the end.
86

97
This is a simple library for [Angular][angular], implemented in the [Angular Package Format v4.0](https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx).
108

119

1210
## Install
1311

14-
`npm i @thisissoon/{angular-infinite-scroll,angular-inviewport} --save`
12+
`npm i @thisissoon/angular-infinite-scroll --save`
1513

1614
`app.module.ts`
1715
```ts
@@ -33,54 +31,30 @@ a working example can be found inside [/src/demo](https://github.com/thisissoon/
3331
### `app.component.html`
3432

3533
```html
36-
<sn-infinite-scroll [image]="image" [sizes]="sizes" imgClass="foo" alt="lorem ipsum"></sn-infinite-scroll>
34+
<div
35+
class="foo"
36+
snInfiniteScroll
37+
(onScrollEnd)="onScrollEnd()"
38+
[offset]="100"
39+
[disabled]="disabled">
40+
</div>
3741
```
3842

3943
### `app.component.ts`
4044

4145
```ts
4246
export class AppComponent {
43-
sizes: Breakpoint[] = [
44-
{ size: 'xs', width: 0},
45-
{ size: 'md', width: 768},
46-
{ size: 'lg', width: 992},
47-
];
48-
49-
image: ResponsiveImage = {
50-
placeholder: 'http://via.placeholder.com/35x15?text=placeholder',
51-
fallback: 'http://via.placeholder.com/350x150?text=fallback',
52-
xs: {
53-
'@1x': 'http://via.placeholder.com/150x350?text=xs+1x',
54-
'@2x': 'http://via.placeholder.com/300x700?text=xs+2x'
55-
},
56-
md: {
57-
'@1x': 'http://via.placeholder.com/350x250?text=md+1x',
58-
'@2x': 'http://via.placeholder.com/700x500?text=md+2x'
59-
},
60-
lg: {
61-
'@1x': 'http://via.placeholder.com/700x400?text=lg+1x',
62-
'@2x': 'http://via.placeholder.com/1400x800?text=lg+2x'
63-
}
64-
};
65-
}
66-
```
67-
68-
### `app.component.css`
69-
70-
```css
71-
.foo {
72-
transition: all .35s ease-in-out;
47+
onScrollEnd() {
48+
// Do something here
49+
}
7350
}
7451

75-
.sn-image-not-loaded /deep/ .foo {
76-
filter: blur(20px);
77-
}
78-
79-
.sn-image-loaded /deep/ .foo {
80-
filter: blur(0px);
81-
}
8252
```
8353

54+
## Options
55+
56+
* `offset` (number): distance in px from bottom of element to trigger `onSctollEnd` event (default: 0)
57+
* `disabled` (boolean): If true directive will not trigger event
8458

8559
[travis-badge]: https://travis-ci.org/thisissoon/angular-infinite-scroll.svg?branch=master
8660
[travis-badge-url]: https://travis-ci.org/thisissoon/angular-infinite-scroll

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@thisissoon/angular-infinite-scroll",
33
"version": "0.1.0",
44
"private": false,
5-
"description": "Simple, lightweight infinite scrolling for Angular (2/4+), with no other dependencies.",
5+
"description": "Simple, lightweight infinite scrolling directive for Angular (2/4+) with no other dependencies.",
66
"keywords": [
77
"angular",
88
"angular 2",
@@ -56,8 +56,7 @@
5656
"postrelease": "npm run build"
5757
},
5858
"peerDependencies": {
59-
"@angular/core": ">=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0",
60-
"rxjs": ">=5.0.0 <6.0.0"
59+
"@angular/core": ">=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0"
6160
},
6261
"devDependencies": {
6362
"@angular/common": "^4.3.4",

src/lib/src/infinite-scroll/infinite-scroll.directive.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ import 'rxjs/add/operator/map';
88
import { Scroll } from '../scroll.model';
99
import * as events from '../events';
1010

11+
/**
12+
* @example
13+
* ```
14+
* <div
15+
* class="foo"
16+
* snInfiniteScroll
17+
* (onScrollEnd)="onScrollEnd()"
18+
* [offset]="100"
19+
* [disabled]="disabled">
20+
* </div>
21+
* ```
22+
*
23+
* @export
24+
* @class InfiniteScrollDirective
25+
* @implements {AfterViewInit}
26+
*/
1127
@Directive({
1228
selector: '[snInfiniteScroll]'
1329
})

0 commit comments

Comments
 (0)