2017-07-17 51 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