Skip to content

Commit 206d848

Browse files
committed
Check if we're still at the bottom after loading content
1 parent a2604a7 commit 206d848

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

assets/js/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ window.Hooks.InfiniteScroll = {
4444

4545
updated() {
4646
this.pending = false
47+
48+
// Check if we're still at the bottom after loading content
49+
// Use requestAnimationFrame to ensure DOM has fully updated
50+
requestAnimationFrame(() => {
51+
const target = this.el
52+
const rect = target.getBoundingClientRect()
53+
const isIntersecting = rect.top <= (window.innerHeight || document.documentElement.clientHeight)
54+
55+
if (isIntersecting && !this.pending) {
56+
this.pending = true
57+
this.pushEvent("load-more", {})
58+
}
59+
})
4760
}
4861
}
4962

0 commit comments

Comments
 (0)