Skip to content

Commit 40b5c63

Browse files
committed
fix: double trigger bug when init with a scrolled wrapper (#228)
1 parent 8748ad4 commit 40b5c63

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/InfiniteLoading.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,20 @@ export default {
146146
this.scrollParent = this.getScrollParent();
147147
}, { immediate: true });
148148
149-
this.scrollHandler = function scrollHandlerOriginal(ev) {
149+
this.scrollHandler = (ev) => {
150150
if (this.status === STATUS.READY) {
151151
if (ev && ev.constructor === Event && isVisible(this.$el)) {
152152
throttleer.throttle(this.attemptLoad);
153153
} else {
154154
this.attemptLoad();
155155
}
156156
}
157-
}.bind(this);
157+
};
158158
159-
setTimeout(this.scrollHandler, 1);
160-
this.scrollParent.addEventListener('scroll', this.scrollHandler, evt3rdArg);
159+
setTimeout(() => {
160+
this.scrollHandler();
161+
this.scrollParent.addEventListener('scroll', this.scrollHandler, evt3rdArg);
162+
}, 1);
161163
162164
this.$on('$InfiniteLoading:loaded', (ev) => {
163165
this.isFirstLoad = false;

0 commit comments

Comments
 (0)