Android / phonegap - Медленное время отклика при нажатии

Я близок к разработке решения благодаря 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">

Спасибо,

7
задан Raj Labana 16 February 2012 в 16:16
поделиться