JSFiddle - React, Tailwind, and code Playground
JavaScript
var tilt = function (args) {
console.log("tilt!");
console.log(args);
}
if (window.DeviceOrientationEvent) {
console.log("deviceorientation!");
window.addEventListener("deviceorientation", function () {
tilt([event.beta, event.gamma]);
}, true);
}
if (window.DeviceMotionEvent) {
console.log("devicemotion!");
window.addEventListener('devicemotion', function () {
tilt([event.acceleration.x * 2, event.acceleration.y * 2]);
}, true);
}
console.log("MozOrientation!");
window.addEventListener("MozOrientation", function () {
tilt([orientation.x * 50, orientation.y * 50]);
}, true);