Untitled


SUBMITTED BY: Guest

DATE: Dec. 11, 2013, 7:14 a.m.

FORMAT: Text only

SIZE: 3.9 kB

HITS: 869

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <style>
  6. #show{position:relative;margin:20px auto;width:800px;border:1px solid #999999;}
  7. .item{position:absolute;height:40px;width:60px;background:#999999;border:1px solid #eeeeee;cursor:pointer;}
  8. </style>
  9. <script>
  10. var len;
  11. var showerObj;
  12. var listObj;
  13. var showerWidth=800;
  14. var showerHeight=400;
  15. var r;
  16. var cR=0;
  17. var ccR=0;
  18. var timer=0;
  19. window.onload=function(){
  20. showerObj=document.getElementById("show");
  21. listObj=showerObj.getElementsByTagName("div");
  22. len=listObj.length;
  23. r=Math.PI/180*360/len;
  24. for(var i=0;i<len;i++){
  25. var item=listObj[i];
  26. item.style.top=showerHeight/2+Math.sin(r*i)*showerWidth/2-20+"px";
  27. item.style.left=showerWidth/2+Math.cos(r*i)*showerWidth/2-30+"px";
  28. item.rotate=(r*i+2*Math.PI)%(2*Math.PI);
  29. item.onclick=function(){
  30. cR=Math.PI/2-this.rotate;
  31. timer || (timer=setInterval(rotate,10));
  32. }
  33. }
  34. var rX=showerObj.offsetLeft+showerWidth/2;
  35. var ry=showerObj.offsetTop+showerHeight/2;
  36. var rotate=function(){
  37. ccR=(ccR+2*Math.PI)%(2*Math.PI);
  38. if(cR-ccR<0) cR=cR+2*Math.PI;
  39. if(cR-ccR<Math.PI){
  40. ccR=ccR+(cR-ccR)/19;
  41. }else{
  42. ccR=ccR-(2*Math.PI+ccR-cR)/19;
  43. }
  44. if(Math.abs((cR+2*Math.PI)%(2*Math.PI)-(ccR+2*Math.PI)%(2*Math.PI))<Math.PI/720){
  45. ccR=cR;
  46. clearInterval(timer);
  47. timer=0;
  48. }
  49. for(var i=0;i<len;i++){
  50. var item=listObj[i];
  51. var w,h;
  52. var sinR=Math.sin(r*i+ccR);
  53. var cosR=Math.cos(r*i+ccR);
  54. w=60+0.6*60*sinR;
  55. h=(40+0.6*40*sinR);
  56. item.style.cssText +=";width:"+w+"px;height:"+h+"px;top:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+"px;left:"+parseInt(showerWidth/2+cosR*showerWidth/2-h/2)+"px;z-index:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+";";
  57. }
  58. }
  59. document.getElementById("l").onclick=function(){
  60. cR=(cR+r+2*Math.PI)%(2*Math.PI);
  61. timer || (timer=setInterval(rotate,10));
  62. }
  63. document.getElementById("r").onclick=function(){
  64. cR=(cR-r+2*Math.PI)%(2*Math.PI);
  65. timer || (timer=setInterval(rotate,10));
  66. }
  67. rotate();
  68. }
  69. </script>
  70. </head>
  71. <body>
  72. <input id="l" type="button" value="left" >
  73. <input id="r" type="button" value="right" >
  74. <div id="show">
  75. <div class="item">1</div>
  76. <div class="item">2</div>
  77. <div class="item">3</div>
  78. <div class="item">4</div>
  79. <div class="item">5</div>
  80. <div class="item">6</div>
  81. <div class="item">7</div>
  82. <div class="item">8</div>
  83. <div class="item">9</div>
  84. <div class="item">0</div>
  85. <div class="item">a</div>
  86. <div class="item">b</div>
  87. <div class="item">1</div>
  88. <div class="item">2</div>
  89. <div class="item">3</div>
  90. </div>
  91. </body>
  92. </html>

comments powered by Disqus