Android/phonegap-点击响应时间慢
Android/ phonegap - Click response time slow
由于ghostCoder暗示了检测触摸事件而不是点击事件的想法,我即将制定出一个解决方案。下面的代码是我目前所拥有的,但是有些地方仍然不太正确。它在我的主页上运行(非常基本的页面),但在实际的游戏页面上它会崩溃:
这是我的代码:JAVASCRIPT:
var b=document.getElementById('STOP'),start=0;
//Check for touchstart
if('ontouchstart' in document.documentElement)
{
document.getElementById("notouchstart").style.display = "none";
}
//Add a listener that fires at the beginning of each interaction
[b].forEach(function(el){el.addEventListener('touchstart',interact);});
//Add the event handlers for each button
b.addEventListener('touchstart',highlight);
//Functions Store the time when the user initiated an action
function interact(e)
{
start = new Date();
}
//Highlight what the user selected and calculate how long it took the action to occur
function highlight(e)
{
e.preventDefault();
e.currentTarget.className="active";
if(start)
{
alert("test")
}
start = null;
}
机身按钮(首先显示启动按钮,然后单击时显示停止按钮,然后再次启动等)
<INPUT TYPE="button" style="background:url(images/Start_Btn.png); background-color:transparent; width:150px; height:186px; border:none; cursor:pointer;" id="START" onClick="startBTN();">
<INPUT TYPE="button" style="background:url(images/Stop_Btn.png); background-color:transparent; width:150px; height:186px; border:none; cursor:pointer;" id="STOP">
谢谢,
我为此使用了touchend
。即使动作是CCD_ 3,CCD_。
听'touchstart'而不是'click':)
点击在触摸屏中有点延迟。http://floatlearning.com/2011/03/developing-better-phonegap-apps/
不要使用按钮。如果将事件添加到div中,速度会更快。
我正在开发一个计算器,我的第一个想法是从phonegap开始。现在,我强烈建议在按钮按下时间紧迫时不要这样做。即使禁用了所有额外的触摸处理程序并将touchstart直接设置为div:这也太慢了。(顺便说一句,触摸端不行,当你把手指从按钮上松开时就会调用它)
在Phonegap应用程序中,单击事件的延迟时间为300ms。你为什么不使用Fastclick库来实现这个目的???我试过了,效果很好!
https://github.com/ftlabs/fastclick
希望对有帮助
相关文章:
- 如何检索AMD的XHR响应代码(+时间戳)'大型Dojo
- PhoneGap 2.0(Cordova)DatePicker插件'模式'-属性以获取日期和时间
- 如何在phonegap应用程序中处理Ajax json响应
- 如何用java计算网站的响应时间
- 最大限度地减少Google AdWords Script的响应时间
- 如何使用javascript记录两次按钮按下之间的响应时间(以秒为单位)
- 如何测量 http.NodeJS 中的 ClientRequest 响应时间
- Web API处于非活动状态5分钟后响应时间过长
- REST API测量服务器端响应时间(性能)
- 使用Heroku进行套接字轮询时响应时间长
- Microsoft Face Api响应时间
- 更改offline.js中允许的服务器响应时间
- 如何在redux框架中使用Action和Reducer记录响应时间
- 如何调用“请等待”只有当ajax的响应时间超过X毫秒时才使用
- PHP HttpRequest创建网页-如何处理长响应时间
- 聊天机器人回答/响应时间代码在js
- 有没有办法限制Node (Express)中的速度和响应时间?
- 当URL具有相同的响应时间时,为什么某些AJAX调用比其他调用需要更长的时间才能完成
- 正在测量服务器响应时间(客户端)
- 有没有办法要求Apache Bench测试提供给URL的所有资源的响应时间