jQuery scroll,滚动延迟加载

延迟加载

$(window).scroll(function(){
    var scrollHeight = $(document).height(); //文档高度
    var scrollTop = $(this).scrollTop(); //滚动条卷去高度
    var windowHeight = $(this).height(); // 窗口高度
    // console.log(scrollHeight, scrollTop, windowHeight)
    if(scrollHeight - scrollTop - windowHeight < 100 ){
        
        console.log("到底了");
        //ajax渲染页面
    }
});
jQuery(function($){
    var topicBoxTopHeight = jQuery('#topicBox').offset().top;
    var topicBoxTopHeight_show = 1
    $(window).scroll(function(event){
        
        if($(this).scrollTop() > topicBoxTopHeight-$(window).height()-200 && topicBoxTopHeight_show==1){
            topicBoxTopHeight_show=0;
            topicBoxFn();
        }

    });
})