Created
February 8, 2010 04:54
-
-
Save hitode909/297885 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<body> | |
<script> | |
var current = { x: 0.0, y: 0.0, z: 0.0 }; | |
window.addEventListener("MozOrientation", | |
function(data) { | |
var xyz = ['x', 'y', 'z']; | |
for(var i = 0;i<xyz.length;i++){ | |
var sum = Math.abs(data.x) + Math.abs(data.y) + Math.abs(data.z); | |
if (data[xyz[i]] > 0) { | |
document.querySelector("div#"+xyz[i]).style.width = data[xyz[i]] * 300 + 'px'; | |
document.querySelector("div#"+xyz[i]).style.marginLeft = '300px'; | |
} else { | |
document.querySelector("div#"+xyz[i]).style.width = data[xyz[i]] * -300 + 'px'; | |
document.querySelector("div#"+xyz[i]).style.marginLeft = (300 + data[xyz[i]] * 300) + 'px'; | |
} | |
} | |
}, true); | |
</script> | |
<div id="x" style="background: #f00; margin-left: 300px; height: 90px;" >x</div> | |
<div id="y" style="background: #0f0; margin-left: 300px; height: 90px;" >y</div> | |
<div id="z" style="background: #00f; margin-left: 300px; height: 90px;" >z</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment