在Android 4.x的touchmove后Touchend不触发?

编程入门 行业动态 更新时间:2024-10-26 22:18:57
本文介绍了在Android 4.x的touchmove后Touchend不触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写了一些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不触发?

本文发布于:2023-11-17 17:08:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1610409.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Android   Touchend   touchmove

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!