Skip to content

Commit 814eb3f

Browse files
committed
Fix onInfinite callback bug when using multiple infinite list with keep-alive feature #40
1 parent e5653b3 commit 814eb3f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/InfiniteLoading.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
isLoading: false,
7171
isComplete: false,
7272
isFirstLoad: true, // save the current loading whether it is the first loading
73+
isActivated: true, // save activate status to support keep-alive feature
7374
};
7475
},
7576
computed: {
@@ -93,7 +94,7 @@
9394
this.scrollParent = getScrollParent(this.$el);
9495
9596
this.scrollHandler = function scrollHandlerOriginal() {
96-
if (!this.isLoading) {
97+
if (!this.isLoading && this.isActivated) {
9798
this.attemptLoad();
9899
}
99100
}.bind(this);
@@ -103,7 +104,7 @@
103104
104105
this.$on('$InfiniteLoading:loaded', () => {
105106
this.isFirstLoad = false;
106-
if (this.isLoading) {
107+
if (this.isLoading && this.isActivated) {
107108
this.$nextTick(this.attemptLoad);
108109
}
109110
});
@@ -121,10 +122,13 @@
121122
});
122123
},
123124
/**
124-
* To adapt to keep-alive feature, but only work on Vue 2.2.0 and above, see: http://vuejs.org/v2/api/#keep-alive
125+
* To adapt to keep-alive feature, but only work on Vue 2.2.0 and above, see: https://vuejs.org/v2/api/#keep-alive
125126
*/
126127
deactivated() {
127-
this.isLoading = false;
128+
this.isActivated = false;
129+
},
130+
activated() {
131+
this.isActivated = true;
128132
},
129133
methods: {
130134
attemptLoad() {

0 commit comments

Comments
 (0)