Skip to content

Commit 24d9f20

Browse files
committed
Modify the way to solve #40
1 parent 814eb3f commit 24d9f20

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/components/InfiniteLoading.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
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
7473
};
7574
},
7675
computed: {
@@ -94,7 +93,7 @@
9493
this.scrollParent = getScrollParent(this.$el);
9594
9695
this.scrollHandler = function scrollHandlerOriginal() {
97-
if (!this.isLoading && this.isActivated) {
96+
if (!this.isLoading) {
9897
this.attemptLoad();
9998
}
10099
}.bind(this);
@@ -104,7 +103,7 @@
104103
105104
this.$on('$InfiniteLoading:loaded', () => {
106105
this.isFirstLoad = false;
107-
if (this.isLoading && this.isActivated) {
106+
if (this.isLoading) {
108107
this.$nextTick(this.attemptLoad);
109108
}
110109
});
@@ -125,10 +124,11 @@
125124
* To adapt to keep-alive feature, but only work on Vue 2.2.0 and above, see: https://vuejs.org/v2/api/#keep-alive
126125
*/
127126
deactivated() {
128-
this.isActivated = false;
127+
this.isLoading = false;
128+
this.scrollParent.removeEventListener('scroll', this.scrollHandler);
129129
},
130130
activated() {
131-
this.isActivated = true;
131+
this.scrollParent.addEventListener('scroll', this.scrollHandler);
132132
},
133133
methods: {
134134
attemptLoad() {

0 commit comments

Comments
 (0)