Created
March 31, 2011 11:25
-
-
Save ahmednuaman/896200 to your computer and use it in GitHub Desktop.
This converts touch events list to a single coors x,y object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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