1 addEventListener('load', function(e) {2 if (window.DeviceOrientationEvent) {3 // DeviceOrientation is supported4 5 var v_alpha = document.getElementById('alpha');6 var v_beta = document.getElementById('beta');;7 var v_gamma = document.getElementById('gamma');;8 9 var needle = document.getElementById('compass-needle');10 11 window.addEventListener('deviceorientation', function(e) {12 v_alpha.innerHTML = e.alpha;13 v_beta.innerHTML = e.beta;14 v_gamma.innerHTML = e.gamma;15 16 needle.style.webkitTransform = 'rotate('+Math.floor(e.alpha)+'deg)';17 }, false);18 19 } else if (window.OrientationEvent) {20 Alert("MozOrientation is supported");21 }22 }, true);23 24
Este ShareCode tiene versiones:
- Mapa rotativo (chrome) AGU... (11/03/2013)
- Orientation Alpha: _ Beta: _ Gamma:... (24/04/2013)
- Orientation Alpha: _ Beta: _ Gamma:... (24/04/2013)
- Orientation Alpha: _ Beta: _ Gamma:... (24/04/2013)
- Orientation Alpha: _ Beta: _ Gamma:... (24/04/2013)
- Orientation Alpha: _ Beta: _ Gamma:... (24/04/2013)
Enlace
El enlace para compartir es: