You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,7 +27,7 @@ added. An infinite-scroll that actually works and super-simple to integrate!
26
27
hasMore={true}
27
28
loader={<h4>Loading...</h4>}
28
29
endMessage={
29
-
<p style={{textAlign:'center'}}>
30
+
<p style={{textAlign:'center'}}>
30
31
<b>Yay! You have seen it all</b>
31
32
</p>
32
33
}
@@ -35,23 +36,55 @@ added. An infinite-scroll that actually works and super-simple to integrate!
35
36
pullDownToRefresh
36
37
pullDownToRefreshThreshold={50}
37
38
pullDownToRefreshContent={
38
-
<h3 style={{textAlign:'center'}}>↓ Pull down to refresh</h3>
39
+
<h3 style={{textAlign:'center'}}>↓ Pull down to refresh</h3>
39
40
}
40
41
releaseToRefreshContent={
41
-
<h3 style={{textAlign:'center'}}>↑ Release to refresh</h3>
42
-
}>
42
+
<h3 style={{ textAlign:'center' }}>↑ Release to refresh</h3>
43
+
}
44
+
>
43
45
{items}
44
46
</InfiniteScroll>
45
47
```
46
48
49
+
# using scroll on top
50
+
51
+
```jsx
52
+
<div
53
+
id="scrollableDiv"
54
+
style={{
55
+
height:300,
56
+
overflow:'auto',
57
+
display:'flex',
58
+
flexDirection:'column-reverse',
59
+
}}
60
+
>
61
+
{/*Put the scroll bar always on the bottom*/}
62
+
<InfiniteScroll
63
+
dataLength={this.state.items.length}
64
+
next={this.fetchMoreData}
65
+
style={{ display:'flex', flexDirection:'column-reverse' }} //To put endMessage and loader to the top.
66
+
inverse={true} //
67
+
hasMore={true}
68
+
loader={<h4>Loading...</h4>}
69
+
scrollableTarget="scrollableDiv"
70
+
>
71
+
{this.state.items.map((_, index) => (
72
+
<div style={style} key={index}>
73
+
div - #{index}
74
+
</div>
75
+
))}
76
+
</InfiniteScroll>
77
+
</div>
78
+
```
79
+
47
80
The `InfiniteScroll` component can be used in three ways.
48
81
49
82
- Specify a value for the `height` prop if you want your **scrollable** content to have a specific height, providing scrollbars for scrolling your content and fetching more data.
50
83
- If your **scrollable** content is being rendered within a parent element that is already providing overflow scrollbars, you can set the `scrollableTarget` prop to reference the DOM element and use it's scrollbars for fetching more data.
51
-
- Without setting either the `height` or `scrollableTarget` props, the scroll will happen at `document.body` like *Facebook's* timeline scroll.
52
-
84
+
- Without setting either the `height` or `scrollableTarget` props, the scroll will happen at `document.body` like _Facebook's_ timeline scroll.
53
85
54
86
# docs version wise
87
+
55
88
[3.0.2](docs/README-3.0.2.md)
56
89
57
90
# live examples
@@ -66,24 +99,26 @@ The `InfiniteScroll` component can be used in three ways.
**next** | function | a function which must be called after reaching the bottom. It must trigger some sort of action which fetches the next data. **The data is passed as `children` to the `InfiniteScroll` component and the data should contain previous items too.** e.g. *Initial data = [1, 2, 3]* and then next load of data should be *[1, 2, 3, 4, 5, 6]*.
72
-
**hasMore** | boolean | it tells the `InfiniteScroll` component on whether to call `next` function on reaching the bottom and shows an `endMessage` to the user
73
-
**children** | node (list) | the data items which you need to scroll.
74
-
**dataLength** | number | set the length of the data.This will unlock the subsequent calls to next.
75
-
**loader** | node | you can send a loader component to show while the component waits for the next load of data. e.g. `<h3>Loading...</h3>` or any fancy loader element
76
-
**scrollThreshold** | number | string | A threshold value defining when `InfiniteScroll` will call `next`. Default value is `0.8`. It means the `next` will be called when user comes below 80% of the total height. If you pass threshold in pixels (`scrollThreshold="200px"`), `next` will be called once you scroll at least (100% - scrollThreshold) pixels down.
77
-
**onScroll** | function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect.
78
-
**endMessage** | node | this message is shown to the user when he has seen all the records which means he's at the bottom and `hasMore` is `false`
79
-
**className** | string | add any custom class you want
80
-
**style** | object | any style which you want to override
81
-
**height** | number | optional, give only if you want to have a fixed height scrolling content
82
-
**scrollableTarget** | node or string | optional, reference to a (parent) DOM element that is already providing overflow scrollbars to the `InfiniteScroll` component. *You should provide the `id` of the DOM node preferably.*
83
-
**hasChildren** | bool | `children` is by default assumed to be of type array and it's length is used to determine if loader needs to be shown or not, if your `children` is not an array, specify this prop to tell if your items are 0 or more.
84
-
**pullDownToRefresh** | bool | to enable **Pull Down to Refresh** feature
85
-
**pullDownToRefreshContent** | node | any JSX that you want to show the user, `default={<h3>Pull down to refresh</h3>}`
86
-
**releaseToRefreshContent** | node | any JSX that you want to show the user, `default={<h3>Release to refresh</h3>}`
87
-
**pullDownToRefreshThreshold** | number | minimum distance the user needs to pull down to trigger the refresh, `default=100px` , a lower value may be needed to trigger the refresh depending your users browser.
88
-
**refreshFunction** | function | this function will be called, it should return the fresh data that you want to show the user
89
-
**initialScrollY** | number | set a scroll y position for the component to render with.
|**next**| function | a function which must be called after reaching the bottom. It must trigger some sort of action which fetches the next data. **The data is passed as `children` to the `InfiniteScroll` component and the data should contain previous items too.** e.g. _Initial data = [1, 2, 3]_ and then next load of data should be _[1, 2, 3, 4, 5, 6]_. |
106
+
|**hasMore**| boolean | it tells the `InfiniteScroll` component on whether to call `next` function on reaching the bottom and shows an `endMessage` to the user |
107
+
|**children**| node (list) | the data items which you need to scroll. |
108
+
|**dataLength**| number | set the length of the data.This will unlock the subsequent calls to next. |
109
+
|**loader**| node | you can send a loader component to show while the component waits for the next load of data. e.g. `<h3>Loading...</h3>` or any fancy loader element |
110
+
|**scrollThreshold**| number | string | A threshold value defining when `InfiniteScroll` will call `next`. Default value is `0.8`. It means the `next` will be called when user comes below 80% of the total height. If you pass threshold in pixels (`scrollThreshold="200px"`), `next` will be called once you scroll at least (100% - scrollThreshold) pixels down. |
111
+
|**onScroll**| function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect. |
112
+
|**endMessage**| node | this message is shown to the user when he has seen all the records which means he's at the bottom and `hasMore` is `false`|
113
+
|**className**| string | add any custom class you want |
114
+
|**style**| object | any style which you want to override |
115
+
|**height**| number | optional, give only if you want to have a fixed height scrolling content |
116
+
|**scrollableTarget**| node or string | optional, reference to a (parent) DOM element that is already providing overflow scrollbars to the `InfiniteScroll` component. _You should provide the `id` of the DOM node preferably._|
117
+
|**hasChildren**| bool |`children` is by default assumed to be of type array and it's length is used to determine if loader needs to be shown or not, if your `children` is not an array, specify this prop to tell if your items are 0 or more. |
118
+
|**pullDownToRefresh**| bool | to enable **Pull Down to Refresh** feature |
119
+
|**pullDownToRefreshContent**| node | any JSX that you want to show the user, `default={<h3>Pull down to refresh</h3>}`|
120
+
|**releaseToRefreshContent**| node | any JSX that you want to show the user, `default={<h3>Release to refresh</h3>}`|
121
+
|**pullDownToRefreshThreshold**| number | minimum distance the user needs to pull down to trigger the refresh, `default=100px` , a lower value may be needed to trigger the refresh depending your users browser. |
122
+
|**refreshFunction**| function | this function will be called, it should return the fresh data that you want to show the user |
123
+
|**initialScrollY**| number | set a scroll y position for the component to render with. |
0 commit comments