要实现的效果:
右滑动切换到评价页面
左滑动切换简介页面
// 切换
$(document).swipeLeft(function(){
$('.tab-title li').removeClass('on').eq(1).addClass('on');
$('.tab-body .tab-con').removeClass('on').eq(1).addClass('on');
})
$(document).swipeRight(function(){
$('.tab-title li').removeClass('on').eq(0).addClass('on');
$('.tab-body .tab-con').removeClass('on').eq(0).addClass('on');
})
使用了swipeLeft()和swipeRight()的两个方法,但是在实际操作中发现上下滑动的时候会偶尔触发左右滑动事件,请问要如何修改呢?
刚搜索找到的方法,通过判断滑动距离来执行事件,代码如下: