JSFiddle - React, Tailwind, and code Playground
by Piara Singh
JavaScript
function handleMotionEvent(event) {
var x = event.accelerationIncludingGravity.x;
var y = event.accelerationIncludingGravity.y;
var z = event.accelerationIncludingGravity.z;
// Do something awesome.
console.log(x);
}
window.addEventListener("devicemotion", handleMotionEvent, true);