2017-07-17 52 views
0

简单的问题。我有一个DIV单击时会改变它的背景颜色。这里的HTML:Cordova 300ms延迟

<html lang="en"> 

<head> 
<meta name="viewport" content="width=device-width, height=device-height, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, initial-scale=1"> 
<script type="text/javascript" src="./js/code.js"></script> 
<link rel="stylesheet" href="./css/styles.css"> 
<title>xxx</title> 
</head> 

<body onload="fInitializeFramework()"> 
<div onclick="fx()" class="fx">touch me!</div> 
</body> 

</html> 

的CSS:

html { 

    height: 100%; 

    -webkit-touch-callout: none;    /* Prevent callout to copy image, etc. when tap to hold */ 

    -webkit-text-size-adjust: none;    /* Prevent webkit from resizing text to fit */ 

    -webkit-tap-highlight-color: rgba(0,0,0,0); /* Prevent tap highlight color/shadow */ 

    -webkit-user-select: none;     /* No element selection */ 

    cursor: default;       /* Default cursor */ 

    touch-action: manipulation;     /* Disable double tap to zoom */ 

} 

.fx:active { 
    background: yellow; 
} 

和JavaScript:

function fInitializeFramework() 
{ 
    document.addEventListener("deviceready",fRun); 
    return; 
} 

function fRun() 
{ 
    return; 
} 

function fx() 
{ 
    return; 
} 

在Chrome在桌面上,一切都很好,迅速引发Click事件。但是,一旦变成与科尔多瓦,平板电脑或手机上的apk,DIV上的触摸和其背景颜色的变化之间存在延迟。

它看起来像臭名昭着的300毫秒延迟。然而,我也跟着被推荐的一切:

  • 视口元与宽度=设备宽度和最小规模= 1.0,最大规模= 1.0
  • 触摸动作:操纵, 等

我试着用fasclick.js,没有结果。这是正常的,因为它在文档中提到的铬32+是没用的。

我怀疑:活性所以我试图改变背景处理用JavaScript,而不是在使用HTML的onclick的onclick()事件。同样的结果,平板电脑上的延迟。

Android是6.0。科尔多瓦7.0.1。

有什么想法?

回答

0

延迟点击触摸屏是有意设计的 - 它有一个点击(触摸并保持在同一个地方)的拖累/滑动区分(触摸和移动,而触摸)和。

我遇到过我的游戏。在我的情况下的补救措施是绑定我的代码touchstart - 这注册更快。

界面设计我的应用程序是这样的:用户永远只能想点击 - 拖动没有实现任何东西。此外,该代码仅用于触摸屏设备,因此我不需要担心处理点击和touchstart