• 某些机型下滑数据不刷新问题处理


     1 $(window).scroll(function() {
     2                   var scrollTop = $(this).scrollTop();
     3                   var scrollHeight = $(document).height();
     4                   var windowHeight = $(this).height();
     5                   if(scrollTop == 0){
     6                       console.log('触顶');
     7                      getList();
     8                  }
     9                               
    10                  if(scrollTop + windowHeight == scrollHeight  ){
    11                       console.log('下拉到底了');
    12                       getList(curIdx, param, "1");
    13                  }                                
    14         })


      某些机型下滑到底时 scrollTop + windowHeight 不等于 scrollHeight 导致不能刷新数据, 所以代码修改为

     1 $(window).scroll(function() {
     2                   var scrollTop = $(this).scrollTop();
     3                   var scrollHeight = $(document).height();
     4                   var windowHeight = $(this).height();
     5                   if(scrollTop == 0){
     6                       console.log('触顶');
     7                      getList();
     8                  }
     9                               
    10                  if((scrollTop + windowHeight)/scrollHeight > 0.95  ){
    11                       console.log('下拉到底了');
    12                       getList(curIdx, param, "1");
    13                  }                                
    14         })

      代码 (scrollTop + windowHeight)/scrollHeight > 0.95 中的0.95是实验性的取值, 可以按照实际情况调整

  • 相关阅读:
    BZOJ 3330 分数
    FR #11题解
    BZOJ 1857 传送带
    BZOJ 4757 Building a Tall Barn
    FR #10题解
    BZOJ 4393 Fruit Feast
    BZOJ 3126 Photo
    BZOJ 1312 Hard Life
    BZOJ 2039 employ人员雇佣
    Count SIN Numbers
  • 原文地址:https://www.cnblogs.com/wawadao/p/14602163.html
Copyright © 2020-2023  润新知