Created
February 25, 2014 15:51
-
-
Save qgustavor/9211594 to your computer and use it in GitHub Desktop.
Scroll infinito
This file contains 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
window.onscroll = function onScroll() { | |
var htmlEl = document.documentElement, | |
alturaJanela = htmlEl.clientHeight, | |
alturaTotal = Math.max(document.body.scrollHeight, htmlEl.scrollHeight, document.body.offsetHeight, htmlEl.offsetHeight, htmlEl.clientHeight); | |
// Aplique a lógica que quiser, usei: se o scroll | |
if(alturaTotal - 2 * alturaJanela < window.scrollY) { | |
carregarDados(); | |
} | |
window.onscroll = null; | |
setTimeout(function () { | |
window.onscroll = onScroll; | |
}, 250) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment