在Android 4.x的touchmove后Touchend不触发? [英] Touchend not firing after touchmove on android 4.x?

查看:359
本文介绍了在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,细节在这里:<一href=\"http://$c$c.google.com/p/chromium/issues/detail?id=152913\">http://$c$c.google.com/p/chromium/issues/detail?id=152913

This is a bug of chrome, the detail is here: http://code.google.com/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不触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆