Site Notice
hello, world
Difference between revisions of "Svg loading"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
Line 2: | Line 2: | ||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="svgspinner" width="52px" height="52px"> | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="svgspinner" width="52px" height="52px"> | ||
<g id="group" style="" transform="translate(26,26)"> | <g id="group" style="" transform="translate(26,26)"> | ||
− | <circle data-status="doMinus" r="20" stroke="#33a0fb" stroke-width="6" stroke-dasharray=" | + | <circle data-status="doMinus" r="20" stroke="{{{color|#33a0fb}}}" stroke-width="6" stroke-dasharray="125 1000" fill="transparent" cx="0" cy="0"></circle> |
</g> | </g> | ||
<style> | <style> | ||
.svgspinner circle { | .svgspinner circle { | ||
animation: circle-spin 1.8s infinite linear; | animation: circle-spin 1.8s infinite linear; | ||
+ | transition: stroke-dasharray .2s linear; | ||
} | } | ||
@keyframes circle-spin { | @keyframes circle-spin { | ||
Line 20: | Line 21: | ||
var startSpin = setInterval(function () { | var startSpin = setInterval(function () { | ||
var $this = $('.svgspinner circle'), | var $this = $('.svgspinner circle'), | ||
− | |||
dash = $this.attr('stroke-dasharray'), | dash = $this.attr('stroke-dasharray'), | ||
dash1 = Number(dash.split(' ')[0]), | dash1 = Number(dash.split(' ')[0]), | ||
Line 26: | Line 26: | ||
if (dash1 > 126) { | if (dash1 > 126) { | ||
$this.attr('data-status', 'doMinus'); | $this.attr('data-status', 'doMinus'); | ||
− | } else if (dash1 < | + | } else if (dash1 < 11) { |
$this.attr('data-status', 'doPlus'); | $this.attr('data-status', 'doPlus'); | ||
} | } | ||
if ($this.attr('data-status') === 'doMinus') { | if ($this.attr('data-status') === 'doMinus') { | ||
− | dash2 = dash1 - | + | dash2 = dash1 - 10; |
$this.attr('stroke-dasharray', dash2 + ' 1000'); | $this.attr('stroke-dasharray', dash2 + ' 1000'); | ||
} else if ($this.attr('data-status') === 'doPlus') { | } else if ($this.attr('data-status') === 'doPlus') { | ||
− | dash2 = dash1 + | + | dash2 = dash1 + 10; |
$this.attr('stroke-dasharray', dash2 + ' 1000'); | $this.attr('stroke-dasharray', dash2 + ' 1000'); | ||
} | } |
Revision as of 01:44, 3 December 2019
<html> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="svgspinner" width="52px" height="52px"> <g id="group" style="" transform="translate(26,26)"> <circle data-status="doMinus" r="20" stroke="{{{color|#33a0fb}}}" stroke-width="6" stroke-dasharray="125 1000" fill="transparent" cx="0" cy="0"></circle> </g> <style> .svgspinner circle {
animation: circle-spin 1.8s infinite linear; transition: stroke-dasharray .2s linear;
} @keyframes circle-spin {
from { transform: rotate(0deg); } to { transform: rotate(720deg); }
} </style> <script> var startSpin = setInterval(function () {
var $this = $('.svgspinner circle'), dash = $this.attr('stroke-dasharray'), dash1 = Number(dash.split(' ')[0]), dash2; if (dash1 > 126) { $this.attr('data-status', 'doMinus'); } else if (dash1 < 11) { $this.attr('data-status', 'doPlus'); } if ($this.attr('data-status') === 'doMinus') { dash2 = dash1 - 10; $this.attr('stroke-dasharray', dash2 + ' 1000'); } else if ($this.attr('data-status') === 'doPlus') { dash2 = dash1 + 10; $this.attr('stroke-dasharray', dash2 + ' 1000'); }
}, 200); </script> </svg> </html>