js移动端的下拉刷新,上拉加载更多。

function refresh(refresh, loadmore) {
    $(window).scroll(function() {
        console.log('正在滑动f');

        //滚动条距离顶部的高度
        var scrollTop = $(this).scrollTop(); 
        //当前页面的总高度
        var scrollHeight = $(document).height(); 
        //当前可视的页面高度
        var clientHeight = $(this).height(); 
        // console.log("top:" + scrollTop + ",doc:" + scrollHeight + ", client:" + clientHeight);

        //距离顶部+当前高度 >=文档总高度 即代表滑动到底部 count++; 
        //每次滑动count加1
        if (scrollTop + clientHeight >= scrollHeight){ 
            //调用筛选方法,count为当前分页数
            // filterData(serviceTypeId, industryId, cityId, count); 

            console.log('下拉');
            if (loadmore) {
                loadmore();
            }
        } else if (scrollTop <= 0) {
            //滚动条距离顶部的高度小于等于0 TODO
            //alert("下拉刷新,要在这调用啥方法?");

            console.log('上拉');
            if (refresh) {
                refresh();
            }
        }
    });
}
var fn1, fn2;
refresh(fn1, fn2);

 

 

 

 

原文:https://www.cnblogs.com/handsomeBoys/p/6557839.html

转载于:https://www.cnblogs.com/luowBlog/p/8168737.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值