$(document).ready(function(){ var deg=0; /* storing all the images into a variable */ var images = $('#stage img').removeclass('default').addclass('animationready'); // var dim = { width:images.width(),height:images.height()}; var cnt = images.length; /* finding the centers of the animation container: */ var centerx = $('#stage').width()/2-dim.width/2; var centery = $('#stage').height()/2 - dim.height/2; //$('#previous').click(function(){ // // 360/cnt lets us distribute the phones evenly in a circle // // // }); // // $('#next').click(function(){ // console.log('+'); // // }); function rotate(step,total){ deg+=step; var esin,ecos,newwidth,newheight,q; for(var i=0;i=1){ sss[i-1].id = "previous"; sss[i+1].id ="next"; } if(i==0){ sss[4].id ="previous"; sss[1].id ="next"; } if(i==4){ sss[3].id ="previous"; sss[0].id ="next"; } } } total-=math.abs(step); if(total<=0) return false; // setting the function to be run again in 40 seconds (equals to 25 frames per second): settimeout(function(){rotate(step,total)},20); } // running the animation once at load time (and moving the iphone into view): rotate(2,360/cnt); $('#stage img').click(function(event){ console.log(event); if(event.currenttarget.id=="next"){ console.log('+'); rotate(-2,360/cnt); } if(event.currenttarget.id=="previous"){ console.log('-'); rotate(2,360/cnt); } }) // $('#phonecarousel .previous,#phonecarousel .next').hover(function(){ // clearinterval(timer); // },function(){ // timer=setinterval(function(){rotate(1,360/cnt);},4000); // }); // var timer=null; // console.log("\u767e\u5ea6\u641c\u7d22\u3010\u7d20\u6750\u5bb6\u56ed\u3011\u4e0b\u8f7d\u66f4\u591ajs\u1079\u6548\u4ee3\u7801"); // timer=setinterval(function(){rotate(1,360/cnt);},4000); });