-1
People. This code is working. But I want help to set the initial position of the progress bar.
Currently it starts at 45º. But I want it to start at 0º. Someone knows how to help me with this?
var circle = document.querySelector('circle');
var radius = circle.r.baseVal.value;
var circumference = radius * 2 * Math.PI;
circle.style.strokeDasharray = `${circumference} ${circumference}`;
circle.style.strokeDashoffset = `${circumference}`;
var percent = 1;
var tempid = setInterval(circleFrame, 40);
function circleFrame() {
if (percent >= 100) {
clearInterval(tempid);
} else {
percent++;
offset = circumference - percent / 100 * circumference;
circle.style.strokeDashoffset = offset;
}
}
html, body {
background-color: #2962FF;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
position: relative;
}
<svg class="progress-ring" width="120" height="120">
<circle class="progress-ring__circle" stroke="white" stroke-width="4" fill="transparent" r="52" cx="60" cy="60"/></svg>
Perfect. I hadn’t really thought about it. Thank you very much.
– Fernando Torres