Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// PROBLEMA: hacer un infinite scroll y obtener mas datos e agregarlos a la lista
// Initial
$(window).on('scroll', scrollHandler);
function scrollHandler () {
}
// html
// <ul id="posts"></ul>
$(window).on('scroll', scrollHandler);
function scrollHandler () {
var scrollHeight = window.scrollHeight;
var scrollTop = window.scrollTop;
var height = window.offsetHeight;
if (scrollTop === (scrolHeight - height)) {
getMoreData();
}
}
function getMoreData() {
return request(req).then(res => {
var list = res.map(item => `<li>${item}</li>`).join('');
var posts = document.getElementById('posts');
posts.innerHTML += list;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment