使用TouchSwipe在元素上多次滑动事件 [英] Multiple swipe events on an element with TouchSwipe
本文介绍了使用TouchSwipe在元素上多次滑动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 TouchSwipe 绑定DOM元素上的多个滑动事件. 演示没有包含多个事件的示例.我尝试了以下方法:
I would like to bind multiple swipe events on a DOM element with TouchSwipe. The demo does not have an example with multiple events. I tried the follwing:
$("#test").swipe( {
//Generic swipe handler for all directions
swipeRight:function(event, direction, distance, duration, fingerCount) {
alert("you swiped " + direction);
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:10
});
$("#test").swipe( {
//Generic swipe handler for all directions
swipeLeft:function(event, direction, distance, duration, fingerCount) {
alert("you swiped " + direction);
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:10
});
但不幸的是,只有第一个事件触发(请参见小提琴).
But unfortunately, only the first event fires (see fiddle).
TouchSwipe库有可能吗?如果是,怎么办?如果没有,您是否可以推荐一个能够在一个元素上绑定多个事件的库?
Is this possible with the TouchSwipe library? If yes, how? If no, can you recommend a library which is capable of binding multiple events on an element?
推荐答案
这是如何添加多个滑动事件的示例.
This is an example of how I add multiple swipe events .
$("#demo1").swipe( {
//Single swipe handler for left swipes
swipeRight:function() {
demo1.goToPrevSlide();
return false;
}
,
swipeLeft:function() {
demo1.goToNextSlide();
return false;
},excludedElements:"",
allowPageScroll:"vertical",
preventDefaultEvents:false
})
这篇关于使用TouchSwipe在元素上多次滑动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文