javascript - rotate object onclick -


so have code supposed add when clicked "+10" button 10degree rotation object, when clicked "+30" button 30degree rotation object, 90degree position max available. ads 1 , dont know how make move degree want move.

http://jsfiddle.net/9xghf/

var rotateobject = document.getelementbyid("object"); var objectrotation = 0;  var add10 = document.getelementbyid("add10"); var add30 = document.getelementbyid("add30");  add10.onclick = function(){     rotate(0, 10);   } add30.onclick = function(){     rotate(0, 30);   } function rotate(index, limit){     if(objectrotation < 90 && index <= limit){         index++;         objectrotation++;         rotateobject.style.transform="rotate(" + objectrotation + "deg)";         rotateobject.style.webkittransform="rotate(" + objectrotation + "deg)";         rotateobject.style.mstransform="rotate(" + objectrotation + "deg)";         settimeout(rotate, 50);     }else{     // 90 degree max limit object      } } 

replace timer :

settimeout(function(){         rotate(index,limit);     }, 50); 

nb : won't work browsers


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -