我试图捕捉的“手势”是在元素(其他或相同)已经有触摸时进行轻击。 因此,触摸(1)按下按钮,而触摸(2)则轻击选定的选项,触摸(1)释放并使按钮凹陷。
我遇到的问题在于最后一部分。 当我松开最后一个手指时,“touchend”事件没有被触发? 所以我无法使按钮凹陷?
另外,“touchend”事件总是具有touches.length = 0?
以下是一些代码,以便您了解我的意思。 我认为这可能是移动Safari中的错误?
我遇到的问题在于最后一部分。 当我松开最后一个手指时,“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>