Search code examples
javascriptjqueryios4mobile-safari

iOS4 cannot detect left right swipe


I am producing a mobile website (safari mobile not uiwebview), with jQuery and the viewport meta tag.

<meta name="viewport" content="width=500, user-scalable=0, initial-scale=default" id="viewport">

I have swipe detection working via the jQuery touchSwipe plugin http://labs.skinkers.com/touchSwipe/

$(window).swipe({
    swipeLeft  :function(){ console.log('1'); arrows.eq(1).click(); },
    swipeRight :function(){ console.log('0'); arrows.eq(0).click(); },
    allowPageScroll:"vertical"
});

Swipe detects fine on iPad iOS5 and Android but iPhone iOS4 nothing triggers. I did some debugging

document.ontouchstart = function(e){
     console.log(e.touches[0].clientX+' | '+e.touches[0].clientY);
};

tried out all the basics clientX pageX ect. all seems to work fine and return valid data. Anyone have any ideas?


Solution

  • Solved it. This issue was very simple:

    $(window)
    

    does not receive touch events in iOS4 while it does in iOS5 and Android. While

    $(document)
    

    DOES receive touch events on all devices. Go figure.