iphone's safari touchmove event not working

34,836

Solution 1

Try using e.originalEvent.touches:

$('#movieShow').bind('touchmove',function(e){
    e.preventDefault();

    var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
    console.log(touch.pageX);
});

I ran into a similar problem when I was playing around with touch events and jquery: http://xavi.co/articles/trouble-with-touch-events-jquery

Solution 2

It might be as simple as a mis-named DIV id ('#info') but can't tell without seeing everything.

Try this, and see if you still get no output:

$('#movieShow').bind('touchmove',function(e){                   
    e.preventDefault();                 
    console.log(e.touches[0].pageX);
});

(You'll need to turn on Debug Console in MobileSafari)

UPDATE

So, from your comment you get an error: 'e.touches' is not an object

In that case try this (not jQuery specific):

document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
document.getElementById('movieShow').addEventListener('touchmove',  function(e){
  console.log(e.touches[0].pageX);
},  false);
Share:
34,836
coure2011
Author by

coure2011

Updated on October 13, 2020

Comments

  • coure2011
    coure2011 over 3 years

    i am using jquery and touchmove event but the code is not showing anything in #info

    $('#movieShow').bind('touchmove',function(e){                   
        e.preventDefault();                 
        $('#info').text(e.touches[0].pageX);
    });         
    
  • donohoe
    donohoe over 13 years
    I've updated my code. Try that. If it works then you can go from there.
  • Xavi
    Xavi over 13 years
    hmm, just tried on my ipad... everything seemed to work as expected. Are you seeing any errors? Also have you tried checking e.originalEvent.changedTouches[0]?
  • Neeraj Rathod
    Neeraj Rathod over 6 years
    I am trying to detect scroll from touchmove event, but in safari pageY, screenY coordinates of touchmove event are not properly working. - When I touch and move to down then coordinates (pageY,screenY) value fluctuates, means it's going like 468,473,470,480,477,486,481, It should be consistent, increasing or decreasing so I can detect scroll top or scroll down. please help me out.
  • Mike
    Mike almost 5 years
    your link is broken