zoukankan      html  css  js  c++  java
  • 懒加载

    $(document).height();获取文档高度;
    $(window).height();获取当前窗口的高度;
    $(window).scrollTop();获取滚动条高度;

    滚动条高度+当前窗口高度=文档高度的话(证明已经到底了)存在小数点ceil

    status:{
    allowGetChapter: true,
    neid:''
    },
    scrollLoad:function(e){
    novelJS.read.status.neid=e;
    $(window).scroll(function(){
    let doheight=$(document).height();//文档的高度
    let winheight=$(window).height();//当前页面的高度
    let winscrhei=$(window).scrollTop();//滚动的高度
    if(novelJS.read.status.allowGetChapter){
    if((doheight-winheight)-winscrhei<=35&&winscrhei>0){
    novelJS.read.status.allowGetChapter=false;
    if(typeof(novelJS.read.status.neid)=='number'){
    novelJS.read.loading();
    $('.read-content .read-contentl .readlistnum .readolnum ol li span').map(function(){
    if($(this).attr('data')==novelJS.read.status.neid){
    $(this).parent().css({'color':'#369f9a'}).siblings().css({'color':'#b0afae'});
    setTimeout(function(){
    $(".read-content .read-contentr .read-contentr-HC .loading").remove();
    $.ajax({
    type:'get',
    url:"/chapter/"+novelJS.read.status.neid,
    dataType:'json',
    success:function(res){
    let str=`<div class="read-contentrchapter-na">`+"Charpter"+res.data.chapter_number+`</div>`+
    `<div class="read-contentrchapter-nafon">`+res.data.chapter_title+`</div>`+
    `<div class="read-contentr-transla">`+"Translator:"+res.data.translator+`</div>`+
    `<div class="read-contentr-HC" data="{{ $chapter->id}}">`+ res.data.chapter_content+`</div>`
    $(".read-content .read-contentr").append(str);
    if($('.read-contentr-botbac .botbackcirb').hasClass('botbackcirbor')){
    $('.read-contentrchapter-nafon').addClass('read-contentrchapter-nafonb');
    $('.read-contentr-HC').addClass('read-contentr-HCb');
    }
    novelJS.common.changeURL(res.data.path,res.data.chapter_title+'-NOVELBR');
    novelJS.read.status.neid=res.data.nextChapterId;
    novelJS.read.status.allowGetChapter=true;
    },
    error:function (res) {
    }
    });
    },1000)
    }
    })
    }
    }
    }
     
    });
     
     
     
    }
  • 相关阅读:
    Dockerfile编写语法
    java应用测试报告生成(二):利用ant的build.xml生成测试报告
    java应用测试报告生成(一): sonarqube配合Jenkins生成测试报告及覆盖率
    cannot create windows service for mysql
    线程交互:生产消费模型
    线程同步与锁
    线程的五种状态及改变状态的三种方法
    简单的git入门介绍及常用操作
    CentOS/RHEL 7中的firewall控制
    oracle数据库兼容mysql的差异写法
  • 原文地址:https://www.cnblogs.com/MDGE/p/9728554.html
Copyright © 2011-2022 走看看