infinit scroll ul li
Display content + 1 element if the scroll is 100% bottom every seconde and stop if all the elment of the list are display !
window.onload = function(){
var liens = document.getElementById("box").getElementsByTagName("li");
for(var i=3;i<liens.length;i++) {
liens[i].style.display = "none";
liens[i].className = 'contactsSheetsHide';
}
var list = document.getElementById("box").getElementsByTagName("li");
var fulllist = list.length; //full child
var $win = $(window);
var number = 3;
var timer = window.setInterval(function(){
if ($win.scrollTop() == 0){
}
else if ($win.height() + $win.scrollTop() == $(document).height()) {
var reint = "0";
var liens = document.getElementById("box").getElementsByTagName("li");
for(var i=reint;i<liens.length;i++) {
liens[i].style.display = "block";
}
number++;
var liens = document.getElementById("box").getElementsByTagName("li");
for(var i=number;i<liens.length;i++) {
liens[i].style.display = "none";
}
if(fulllist <= number){window.clearInterval(timer);alert('fin');}
}
},1000);
}Written by Valentin Beuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#