I am having a really odd issue. I have a Phonegap 2.0 app that is basically completed. It is working on iPhone and iPad and I ported it over to Android in a day, testing it on my Galaxy S. Everything worked perfectly. Then I tried to run it on my brand new S3 and none of the touch events worked. Clicks work, but not touch.
If I run this code:
document.addEventListener('touchstart', function (e) { console.log('touch start')}, false);
document.addEventListener('click', function (e) { console.log('doc click'); }, false);
... only the click events logs. If I comment out the click I get nothing but the system clicks.
10-12 10:08:16.213: V/webview(2805): NO_FAST_DRAW = false
10-12 10:08:16.283: V/webview(2805): singleCursorHandlerTouchEvent -getEditableSupport FASLE
The really weird thing is that the same touchstart works both on the S3 browser AND the PhoneGap ChildBrowser plugin. Just not in the webview portion of the app, and only on the S3.
[UPDATED]
And it gets weirder. If I bind the event in the inline JavaScript code, such as this
// Javascript stuff
document.addEventListener('touchstart', function (e) { alert('touch start')}, false);
// more JavaScript stuff
it actually works. However, if I set it after a timeout it doesn't
setTimeout(function() {
document.addEventListener('touchstart', function (e) { alert('touch start')}, false);
}, 2000);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…