Skip to content

Commit c42d2d3

Browse files
committed
fix #11: round scroll position to handle zoom
1 parent 5413dfc commit c42d2d3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*
66
*/
77

8-
// @ts-ignore
98
import debounce from 'lodash.debounce'
109
import React, { Component } from 'react'
1110

@@ -84,11 +83,10 @@ class BottomScrollListener extends Component<Props> {
8483
}
8584
} else {
8685
const scrollNode = document.scrollingElement || document.documentElement
86+
const scrollContainerBottomPosition = Math.round(scrollNode.scrollTop + window.innerHeight)
87+
const scrollPosition = Math.round(scrollNode.scrollHeight - this.props.offset)
8788

88-
if (
89-
scrollNode != null &&
90-
scrollNode.scrollHeight - this.props.offset <= scrollNode.scrollTop + window.innerHeight
91-
) {
89+
if (scrollPosition <= scrollContainerBottomPosition) {
9290
this.props.onBottom()
9391
}
9492
}

0 commit comments

Comments
 (0)