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!
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!
Share Improve this question asked Oct 7, 2011 at 0:13 Tom MurrayTom Murray 811 silver badge3 bronze badges1 Answer
Reset to default 6Please use:
event.touches[0].pageY
instead of:
event.pageY
it will work.