Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. <style id="jsbin-css">
  8. .circle {
  9. margin: 50px;
  10. position: relative;
  11. width: 100px;
  12. height: 100px;
  13. background-color: #fff;
  14. border-radius: 50%;
  15. border: 3px solid rgba(0, 0, 0, .25);
  16. }
  17. .circle-fill-before {
  18. position: absolute;
  19. z-index: 1;
  20. top: 0;
  21. right: 0;
  22. width: 50px;
  23. height: 100px;
  24. border-radius: 0 50px 50px 0;
  25. transform-origin: 0 50%
  26. }
  27. .circle-fill-after {
  28. position: absolute;
  29. top: 0;
  30. right: 0;
  31. width: 50px;
  32. height: 100px;
  33. border-radius: 0 50px 50px 0;
  34. transform-origin: 0 50%
  35. }
  36. </style>
  37. </head>
  38. <body>
  39.  
  40. <div class="circle">
  41. <div class="circle-fill-before" style="transform: rotate(0deg);background-color: #b700b7;"></div>
  42. <div class="circle-fill-after" style="transform: rotate(180deg);background-color: #b700b7;"></div>
  43. </div>
  44.  
  45. <script id="jsbin-javascript">
  46. var countdown = function (t, u) {
  47. var fillBefore = document.querySelector('.circle-fill-before');
  48. var fillAfter = document.querySelector('.circle-fill-after');
  49.  
  50. var step = 360 / (t / u);
  51. var increament = step;
  52.  
  53. var id = setInterval(function() {
  54. if (increament <= 180) {
  55. fillBefore.style.transform = 'rotate('+ increament +'deg)';
  56. } else if (increament > 180 && increament <=360) {
  57. fillBefore.style.transform = 'rotate(0deg)';
  58. fillBefore.style.backgroundColor = '#fff';
  59. fillAfter.style.transform = 'rotate('+ increament +'deg)';
  60. } else {
  61. fillAfter.style.backgroundColor = '#fff';
  62. clearInterval(id);
  63. }
  64. increament += step;
  65. console.log(increament);
  66. }, u * 1000);
  67. }
  68.  
  69.  
  70. countdown(10, 1/100);
  71. </script>
  72.  
  73.  
  74. <script id="jsbin-source-css" type="text/css">
  75. .circle {
  76. margin: 50px;
  77. position: relative;
  78. width: 100px;
  79. height: 100px;
  80. background-color: #fff;
  81. border-radius: 50%;
  82. border: 3px solid rgba(0, 0, 0, .25);
  83. }
  84. .circle-fill-before {
  85. position: absolute;
  86. z-index: 1;
  87. top: 0;
  88. right: 0;
  89. width: 50px;
  90. height: 100px;
  91. border-radius: 0 50px 50px 0;
  92. transform-origin: 0 50%
  93. }
  94. .circle-fill-after {
  95. position: absolute;
  96. top: 0;
  97. right: 0;
  98. width: 50px;
  99. height: 100px;
  100. border-radius: 0 50px 50px 0;
  101. transform-origin: 0 50%
  102. } </script>
  103.  
  104. <script id="jsbin-source-javascript" type="text/javascript">var countdown = function (t, u) {
  105. var fillBefore = document.querySelector('.circle-fill-before');
  106. var fillAfter = document.querySelector('.circle-fill-after');
  107.  
  108. var step = 360 / (t / u);
  109. var increament = step;
  110.  
  111. var id = setInterval(function() {
  112. if (increament <= 180) {
  113. fillBefore.style.transform = 'rotate('+ increament +'deg)';
  114. } else if (increament > 180 && increament <=360) {
  115. fillBefore.style.transform = 'rotate(0deg)';
  116. fillBefore.style.backgroundColor = '#fff';
  117. fillAfter.style.transform = 'rotate('+ increament +'deg)';
  118. } else {
  119. fillAfter.style.backgroundColor = '#fff';
  120. clearInterval(id);
  121. }
  122. increament += step;
  123. console.log(increament);
  124. }, u * 1000);
  125. }
  126.  
  127.  
  128. countdown(10, 1/100);</script></body>
  129. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement