Skip to content

Commit

Permalink
Fix infinite loading streams in zoomed viewports (#3442)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjun authored Sep 26, 2024
1 parent 26a4905 commit b1d5259
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/js/phoenix_live_view/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ let top = (scrollContainer) => {

let isAtViewportTop = (el, scrollContainer) => {
let rect = el.getBoundingClientRect()
return rect.top >= top(scrollContainer) && rect.left >= 0 && rect.top <= bottom(scrollContainer)
return Math.ceil(rect.top) >= top(scrollContainer) && Math.ceil(rect.left) >= 0 && Math.floor(rect.top) <= bottom(scrollContainer)
}

let isAtViewportBottom = (el, scrollContainer) => {
let rect = el.getBoundingClientRect()
return rect.right >= top(scrollContainer) && rect.left >= 0 && rect.bottom <= bottom(scrollContainer)
return Math.ceil(rect.bottom) >= top(scrollContainer) && Math.ceil(rect.left) >= 0 && Math.floor(rect.bottom) <= bottom(scrollContainer)
}

let isWithinViewport = (el, scrollContainer) => {
let rect = el.getBoundingClientRect()
return rect.top >= top(scrollContainer) && rect.left >= 0 && rect.top <= bottom(scrollContainer)
return Math.ceil(rect.top) >= top(scrollContainer) && Math.ceil(rect.left) >= 0 && Math.floor(rect.top) <= bottom(scrollContainer)
}

Hooks.InfiniteScroll = {
Expand Down

0 comments on commit b1d5259

Please sign in to comment.