我试图捕捉的“手势”是一个点击,但只有当一个元素(其他或相同)已经触摸它时才会点击。因此,触摸(1)按下按钮,同时触摸(2)轻触所选选项,触摸(1)释放并按下按钮。移动Safari - “touchend”事件在最后一次触摸移除时不会触发?
我遇到的问题是最后一点。当我释放最后一根手指时,“touchend”事件没有被解雇?所以我无法按下按钮?
..此外,“touchend”事件总是touches.length = 0?
这里有一些代码,所以你可以看到我的意思。我认为这可能是移动Safari中的一个错误?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Multi-touch problem</title>
<style>
#touchpane{
width:900px;
height:500px;
background-color:#333;
}
</style>
</head>
<body>
<div id="touchpane" click="void();"></div>
<script>
var tp = document.getElementById("touchpane");
tp.addEventListener('touchstart', function(e){
e.preventDefault();// to stop copy and paste
console.log("touchstart " + e.touches.length);
}, false)
tp.addEventListener('touchend', function(e){
console.log("touchend " + e.touches.length);
// not called when last finger removed?
}, false)
tp.addEventListener('touchcancel', function(e){
console.log("touchcancel");
}, false)
</script>
</body>
</html>
一定要包含您的操作系统版本。这在3.1.3(第一代iPod touch)中的预期效果:“touchstart 1”,“touchstart 2”,“touchend 1”,“touchend 0”。 – 2010-12-10 21:59:57
当然对不起。 3.2.1在iPad上。这和其他一些似乎已经修复在4.2 – 2011-01-01 19:23:47