Created
November 25, 2013 23:38
-
-
Save dfreedm/7650864 to your computer and use it in GitHub Desktop.
PointerEvents offscreen tracking
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 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