domenica 30 ottobre 2011

SCROLL

<script type="text/javascript">

var x = 0, y = 0,
    vx = 0, vy = 0,
ax = 0, ay = 0;

var sphere = document.getElementById("sphere");
var scrolla = document.getElementById("scrolla");

if (window.DeviceMotionEvent != undefined) {
window.ondevicemotion = function(e) {
ax = event.accelerationIncludingGravity.x * 4;





}


setInterval( function() {
var landscapeOrientation = window.innerWidth/window.innerHeight > 1;

vx = ax;


x = parseInt(x + vx );


boundingBoxCheck();



scrolla.style.left = x + "px";

}, 30);
}


function boundingBoxCheck(){
if (x<-50) { x = -50; vx = 0; }

if (x>2000) { x = document.documentElement.clientWidth-20; vx = -vx; }





}

</script>

Nessun commento:

Posta un commento