Skip to content

Instantly share code, notes, and snippets.

@mikebucks
Created November 19, 2013 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebucks/7538408 to your computer and use it in GitHub Desktop.
Save mikebucks/7538408 to your computer and use it in GitHub Desktop.
Accelerometer gamma detection.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>device detection</title>
</head>
<body>
<div id="log_motion"></div>
<div id="log_orientation"></div>
<script>
(function() {
window.ondeviceorientation = function(e) {
updateDOM(e.gamma, 'orientation');
};
window.ondevicemotion = function(e) {
updateDOM(e.gamma, 'motion');
};
function updateDOM(data, type) {
document.getElementById('log_' + type + '').innerHTML = type + ' ' + data;
}
}());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment