I use this code on scrolling to fetch data works perfect on windows, for iphone i hade to add the debounceTimer and know that i have it on production android devices just fetching a few times or not fetching at all.
window.addEventListener('scroll', () => {
if (debounceTimer) {
clearTimeout(debounceTimer)
}
debounceTimer = setTimeout(() => {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
if (offset < rows) {
fetchData()
}
}
}, 100)
})
Tried ai solutions but cant find anything
New contributor
FelipeHF is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.