Skip to content

Instantly share code, notes, and snippets.

@dfreedm
Created November 25, 2013 23:38
Show Gist options
  • Select an option

  • Save dfreedm/7650864 to your computer and use it in GitHub Desktop.

Select an option

Save dfreedm/7650864 to your computer and use it in GitHub Desktop.
PointerEvents offscreen tracking
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Drag off screen</title>
<script src="polymer/components/PointerEvents/pointerevents.js"></script>
<style>
#foo {
width: 100px;
height: 100px;
background: orange;
}
</style>
</head>
<body>
<div id="foo" touch-action="none"></div>
<pre id="output"></pre>
<script>
var foo = document.querySelector('#foo');
foo.addEventListener('pointerdown', function(e) {
foo.setPointerCapture(e.pointerId);
});
foo.addEventListener('pointermove', function(e) {
if (e.isPrimary) {
output.textContent += e.x + ', ' + e.y + '\n';
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment