I'm writing an HTML5 game which updates the canvas on touchstart. On my Galaxy Note 10.1 running Android 4.1.1, the screen takes a little while to update after the touchstart event. I investigated and concluded that the screen (just any change in the screen) just takes a while to update after touchstart. Here's a demonstration:
<!DOCTYPE html>
<html>
<head>
<script>
document.addEventListener(
'touchstart',
function(event) {
console.log('touchstart');
document.getElementById('asdf').value = 'asdf';
}
);
</script>
</head>
<body>
<input id="asdf" value="qwer" type="text" />
</body>
</html>
Here are some of the scenarios:
- tap the screen, do not move your finger, do not release your finger
- you will need to wait around half a second to see the text box updated
- tap the screen, move your finger, do not release your finger
- the screen will be updated the moment you move your finger
- tap the screen and release
- the screen will be updated the moment you release your finger
In all cases, the touchstart event is fired immediately, it's just the screen update gets delayed. It seems to be related to the 300ms delay that triggers the click event, but the problem is different, it is the screen update that gets delayed. I think I've tried every obvious things, like event.preventDefault
or return false, setting capture to true or false. I also searched but cannot find any similar problem reported.
And it is working fine on my iPad and my Nexus One phone running Android 2.3, the screen gets updated immediately after touchstart.
Any ideas?