Javascript 两次点击iOS WebApp之间有300毫秒的延迟
我正在写一个游戏,所以它需要我每300毫秒点击几次以上。我已经有了fastclick.js,它可以工作,但是我不能在300毫秒内点击超过一次 例如,我将点击一次,它会立即做出反应,但如果我在300毫秒之前再次点击,则不会触发事件 快速点击:Javascript 两次点击iOS WebApp之间有300毫秒的延迟,javascript,html,mobile-safari,fastclick.js,fastclick,Javascript,Html,Mobile Safari,Fastclick.js,Fastclick,我正在写一个游戏,所以它需要我每300毫秒点击几次以上。我已经有了fastclick.js,它可以工作,但是我不能在300毫秒内点击超过一次 例如,我将点击一次,它会立即做出反应,但如果我在300毫秒之前再次点击,则不会触发事件 快速点击: //remove 300ms delay on mobile FastClick.attach(document.body); 我的活动: //when the game is clicked window.onclick = function(e
//remove 300ms delay on mobile
FastClick.attach(document.body);
我的活动:
//when the game is clicked
window.onclick = function(e){
if(e.x > window.innerWidth/2){
move('right');
} else {
move('left');
}
}
我发现为此使用fastclick.js是一个问题。js触发onclick事件,但必须等待常规onclick事件被触发才能停止它
$('.punch')[0].ontouchend = function() {
$('.console').append((Date.now() - time) + ' Tap<br>');
tap = true;
}
$('.punch')[0]。ontouchend=function(){
$('.console').append((Date.now()-time)+“点击
”);
tap=真;
}
然后我添加了一个点击事件
$('.punch')[0].onclick = function() {
if (!tap) {
$('.console').append((Date.now() - time) + ' Click<br>');
time = Date.now();
}
}
$('.punch')[0]。onclick=function(){
如果(!点击){
$('.console').append((Date.now()-time)+单击
);
时间=日期。现在();
}
}
JSFiddle:
Fastclick.js是无重复点击的首选,并且仍然允许您使用手势。这不是