ColacX
ColacX

Reputation: 4042

Android webview touchmove bug

I am developing an Android WebView App and for some reason the "touchmove" event refuses to fire. It works fine on a desktop-browser. How can I fix it? Does not work on the android emulator either.

document.body.addEventListener("touchstart", function (e) {
    console.log("touchstart", e);
    e.preventDefault();
    e.stopPropagation();
});
document.body.addEventListener("touchmove", function (e) {
    console.log("touchmove", e); // <--- refuses to fire
    e.preventDefault();
    e.stopPropagation();
});
document.body.addEventListener("touchend", function (e) {
    console.log("touchend", e);
    e.preventDefault();
    e.stopPropagation();
});

Upvotes: 1

Views: 609

Answers (1)

Rahul Khurana
Rahul Khurana

Reputation: 8844

You may need to do a workaround it like this:

var onTouchEnd = function(){
  console.log("touch end");
}
document.addEventListener("touchstart", onTouchEnd);
document.addEventListener("touchmove", onTouchEnd);
document.addEventListener("touchend", onTouchEnd);

or

try to console it like this

var onTouchEnd = function(){
  console.log("touch end");
  var touch = event.changeTouches[0];
  console.log("touch", touch);
}
document.addEventListener("touchstart", onTouchEnd);
document.addEventListener("touchmove", onTouchEnd);
document.addEventListener("touchend", onTouchEnd);

Upvotes: 3

Related Questions