JQuery mobile swipe event on Android emulator works only sometimes (using PhoneGap)

时光毁灭记忆、已成空白 提交于 2019-12-13 08:47:50

问题


I added swipeleft and swiperight listeners this way

$("#slides li").swipeleft(function(){
    console.log("!!!! swipe left");
});
$("#slides li").swiperight(function(){      
    console.log("!!!! swipe right");            
});

And it works sometimes, but mostly not. I'm not doing anything different.

I'm using PhoneGap 1.4.0, JQuery mobile 1.0 and JQuery min 1.7.1.

Any ideas...? Thanks in advance.


回答1:


Mobile browsers generally have problems with the id attribute, due to how their caching works. This means that the id attribute isn't always unique even though you only use it once on your page.

You can try to bind your swipe events to a class instead so you avoid those kinds of problems. It may look something like this:

$('.slides').bind('swiperight',function(event, info){
    console.log("!!!! swipe right"); 
});

jQuery Mobile also have some constants in the javascript code that defines how sensitive it should be to different gestures (such as swipe). You may want to change these constants to make your application more sensitive to swipe-events.



来源:https://stackoverflow.com/questions/9153090/jquery-mobile-swipe-event-on-android-emulator-works-only-sometimes-using-phoneg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!