当前位置: 首页 > 工具软件 > jQuery Touch > 使用案例 >

jquery touch 移动端上下滑动加载

宋航
2023-12-01
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);
                    }
                }
            }
        });

 

转载于:https://www.cnblogs.com/jury/p/7073447.html

 类似资料: