Last active
July 21, 2017 23:41
-
-
Save raullucero/0968d5f8f39bd453b2861efce4a65e78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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