File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -194,12 +194,16 @@ export default {
194194 });
195195
196196 this .$on (' $InfiniteLoading:reset' , (ev ) => {
197- this .status = STATUS .READY ;
198- this .isFirstLoad = true ;
199- throttleer .reset ();
200- scrollBarStorage .remove (this .scrollParent );
201197 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 );
203207
204208 if (! ev || ev .target !== this ) {
205209 warn (WARNINGS .IDENTIFIER );
Original file line number Diff line number Diff line change @@ -22,17 +22,32 @@ export function error(msg) {
2222}
2323
2424export const throttleer = {
25+ timers : { } ,
2526 caches : [ ] ,
2627 throttle ( fn ) {
2728 if ( this . caches . indexOf ( fn ) === - 1 ) {
29+ const fnIndex = this . caches . length ;
30+
31+ // cache current handler
2832 this . caches . push ( fn ) ;
29- setTimeout ( ( ) => {
33+
34+ // save timer for current handler
35+ this . timers [ fnIndex ] = setTimeout ( ( ) => {
3036 fn ( ) ;
31- this . caches . splice ( this . caches . indexOf ( fn ) , 1 ) ;
37+
38+ // empty cache and timer
39+ this . caches . splice ( fnIndex , 1 ) ;
3240 } , config . system . throttleLimit ) ;
3341 }
3442 } ,
3543 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
3651 this . caches = [ ] ;
3752 } ,
3853} ;
You can’t perform that action at this time.
0 commit comments