Swipe event triggers tap event for ipod touch

雨燕双飞 提交于 2019-12-23 10:14:25

问题


I am using jquery mobile beta and jquery 1.6. On ipod touch, a swipe event is also trigerring the tap event. This issue is not hapenning on android devices. I am trying to google out the solution, but looks like there are not many with the same problem. Is there something very basic that I am missing??

$("div.totapandswipe").bind('tap',function(event, ui){
    alert('event');
});

$("div.totapandswipe").bind('swipe',function(event, ui){
            alert('event');
});

Thank you for the help!


回答1:


I have found that I needed to unbind('click') as the first option in my bind('swipeleft swiperight') function. Since my swipe goes to a new page, that page re-binds the 'click' event for the page that it just left. My utility is a flashcard that tap brings a new card and swiping flips it over. Good luck.

$('#flashVerse').bind('swipeleft swiperight', function(event) {
    console.log(event.type);
    $('#flashVerse').unbind('click');
    if(event.type == 'swipeleft') {
        $.mobile.changePage('flashReference','flip');
    } else {
        $.mobile.changePage('flashReference','flip',true,false);
        console.log('SWIPERIGHT');
    }
});

$('#flashReference').live('pageshow',function(event,ui){
    if((tipsOn() || ls.getItem('tipFlash') == '1') && ui.prevPage.attr('id')!='flashVerse') {
        ls.setItem('tipFlash','0');
        var msg = 'Swipe to flip the card.\n Tap for a new card.\nuse Options to turn Tips back on.';
        if(phoneGap) navigator.notification.alert(msg,dummy,'Flash Cards','OK');
        else alert(msg);
    }
    $('#lnkFlashVerse').addClass('ui-btn-active').addClass('ui-state-persist');
    $('#lnkFlashReference').removeClass('ui-btn-active').removeClass('ui-state-persist');
    $('#flashReference').bind('click', function(event) {
        console.log(event.type);
        newFlashCard();
        //$('#flashReference div[data-role="content"]').append('clicked ');
    });
});



回答2:


This seemed to help me:

$("selector").swiperight(function (e) {
  if (e.type === "swiperight") {
    myHandler(e);
  }
});

It's lame that this would be an issue. Jqm bug on this yet?



来源:https://stackoverflow.com/questions/6550488/swipe-event-triggers-tap-event-for-ipod-touch

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