TouchMove & MouseMove test
HTML
<meta name="viewport" content="width=device-width">
CSS
#floater {
width: 100px;
height: 100px;
position: absolute;
top: -200px;
left: -200px;
border: 3px solid #999;
border-radius: 500px;
}
#console {
margin: 0px;
padding: 6px;
width: 100%;
height: 16px;
line-height: 16px;
position: fixed;
top: 0px;
left: 0px;
right: 0px;
background: #333;
color: #fff;
}
JavaScript
$('body').append( '<div id="console">Coordinates: <span></span></div> <div id="floater">' );
$(document).on("vmousemove touchmove touchstart", function( e ) {
e.preventDefault();
var touchstart = e.type === 'touchstart' || e.type === 'touchmove',
e = touchstart ? e.originalEvent : e,
pageX = touchstart ? e.targetTouches[0].pageX : e.pageX,
pageY = touchstart ? e.targetTouches[0].pageY : e.pageY;
$('#console span').html( 'x' + pageX + ' y' + pageY );
$('#floater').css({
top: pageY - 50,
left: pageX - 50
});
});