function refresh(refresh,loadmore) {
  $(window).scroll(function(){
    console.log('正在滑动');
    var scrollTop = $(this).scrollTop();    //滚动条距离顶部的高度
    var scrollHeight = $(document).height();   //当前可视文档的总高度
    var clientHeight = $(document.body).height();    //文档总高度
  
    
    if(scrollTop + clientHeight >= scrollHeight){   //距离顶部+当前高度 >=文档总高度 即代表滑动到底部
     
      console.log('下拉');
      //在这调用方法
      if(loadmore){
        loadmore();
      }
    }else if(scrollTop<=0){
      //滚动条距离顶部的高度小于等于0
      
      
      console.log('上拉');
       //在这调用方法
      if(refresh){
        refresh();
      }

    }

  });

}


//调用
refresh();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-01-19
  • 2021-11-19
  • 2022-01-11
  • 2022-12-23
相关资源
相似解决方案