我正在使用HP Touchscreen台式电脑,开发一个简单的网站。我想阻止用户一次用八个手指“捣碎”屏幕。有没有一种方法可以让jQuery一次只能注册一个触摸事件?这样,当第一根手指击中屏幕时,那是已注册的手指,所有其他触摸都被忽略,直到手指到达touchend
?
答案 0 :(得分:2)
单击后禁用输入类型(按钮,文本框等),在逻辑完成后启用它。
编辑:如果您尝试禁用所有触摸事件,直到触发了touchend,请尝试以下操作:
var isProcessing = false;
$(document).on("touchstart",function(e){
e.preventDefault();
if(!isProcessing){
isProcessing = true;
//Do your stuff here
}
});
$(document).on("touchend",function(e){
e.preventDefault();
isProcessing = false;
});
答案 1 :(得分:0)
好的,这是我使用的解决方案:
var isTouched = false;
var $document = $(document);
$document.on('touchstart', function () {
if (!isTouched) {
isTouched = true;
$document.off('touchstart', function () {
$document.on('touchend', function () {
isTouched = false;
$document.bind('touchstart');
});
});
}
});