File tree Expand file tree Collapse file tree 4 files changed +51
-20
lines changed
Expand file tree Collapse file tree 4 files changed +51
-20
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,7 @@ updates:
55 schedule :
66 interval : daily
77 time : " 04:00"
8- open-pull-requests-limit : 2
9- ignore :
10- - dependency-name : cypress
11- versions :
12- - 7.0.0
13- - 7.0.1
14- - dependency-name : rollup
15- versions :
16- - 2.38.2
17- - 2.38.4
8+ open-pull-requests-limit : 4
189- package-ecosystem : npm
1910 directory : " /examples/articles"
2011 schedule :
@@ -27,9 +18,33 @@ updates:
2718 interval : daily
2819 time : " 04:00"
2920 open-pull-requests-limit : 2
21+ - package-ecosystem : npm
22+ directory : " /examples/button"
23+ schedule :
24+ interval : daily
25+ time : " 04:00"
26+ open-pull-requests-limit : 2
27+ - package-ecosystem : npm
28+ directory : " /examples/json"
29+ schedule :
30+ interval : daily
31+ time : " 04:00"
32+ open-pull-requests-limit : 2
3033- package-ecosystem : npm
3134 directory : " /examples/masonry"
3235 schedule :
3336 interval : daily
3437 time : " 04:00"
3538 open-pull-requests-limit : 2
39+ - package-ecosystem : npm
40+ directory : " /examples/overflow"
41+ schedule :
42+ interval : daily
43+ time : " 04:00"
44+ open-pull-requests-limit : 2
45+ - package-ecosystem : npm
46+ directory : " /examples/vuejs"
47+ schedule :
48+ interval : daily
49+ time : " 04:00"
50+ open-pull-requests-limit : 2
Original file line number Diff line number Diff line change @@ -70,9 +70,22 @@ Triggered right after the `hit` event. Indicating that the next page will be loa
7070| property | type | description |
7171| :--- | :--- | :--- |
7272| pageIndex | int | The page index of the next page (the page that is about to be loaded) |
73+ | promise | Promise | A Promise that is resolved when the next operation finishes |
7374
7475> pageIndex is zero indexed. This means the index starts at 0 on the first page.
7576
77+ For example to notify the user about loading the next page, you can do:
78+
79+ ``` js
80+ ias .on (' next' , function (event ) {
81+ alert (` Page ${ event .pageIndex + 1 } is loading...` );
82+
83+ event .promise .then (function () {
84+ alert (` Page ${ event .pageIndex + 1 } is loaded and added to the page.` );
85+ });
86+ });
87+ ```
88+
7689### load
7790
7891This event is triggered before the next page is requested from the server.
Original file line number Diff line number Diff line change @@ -142,15 +142,11 @@ export default class InfiniteAjaxScroll {
142142
143143 this . pause ( ) ;
144144
145- let event = {
146- pageIndex : this . pageIndex + 1 ,
147- } ;
145+ const pageIndex = this . pageIndex + 1 ;
148146
149- this . emitter . emit ( Events . NEXT , event ) ;
150-
151- return Promise . resolve ( this . nextHandler ( event . pageIndex ) )
147+ const promise = Promise . resolve ( this . nextHandler ( pageIndex ) )
152148 . then ( ( hasNextUrl ) => {
153- this . pageIndex = event . pageIndex ;
149+ this . pageIndex = pageIndex ;
154150
155151 if ( ! hasNextUrl ) {
156152 this . emitter . emit ( Events . LAST ) ;
@@ -161,6 +157,15 @@ export default class InfiniteAjaxScroll {
161157 this . resume ( ) ;
162158 } )
163159 ;
160+
161+ const event = {
162+ pageIndex : this . pageIndex + 1 ,
163+ promise
164+ } ;
165+
166+ this . emitter . emit ( Events . NEXT , event ) ;
167+
168+ return promise ;
164169 }
165170
166171 /**
Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ export default class Paging {
4949 let url = document . location . toString ( ) ;
5050 let title = document . title ;
5151
52- // @todo can be moved inside appended when eventStack is implemented
5352 let loaded = ( event ) => {
5453 url = event . url ;
5554
@@ -60,7 +59,7 @@ export default class Paging {
6059
6160 this . ias . once ( Events . LOADED , loaded ) ;
6261
63- this . ias . once ( Events . APPENDED , ( ) => {
62+ nextEvent . promise . then ( ( ) => {
6463 this . pageBreaks . push ( {
6564 pageIndex : nextEvent . pageIndex ,
6665 url,
@@ -70,7 +69,6 @@ export default class Paging {
7069
7170 this . update ( ) ;
7271
73- // @todo can be removed when eventStack is implemented
7472 this . ias . off ( Events . LOADED , loaded ) ;
7573 } ) ;
7674 }
You can’t perform that action at this time.
0 commit comments