Created
August 10, 2015 06:14
-
-
Save hoox/7815a79a923aa1c07773 to your computer and use it in GitHub Desktop.
"Device Orientation" Event Listner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('deviceorientation', function(e) { | |
var media = document.querySelectorAll("img"); | |
for (var i=0;i<media.length;i++) { | |
media[i].style.transform = "rotate("+ Math.round(e.gamma) +"deg) rotate3d(1,0,0, "+ (Math.round(e.beta)*-1)+"deg)"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment