Created
April 11, 2014 19:19
-
-
Save omniosi/10493889 to your computer and use it in GitHub Desktop.
pointer events code by @girlie_mac as seen in netm.ag may 2014
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script> | |
var isTouchSupported = 'ontouchstart' in window; | |
var isPointerSupported = navigator.pointerEnabled; | |
var isMSPointerSupported = naviogator.msPointerEnabled; | |
var downEvent = isTouchSupported ? 'touchstart' : (isPointerSupported ? 'pointerdown' : (isMSPointerSupported ? 'MSPointerDown' : 'mousedown')); | |
document.body.addEventListener(downEvent, function(e){ | |
//console.log('pointerdown',e.clientX,e.clientY); | |
var x = isTouchSupported ? e.targetTouches[0].clientX : e.clientX; | |
var y = isTouchSupported ? e.targetTouches[0].clientY : e.clientY; | |
}, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment