Jake Vanderwerf
2025-09-30 2cb91676044ecd0abd9c45b4835abb8b0d042312
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class InfiniteScroll {
 
    constructor () {
        this.elements = [];
    }
 
 
    window.initInfiniteScroll = function (container)
    {
        container = (typeof container === 'string') ? document.querySelector(container)??false : container;
        if (!container) return;
        const observer = new IntersectionObserver(entries => {
            entries.forEach(entry => {
                if (entry.isIntersecting && this.hasMore) {
                    this.loadContent();
                }
            })
        });
 
        observer.observe(this.elements.scroll);
    }
 
}
 
window.infiniteScroll = InfiniteScroll;