I am unable to get the circle bar to animate, I attempted adding transition: all 600ms ease;
but that didn’t work. I am not if css animation support conic-gradient.
jQuery(function ($) {
$('.bar').addClass('animate');
});
.icon {
width: 146px;
height: 146px;
padding: 36px;
position: relative;
flex-shrink: 0;
}
.icon .bar {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
}
.icon .bar::before {
content: "";
position: absolute;
border-radius: 50%;
inset: 0;
background: conic-gradient(#00a451 0%, #e1e1e1 0%);
z-index: 1;
transition: all 600ms ease;
}
.icon .bar::after {
content: "";
background-color: #fff;
border-radius: 50%;
width: 110px;
height: 110px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
}
.icon .bar.animate::before {
background: conic-gradient(#00a451 var(--stat-bar), #e1e1e1 0%);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<div class="icon">
<div class="bar" style="--stat-bar:75%"></div>
</div>
2
Answers
Fix: I have used the following https://codepen.io/t_afif/pen/XWaPXZO as an inspiration and updated my script accordingly and now it works as intended.
With css animation not possible in this case, please see here for a reference.
I have implemented some extra code with the JS. Please review the attributes added
animate-end="75"
animate-speed="10"
.Please let me know if this could help you.