多次触摸:仅在发生触摸移动时触发touchend事件 [英] multiple touches: touchend event fired only when a touchmove occurs

查看:250
本文介绍了多次触摸:仅在发生触摸移动时触发touchend事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从ios设备(也许以后是android)访问javascript应用程序时,我想向我的javascript应用程序添加一些多点触控功能.

I would like to add some multitouch features to my javascript application when it is accessed from an ios device (and maybe android later).

我想提供类似 shiftkey 的功能:用户可以用一根手指按住屏幕上的一个按钮,并且在按下该按钮时,其余用户可以点击操作屏幕与经典水龙头略有不同.

I want to provide a shiftkey-like functionality: the user may hold a button on the screen with one finger, and while this button is pressed, the behavior for a tap action on the rest of the screen is slightly different from the classic tap.

我遇到的问题是,除非为按住的第一根手指触发 touchmove ,否则我不会收到任何有关敲击手指的 touchend 事件. > shiftkey 按钮.

The problem i'm running into is that i do not receive any touchend event for the tapping finger unless a touchmove is fired for the first finger holding the shiftkey button.

因为屏幕非常敏感,所以很容易触发 touchmove 事件,并且在大多数情况下一切正常.

Because the screen is very sensitive, touchmove events gets easily fired and in most cases everything works fine.

但是,当用户的手指有点太静止时,只有在用户稍微移动手指后才能检测到敲击. 这会在点击和屏幕上发生的动作之间引起可变的延迟"(如果用户非常镇定,延迟可能会有所不同,可能会持续几秒钟). 我的猜测是,这种延迟将导致用户再次轻按,从而第二次触发该动作,这是我想要的!

But when the user's finger is a bit too still, the tapping is not detected until the user moves his finger a bit. This induces a variable 'delay' between the tapping and the action that occurs on the screen (the delay may vary and last a few seconds if the user is very calm). My guess is that this delay will cause the user to tap again and thus fire the action a second time, which is something that i don't want !

您可以在这里使用ipad/iphone对其进行测试: http://jsfiddle.net/jdeXH/8 /

You can test it here with your ipad/iphone : http://jsfiddle.net/jdeXH/8/

通过在红色div上轻按手指,使身体保持绿色几秒钟来尝试使身体保持绿色.

Try to make the body remain green for a few seconds by holding your finger very still on the cyan div while tapping on the red div.

这是预期的行为吗? 有解决该问题的已知方法吗? 我希望从屏幕上移开手指后立即触发touchend事件.

Is this behavior to be expected ? Is there some known workaround for the problem ? I would have expected the touchend event to be fired right away when the finger is removed from the screen.

我在iOS 5.1.1(ipad1和iphone4s)上对此进行了测试

发现了一个类似的问题不是多点触控事件在Safari Mobile上应有的触发状态

edit: found a similar question Multitouch touchEvents not triggered as they should on Safari Mobile

推荐答案

好吧,该错误似乎困扰了比我更多的人,他们直接向Apple提交了一个错误,几年后,现在已在iOS6中修复:)

Well, it appears that the bug bothered some people more than me, they filed a bug directly to apple, and after a few years it is now fixed in iOS6 :)

这篇关于多次触摸:仅在发生触摸移动时触发touchend事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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