Skip to content

Commit 258629f

Browse files
committed
Fix distance calculate bug that cause infinite load
1 parent a0dc36d commit 258629f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/components/InfiniteLoading.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,16 @@
5151
distance = scrollTop;
5252
} else {
5353
let scrollElmHeight;
54-
let elOffsetTopFromScrollElm;
54+
let elOffsetTopFromScrollElm = this.$el.getBoundingClientRect().top;
5555
5656
if (elm === window) {
5757
scrollElmHeight = window.innerHeight;
58-
elOffsetTopFromScrollElm = this.$el.getBoundingClientRect().top;
5958
} else {
6059
scrollElmHeight = elm.getBoundingClientRect().height;
61-
elOffsetTopFromScrollElm = this.$el.getBoundingClientRect().top -
62-
elm.getBoundingClientRect().top;
60+
elOffsetTopFromScrollElm -= elm.getBoundingClientRect().top;
6361
}
6462
65-
distance = elOffsetTopFromScrollElm - scrollTop - scrollElmHeight - (elm.offsetTop || 0);
63+
distance = elOffsetTopFromScrollElm - scrollElmHeight - (elm.offsetTop || 0);
6664
}
6765
return distance;
6866
}

0 commit comments

Comments
 (0)