Skip to content

Instantly share code, notes, and snippets.

@artemuzz
Created September 11, 2019 23:42
Show Gist options
  • Save artemuzz/b8572c13e43efbe56a5e84a2c8ffe310 to your computer and use it in GitHub Desktop.
Save artemuzz/b8572c13e43efbe56a5e84a2c8ffe310 to your computer and use it in GitHub Desktop.
5 Lines: SVG Stroke Animation
- var colors = ['#6699CC', '#FFF275', '#FF8C42', '#FF3C38', '#A23E48']
svg(viewbox="0 0 50 50")
each color, i in colors
- var j = i + 1;
circle(stroke=color stroke-width="1" stroke-dasharray=j * 10 stroke-linecap="round" fill="transparent" cx="50%" cy="50%" r="2" * j style="transform-origin: 50% 50%; --index: " + j * 20)
document.querySelector("svg").style.animation = `animate 1s linear infinite`
document.querySelector("svg").style.maxWidth = '400px'
document.querySelectorAll("circle").forEach((c, i) => {
c.style.animation = `animate 2s ${i * -0.05}s linear infinite alternate`
})
@keyframes animate
to
stroke-dashoffset: var(--index)
transform: rotate(1turn)
stroke-width: 1.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment