Use jQuery .animate() stepfor custom values to control .barCSS3transform: rotate
$(".progress").each(function(){
var $bar = $(this).find(".bar");
var $val = $(this).find("span");
var perc = parseInt( $val.text(), 10);
$({p:0}).animate({p:perc}, {
duration: 3000,
easing: "swing",
step: function(p) {
$bar.css({
transform: "rotate("+ (45+(p*1.8)) +"deg)",
});
$val.text(p|0);
}
});
});
.progress{
position: relative;
margin: 4px;
float:left;
text-align: center;
}
.barOverflow{
position: relative;
overflow: hidden;
width: 90px; height: 45px;
margin-bottom: -14px;
}
.bar{
position: absolute;
top: 0; left: 0;
width: 90px; height: 90px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid #eee;
border-bottom-color: #0bf;
border-right-color: #0bf;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="progress">
<div class="barOverflow">
<div class="bar"></div>
</div>
<span>10</span>%
</div>
<div class="progress">
<div class="barOverflow">
<div class="bar"></div>
</div>
<span>100</span>%
</div>
<div class="progress">
<div class="barOverflow">
<div class="bar"></div>
</div>
<span>34</span>%
</div>
<div class="progress">
<div class="barOverflow">
<div class="bar"></div>
</div>
<span>67</span>%
</div>
Run codeHide resultPS: you do not need JS (this can be done in pure CSS3 ... if you do not need to precisely control the execution steps)
source
share