我写了一些code用JavaScript就像这样:
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"; };在IOS /萨法航空和Android 2.x.x这code做工精细。在Android 4.x版(我试过4.0.4&安培; 4.1),touchmove后touchend不点火。如果我点击屏幕,不要动我的手指,touchend将被解雇。
This code work fine on IOS/safair 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.
如何解决这一问题?
这是镀铬的一个bug,细节在这里:$c$c.google/p/chromium/issues/detail?id=152913
This is a bug of chrome, the detail is here: code.google/p/chromium/issues/detail?id=152913
推荐答案我相信如果你叫即preventDefault()在touchstart或touchmove它将停止该事件被吸收了它击中你的ontouchend处理程序之前。我没有一个设备现在在这里想试试,但:)
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 :)
更多推荐
在Android 4.x的touchmove后Touchend不触发?
发布评论