File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 83
83
this .scrollParent = getScrollParent (this .$el );
84
84
85
85
this .scrollHandler = function scrollHandlerOriginal () {
86
- const currentDistance = getCurrentDistance (this .scrollParent );
87
- if (! this .isLoading && currentDistance <= this .distance ) {
88
- this .isLoading = true ;
89
- if (this .onInfinite ) {
90
- this .onInfinite .call ();
91
- }
86
+ if (! this .isLoading ) {
87
+ this .attemptLoad ();
92
88
}
93
89
}.bind (this );
94
90
95
91
setTimeout (this .scrollHandler , 1 );
96
92
this .scrollParent .addEventListener (' scroll' , this .scrollHandler );
97
93
98
94
this .$on (' $InfiniteLoading:loaded' , () => {
99
- this .isLoading = false ;
100
95
this .isFirstLoad = false ;
96
+ if (this .isLoading ) {
97
+ this .$nextTick (this .attemptLoad );
98
+ }
101
99
});
102
100
this .$on (' $InfiniteLoading:complete' , () => {
103
101
this .isLoading = false ;
112
110
setTimeout (this .scrollHandler , 1 );
113
111
});
114
112
},
113
+ methods: {
114
+ attemptLoad () {
115
+ const currentDistance = getCurrentDistance (this .scrollParent , this .direction );
116
+ if (! this .isComplete && currentDistance <= this .distance ) {
117
+ this .isLoading = true ;
118
+ this .onInfinite .call ();
119
+ } else {
120
+ this .isLoading = false ;
121
+ }
122
+ },
123
+ },
115
124
destroyed () {
116
125
if (! this .isComplete ) {
117
126
this .scrollParent .removeEventListener (' scroll' , this .scrollHandler );
You can’t perform that action at this time.
0 commit comments