Skip to content

Commit f4623af

Browse files
authored
Merge pull request #48 from syn-zeta/patch-1
Fix #43: Improve the way to calculate distance
2 parents 7af8b32 + dba7ece commit f4623af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/InfiniteLoading.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@
5050
if (dir === 'top') {
5151
distance = scrollTop;
5252
} else {
53+
const elmBoundingClientRect = elm.getBoundingClientRect();
5354
const scrollElmHeight = elm === window ?
5455
window.innerHeight :
55-
elm.getBoundingClientRect().height;
56+
elmBoundingClientRect.height;
57+
const elOffsetTopFromScrollElm = this.$el.getBoundingClientRect().top -
58+
elmBoundingClientRect.top;
5659
57-
distance = this.$el.offsetTop - scrollTop - scrollElmHeight - (elm.offsetTop || 0);
60+
distance = elOffsetTopFromScrollElm - scrollTop - scrollElmHeight - (elm.offsetTop || 0);
5861
}
5962
return distance;
6063
}

0 commit comments

Comments
 (0)