JSFiddle - React, Tailwind, and code Playground
by Timatnet
HTML
<div id="stdout">1</div>
JavaScript
window.ondeviceorientation = function(event) {
alpha = Math.round(event.alpha);
beta = Math.round(event.beta);
gamma = Math.round(event.gamma);
$("#stdout").text("alpha: "+alpha+"; beta"+beta+"; gamma");
}
window.ondevicemotion = function(event) {
ax = event.accelerationIncludingGravity.x
ay = event.accelerationIncludingGravity.y
az = event.accelerationIncludingGravity.z
rotation = event.rotationRate;
if (rotation != null) {
arAlpha = Math.round(rotation.alpha);
arBeta = Math.round(rotation.beta);
arGamma = Math.round(rotation.gamma);
}
}
$(document).bind("ondeviceorientation", function(alpha, beta, gamma) {
$("#stdout").text("alpha: "+alpha+"; beta"+beta+"; gamma");
});