Site Notice

hello, world

Difference between revisions of "Svg loading"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
([InPageEdit] 没有编辑摘要)
Line 30: Line 30:
 
   if (dash1 > 126) {
 
   if (dash1 > 126) {
 
     $this.attr('class', 'doMinus');
 
     $this.attr('class', 'doMinus');
   } else if (dash1 < 10) {
+
   } else if (dash1 < 4) {
 
     $this.attr('class', 'doPlus');
 
     $this.attr('class', 'doPlus');
 
   }
 
   }
Line 40: Line 40:
 
     $this.attr('stroke-dasharray', dash2 + ' 1000');
 
     $this.attr('stroke-dasharray', dash2 + ' 1000');
 
   }
 
   }
}, 400);
+
}, 200);
 
</script>
 
</script>
 
</html>
 
</html>

Revision as of 01:27, 3 December 2019

<html> <div class="spinner-block"> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="spinner" width="52px" height="52px"> <g id="group" style="" transform="translate(26,26)"> <circle class="doMinus" r="20" stroke="black" stroke-width="6" stroke-dasharray="120 1000" fill="transparent" style="transition: stroke-dasharray .8s linear" cx="0" cy="0"></circle> </g> </svg> </div> <style> .spinner circle {

 animation: circle-spin 4s infinite linear;

} @keyframes circle-spin {

 from {
   transform: rotate(0deg);
 }
 to {
   transform: rotate(720deg);
 }

} </style>

<script> setInterval(function () {

 var $this = $('.spinner circle'),
   $class = $this.attr('class'),
   dash = $this.attr('stroke-dasharray'),
   dash1 = Number(dash.split(' ')[0]),
   dash2;
 if (dash1 > 126) {
   $this.attr('class', 'doMinus');
 } else if (dash1 < 4) {
   $this.attr('class', 'doPlus');
 }
 if ($this.hasClass('doMinus')) {
   dash2 = dash1 - 8;
   $this.attr('stroke-dasharray', dash2 + ' 1000');
 } else if ($this.hasClass('doPlus')) {
   dash2 = dash1 + 8;
   $this.attr('stroke-dasharray', dash2 + ' 1000');
 }

}, 200); </script> </html>