File tree 2 files changed +26
-7
lines changed
2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -194,12 +194,16 @@ export default {
194
194
});
195
195
196
196
this .$on (' $InfiniteLoading:reset' , (ev ) => {
197
- this .status = STATUS .READY ;
198
- this .isFirstLoad = true ;
199
- throttleer .reset ();
200
- scrollBarStorage .remove (this .scrollParent );
201
197
this .scrollParent .addEventListener (' scroll' , this .scrollHandler , evt3rdArg);
202
- setTimeout (this .scrollHandler , 1 );
198
+
199
+ // wait for list to be empty and the empty action may trigger a scroll event
200
+ setTimeout (() => {
201
+ this .status = STATUS .READY ;
202
+ this .isFirstLoad = true ;
203
+ throttleer .reset ();
204
+ scrollBarStorage .remove (this .scrollParent );
205
+ this .scrollHandler ();
206
+ }, 1 );
203
207
204
208
if (! ev || ev .target !== this ) {
205
209
warn (WARNINGS .IDENTIFIER );
Original file line number Diff line number Diff line change @@ -22,17 +22,32 @@ export function error(msg) {
22
22
}
23
23
24
24
export const throttleer = {
25
+ timers : { } ,
25
26
caches : [ ] ,
26
27
throttle ( fn ) {
27
28
if ( this . caches . indexOf ( fn ) === - 1 ) {
29
+ const fnIndex = this . caches . length ;
30
+
31
+ // cache current handler
28
32
this . caches . push ( fn ) ;
29
- setTimeout ( ( ) => {
33
+
34
+ // save timer for current handler
35
+ this . timers [ fnIndex ] = setTimeout ( ( ) => {
30
36
fn ( ) ;
31
- this . caches . splice ( this . caches . indexOf ( fn ) , 1 ) ;
37
+
38
+ // empty cache and timer
39
+ this . caches . splice ( fnIndex , 1 ) ;
32
40
} , config . system . throttleLimit ) ;
33
41
}
34
42
} ,
35
43
reset ( ) {
44
+ // reset all timers
45
+ Object . keys ( this . timers ) . forEach ( ( key ) => {
46
+ clearTimeout ( this . timers [ key ] ) ;
47
+ delete this . timers [ key ] ;
48
+ } ) ;
49
+
50
+ // empty caches
36
51
this . caches = [ ] ;
37
52
} ,
38
53
} ;
You can’t perform that action at this time.
0 commit comments