我有以下代码尝试左右扫描:
$('#my_view').bind('pageinit', function() {
$( '#my_view' ).on( "swipeleft swiperight", "#myItem", function( event ) {
var listitem = $( this ),
dir = event.type === "swipeleft" ? "left" : "right";
console.log("Detected swipe!!!! " + dir);
});
});
然而,这仅检测到正确的滑动并且从不检测到左滑动,有人可以解释原因吗?
答案 0 :(得分:3)
我创造了一个小提琴,似乎工作正常
<强> DEMO 强>
也许对于pageinit,使用$(document).on:
$(document).on("pageinit", "#my_view", function(){
$('#my_view').on( "swipeleft swiperight", "#myItem li", function( event ){
alert(event.type);
});
});