Here is my JSfiddle I am trying to make an SVG Arc progress bar with a constant object at the end of the progress bar. When i animate this using JavaScript the constant object is going to the other side when it reach 100%. Otherwise it is working perfectly. Also i found 1 Pixel difference in stroke-dasharray for constant object when using Safari.
My Questions and concerns
1) I really like the quality of the SVG object but it is good for cross browser rendering like Canvas? (Canvas vs SVG Performance and Browser support)
2) How to prevent constant object is going to the other side when it reach 100 %?
3) How to make it responsive?
HTML
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 100 100">
<linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#56c4fb" />
<stop offset="100%" stop-color="#0baeff" />
</linearGradient>
<path class="grey" d="M30,90 A40,40 0 1,1 80,90" style="fill:none;"/>
<path id="purple" class="purple" d="M30,90 A40,40 0 1,1 80,90" style="fill:none; transition: .3s;"/>
<path id="white" class="white" d="M30,90 A40,40 0 1,1 80,90" style="fill:none; transition: .3s;"/>
</svg>
CSS
svg {
height: 90vh;
margin: auto;
display: block;
}
path {
stroke-linecap: round;
stroke-width: 6;
}
path.grey {
stroke: #e7e7e8;
}
path.purple {
stroke: url(#gradient);
stroke-dasharray: 198;
stroke-dashoffset: 198;
animation: dash 5s linear forwards;
}
path.white {
stroke: #ffffff;
stroke-dasharray: 0px, 198px;
stroke-dashoffset: 198;
stroke-width: 3.5px;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}