jq判断触屏左右滑动方向


$('body').on('touchstart', '.slide-box>ul>li', function(e) {
var touch = e.originalEvent,
startX = touch.changedTouches[0].pageX;

$(this).on('touchmove', function(e) {
e.preventDefault();
touch = e.originalEvent.touches[0] ||
e.originalEvent.changedTouches[0];
if (touch.pageX - startX > 20) {//向左
$('#preBtn').click();
$(this).off('touchmove');

} else if (touch.pageX - startX < -20) {//向右

$('#nextBtn').click();
            $(this).off('touchmove');

};

});

// Return false to prevent image
// highlighting on Android
//return false;

}).on('touchend', function() {
$(this).off('touchmove');
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM