jquery touch 移動端上下滑動加載
阿新 • • 發佈:2017-06-24
hang blog change ldl scrollto jquery scroll edt end
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); } } elseif (diff <= -touchDiff) { // direction up if ($(window).scrollTop() == 0) { // scroll top buildList(1); } } } });
jquery touch 移動端上下滑動加載