如何解决jquery.touchSwipe左右滑动和垂直滚动条冲突

2025-05-02 04:37:03
推荐回答(1个)
回答1:

解决方式是,我把左右滚动的事件添加到了Body上面,而上下活动的使用了DIV的垂直滚动。上代码:$("#body").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe2} );
function swipe1(event, direction, distance, duration, fingerCount) {
tab_shipu(-1); //向左滑动你要执行的动作
}

function swipe2(event, direction, distance, duration, fingerCount) {
tab_shipu(1); //向右滑动你要执行的动作
}

然后上下滚动条我设置div的滚动;




设置body和div的默认高度代码:
$("body").css("height",document.body.scrollHeight);
$(".cook").css("height",document.body.scrollHeight-$('#cook').position().top);