我正在用 Javascript 编写一些代码,就像这样:
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";
};
此代码在 iOS/Safari 和 Android 2.x.x 上运行良好。在 Android 4.x 上(我试过 4.0.4 和 4.1),touchend 在 touchmove 之后不触发。如果我点击屏幕,不要移动我的手指,touchend 将被触发。
如何解决这个问题?
这是Chrome的一个bug,详情在这里:http://code.google.com/p/chromium/issues/detail?id=152913
最佳答案
我相信,如果您在 touchstart 或 touchmove 中调用 e.preventDefault(),它会在事件到达您的 ontouchend 处理程序之前停止吸收该事件。不过,我现在这里没有可以试用的设备:)
关于javascript - Touchend 在 Android 4.x 上的 touchmove 后不触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16315052/