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;
|