25

I am developing a webView based android application and was trying to capture the touch events. however it is not working and i saw this message in the log:

"Miss a drag as we are waiting for WebCore's response for touch down"

Does anyone know how to fix this problem?

Oscar Foley
  • 6,817
  • 8
  • 57
  • 90
Anchal
  • 859
  • 1
  • 10
  • 21

3 Answers3

3

Currently, I`m facing the same issue while implementing an OpenLayers map inside of an Android WebView. Seems to be an open issue since 2009: Issue 4549 A workaround is mentioned there: Use

 e.preventDefault() 

in every ontouch###-function (Javascript).

Another hint was this answer on SO

It worked for me, but I'm going to take a closer look at WebView-MultiTouch-Polyfill in connection with MTfix for Android (Sorry, as a new user I`m not allowed to post more hyperlinks than two, but Google will help you)

Community
  • 1
  • 1
Ronny
  • 166
  • 1
  • 1
  • 9
1

I fixed this issue with adding

    document.addEventListener( 'touchstart', function(e){ onStart(e); }, false );
    function onStart ( touchEvent ) {
      if( navigator.userAgent.match(/Android/i) ) {
        touchEvent.preventDefault();
      }
    }
1amjennifer
  • 39
  • 1
  • 4
  • preventDefault() works on some devices, this worked fine in motorola device 4.1. Same Code didn't work in samsung galaxy and in galaxy note"i got no_fast_draw = false" which is similar to this touch problem. – Anchal Mar 12 '13 at 10:54
0

For me the only way I could get this to function was to attach the event directly so it is fired before the webCore. addEventListenter was too late for me and the event stalled at the webCore and did not bubble up. This is on a Galaxy note with Android 4.0.4

This is how I fixed it in my instance:

var myDiv = document.createElement("div");
myDiv.className = "myClass";
myDiv.id = "myId";
myDiv.setAttribute("data-open","false");
myDiv.ontouchmove = function(e) {
  //e is touch event, this is myDiv                     
  e.preventDefault();
  //e.changedTouches[0].pageX
  //http://www.w3.org/TR/touch-events/#idl-def-TouchEvent
};
Gurnard
  • 1,773
  • 22
  • 43