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
This version introduces upwards scroll support (fixes [#466](https://github.com/webcreate/infinite-ajax-scroll/issues/466)). See documentation on the [`prev`](docs/options.md#prev) option on how to enable this feature.
@@ -123,7 +128,8 @@ See [LICENSE](LICENSE) for more details.
Infinite Ajax Scroll can also be used to load items above the current scroll position. This is useful when you want to load older items first.
4
+
5
+
*Introduced in Infinite Ajax Scroll 3.1.0*
6
+
7
+
## Caveats
8
+
9
+
### Fixed height images
10
+
11
+
Upward scroll works by calculation screen height and content height. Due to they way browser load content, especially images, this could cause incorrect measurements. This can be solved by using fixed height images.
12
+
13
+
## Setup
14
+
15
+
1. Add a previous page link to your pagination.
16
+
17
+
```html
18
+
<divclass="pagination">
19
+
<ahref="page1.html"class="prev">Prev</a>
20
+
<spanclass="current">2</span>
21
+
<ahref="page3.html"class="next">Next</a>
22
+
</div>
23
+
```
24
+
25
+
2. Configure the [`prev`](../options.md#prev) option.
26
+
27
+
```javascript
28
+
// import if you use the NPM package
29
+
import InfiniteAjaxScroll from '@webcreate/infinite-ajax-scroll';
30
+
31
+
let ias = new InfiniteAjaxScroll('.container', {
32
+
item: '.item',
33
+
next: '.next',
34
+
prev: '.prev',
35
+
pagination: '.pagination'
36
+
});
37
+
```
38
+
39
+
## Hook into upward scroll with events
40
+
41
+
In this example we notify the user about loading the previous page.
42
+
43
+
```js
44
+
ias.on('prev', function(event) {
45
+
// pageIndex is 0-indexed, so we add 1
46
+
alert(`Page ${event.pageIndex+1} is loading...`);
47
+
});
48
+
ias.on('preved', function(event) {
49
+
alert(`Page ${event.pageIndex+1} is loaded and prepended to the page.`);
50
+
});
51
+
```
52
+
53
+
## Inform user about first page reached
54
+
55
+
In this example we notify the user when the first page is reached.
0 commit comments