3

I'm creating a web app featuring divs with overflow: scroll styling. Since the Android browser doesn't support this, I need to use touches and drags with my own custom function.

$([element]).
.bind('touchmove', function(event) {
    event.preventDefault();
    // Move elements around as page scrolls, using event.pageY
})
.bind('touchstart', function(event) {
    event.preventDefault();
    // Do stuff to set up scrolling event.
}

This works fine on iOS devices. However, in Android, it does not.

With console.log, I found out that event.pageY is always set to zero (in iOS it tells you where your touch is in relation to the rest of the page). I also get the following cryptic message:

W/webview (21798): Miss a drag as we are waiting for WebCore's response for touch down.

Data on this has been minimal, but it seems to be the case that Android doesn't actually register a touch event until you un-touch. I don't believe it, since normal pages scroll fine. I just don't know hot to get it to recognize the real value of pageY, instead of ignoring the Y-value of the touch.

Thanks for looking!

Tom Murray
  • 81
  • 1
  • 3

1 Answers1

6

Please use:

event.touches[0].pageY

instead of:

event.pageY

it will work.

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Abu Saad Papa
  • 1,908
  • 15
  • 20
  • Sorry for the long delay on responding. A co-worker of mine pointed me to the same solution a week ago, when I jumped back into this task, and it worked - thank you very much! – Tom Murray Nov 23 '11 at 16:54
  • 1
    It would help everyone if you can accept this answer. – Abu Saad Papa Jul 08 '14 at 06:06