@H_502_0@本文为大家分享了jquery.touchSwipe左右滑动和垂直滚动条冲突问题的解决方法,具体内容如下
@H_502_0@正好需要Html5做一个左右可以切换的功能,但是要保留上下滚动条功能。我在移动端使用的jquery.touchSwipe插件,上网找了好久没有看到对应的解决方式,只能自己修改了,最后是能用了。
@H_502_0@先上个图:
<p style="text-align: center">
<p style="text-align: left">解决方式是,我把左右滚动的事件添加到了Body上面,而上下活动的使用了DIV的垂直滚动。上代码:
<div class="jb51code">
<pre class="brush:js;">
$("#body").swipe( { fingers:'all',swipeLeft:swipe1,swipeRight:swipe2} );
function swipe1(event,direction,distance,duration,fingerCount) {
tab_shipu(-1); //向左滑动你要执行的动作
}
function swipe2(event,fingerCount) {
tab_shipu(1); //向右滑动你要执行的动作
}