0

Using PhoneGap build with PG 2.2.0 and testing on my Galaxy S2 with Android 4.0.4

I already found touch events not working in android phonegap webview (or even built-in browser) and Phonegap on Galaxy S3 ignores touch events and WebView in ICS touch events not being fired properly but I'm not sure if they describe the exact same problem.

I'm using Tap.js and iScroll. Neither of them works (I can't scroll or use my app menu) until I rotate the device at least once. I can rotate it back to where I started and it still works. It seems like the first rotation/orientationchange triggers some kind of refresh but I have no clue how I'm supposed to handle this.

Maybe someone with the same symptoms was able to resolve this. Thanks.

Edit: I disabled all JS and put this code inside deviceready

document.getElementById('app').addEventListener('touchstart', function() {
    alert('touchstart #app');
}, false);

And I only get the alert after at least one orientationchange.

Community
  • 1
  • 1
Prinzhorn
  • 22,120
  • 7
  • 61
  • 65

1 Answers1

0

After I took my app apart and created a test case, I found the following: Adding position:relative; to html or body in combination with overflow:hidden; seems to have caused the issue.

To fully resolve my issue, I took the following steps:

  • Made html and body static again
  • Removed overflow:hidden; from html and body
  • Instead applied both to #app (my wrapper div)
  • Listen to touchstart touchmove touchend on document level and preventDefault

Update 12th Jun 2013, another important find:

  • If you call preventDefault for touchstart, then touchmove will not fire
Prinzhorn
  • 22,120
  • 7
  • 61
  • 65