javascript - Arc progress bar -
i need make circular progress bar (image below), loading start left bottom side right bottom side. light-blue (#e8f6fd)
color empty state , strong-blue (#1cadeb)
progress.
i have tried approaches, cannot find best 1 implementation:
- first of tried using
div
elementborder-radius: 50%;
,border-bottom-color: transparent;
, jsfiddle. in approach got shape in image problem how can fill border progress? - the second try using canvas, , approach nice expect reason loader appears on screen after
js
loaded, prevent behavior , show loader when page loaded, jsfiddle
so question there approaches can achive an arc loader or suggestion listed problems.
you can use inline svg arc commands make arc shape. animation can handled css transitioning stroke-dasharray property.
here example, hover arc launch loading animation :
svg { display: block; width: 40%; margin: 0 auto; } .loader { stroke-dasharray: 0 18 18; transition: stroke-dasharray 2s linear; } svg:hover .loader { stroke-dasharray: 18 0 18; }
<svg viewbox="0 0.5 10 8"> <path d="m2 8 4 4 0 1 1 8 8" fill="none" stroke-width="0.78" stroke="#e8f6fd" /> <path class="loader" d="m2 8 4 4 0 1 1 8 8" fill="none" stroke-width="0.8" stroke="#00acee" /> </svg>
note need add vendor prefixes transition property browser support (more info on caniuse).
Comments
Post a Comment