码迷,mamicode.com
首页 > 移动开发 > 详细

jquery touch 移动端上下滑动加载

时间:2017-06-24 16:17:42      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:ldl   ==   index   加载   list   var   build   移动   nbsp   

var touchStart, touchEnd, touchDiff = 80;
        $(window).on({
            ‘touchstart‘: function (e) {
                touchStart = e.originalEvent.changedTouches[0].clientY;
            },
            ‘touchend‘: function (e) {
                touchEnd = e.originalEvent.changedTouches[0].clientY;
                var diff = touchStart - touchEnd;
                if (diff >= touchDiff) { // direction down
                    if ($(window).scrollTop() + $(window).height() >= $(document).height()) { // scroll bottom
                        buildList(pageIndex + 1);
                    }
                } else if (diff <= -touchDiff) { // direction up
                    if ($(window).scrollTop() == 0) { // scroll top
                        buildList(1);
                    }
                }
            }
        });

 

jquery touch 移动端上下滑动加载

标签:ldl   ==   index   加载   list   var   build   移动   nbsp   

原文地址:http://www.cnblogs.com/jury/p/7073447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!