JSFiddle - React, Tailwind, and code Playground

by darcyclarke

HTML

<div class="test"></div>

CSS

.test {
    background: red;
    width: 100px;
    height: 100px;
    display: block;
}

JavaScript

var el = document.getElementsByClassName('test')[0];
console.log(el);
if (window.DeviceOrientationEvent) {
  window.addEventListener('deviceorientation', function(e) {
    a = Math.floor(e.alpha);
	b = Math.floor(e.beta);
	g = Math.floor(e.gamma);
	el.style.transform = 'rotateZ('+a+'deg) rotateX('+b+'deg) rotateY('+g+'deg)';
    }, true);
}