Touchend not firing after touchmove on Android 4.x?

纵然是瞬间 提交于 2019-12-23 08:57:11

问题


I am writing some code with Javascript just like this:

    var el = document.getElementById('some-div');
    el.ontouchstart = function(e){
            el.innerHTML = "touch start";
    };
    el.ontouchend = function(e){
            el.innerHTML = "touch end";
    };
    el.ontouchmove = function(e){
            el.innerHTML = "touch moved";
    };

This code work fine on iOS/Safari and Android 2.x.x . On Android 4.x (I tried 4.0.4 & 4.1) , touchend not firing after touchmove. If I tap the screen, don't move my finger, touchend will be fired.

How to fix this?

This is a bug of Chrome, the detail is here: http://code.google.com/p/chromium/issues/detail?id=152913


回答1:


I believe if you call e.preventDefault() in touchstart or touchmove it will stop the event being soaked up before it hits your ontouchend handler. I dont have a device here to try it on right now though :)



来源:https://stackoverflow.com/questions/16315052/touchend-not-firing-after-touchmove-on-android-4-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!