infinit scroll ul li

Posted on

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);

}

Leave a Reply

Your email address will not be published.