Test touchend when touching multiple elements
by bakhshi
HTML
<div class="first"></div>
<div class="second"></div>
<textarea name="output" id="" cols="30" rows="10"></textarea>
CSS
div{
width:500px;
height:500px;
float:left;
}
.first{
background-color:blue;
}
.second{
background-color:red;
}
JavaScript
$ = document.querySelectorAll.bind(document);
NodeList.prototype.addEventListener = function(){
var args = [].slice.call(arguments, 0);
for(var index = 0; index < this.length; index++)
{
var current = this[index];
current.addEventListener.apply(current, args);
}
};
$('div').addEventListener('touchstart', touchstart);
$('div').addEventListener('touchend', touchend);
function touchstart(){
log('touch start', this.classList);
}
function touchend(){
log('touch end', this.classList);
}
var output = $('textarea')[0];
function log(){
var outstr = "\r\n";
for(var i = 0; i < arguments.length; i++)
outstr += " | " + arguments[i];
output.value = output.value + outstr;
}