Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Created March 31, 2011 11:25
Show Gist options
  • Save ahmednuaman/896200 to your computer and use it in GitHub Desktop.
Save ahmednuaman/896200 to your computer and use it in GitHub Desktop.
This converts touch events list to a single coors x,y object
function scrollGetCoords(e)
{
var coors;
if ( e.hasOwnProperty( 'originalEvent' ) )
{
e = e.originalEvent;
}
if ( e.touches && e.touches.length )
{
coors = e.touches[ 0 ];
}
else
{
coors = { clientX: e.clientX, clientY: e.clientY };
}
return coors;
}
/* use like this $( 'div' ).bind( 'touchstart', function(e)
{
var coords = scrollGetCoords( e );
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment