模拟懒加载

/**
 * 当滚动条即将滚动到底部时懒加载列表
 * */
function lazyLoadList(){
    var timeout;
    $('.oc_simple_content_right').on('scroll',function(){
        /*清除定时器,防止滚动滚动条是多次触发请求(IE)*/
        clearTimeout(timeout);
            /*当请求完成是把isLoding设置成false(请求完成之后才能继续请求)*/
            if(!isLoadding){
                 var $this = $(this),
                      scorllBottom = $this.find('.oc_simple_desk_ul').height()0 - $(this).height(),
                      scrollTop = $this.scrollTop();
                 /*当滚动条滚动到底部时才触发请求,请求列表数据*/
                 if(scrollTop >= scorllBottom){
                     timeout = setTimeout(function(){
                        ajax();
                     },200);
                 }
            }
    });
}

 

posted @ 2014-12-28 20:33  过眼云烟之活在当下  阅读(163)  评论(0)    收藏  举报