JSFiddle - React, Tailwind, and code Playground
HTML
<!--
This is a test of the Chrome/Android bug reported at:
https://code.google.com/p/chromium/issues/detail?id=260732
Chrome 28.0.1500.64
Android 4.2.2
Galaxy Tab 3 10.1
Tap on the green square and move your finger around.
With a sufficiently high delay setting, touchcancel
will fire.
-->
<div id="target"></div>
<p id="status">[]</p>
CSS
#target {
background-color: green;
height: 300px;
}
#status {
text-align: center;
}
JavaScript
// 200 reliably causes touchcancel to fire.
// 150 reliably prevents touchcansel from firing.
var delay = 200;
var haltEvent = function (event) {
event.preventDefault();
event.stopPropagation();
};
var pause = function() {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + delay);
};
var target = document.querySelector('#target');
var status = document.querySelector('#status');
target.addEventListener('touchstart', function (event) {
haltEvent(event);
status.innerHTML = '[touchstart]';
}, true);
target.addEventListener('touchmove', function (event) {
pause();
haltEvent(event);
status.innerHTML = '[touchmove]';
}, true);
target.addEventListener('touchend', function (event) {
status.innerHTML = '[touchend]';
}, true);
target.addEventListener('touchcancel', function (event) {
status.innerHTML = '[touchcancel]';
}, true);