JSFiddle - React, Tailwind, and code Playground
by godfrzero
HTML
<div class="radialWrapper" id="rW1">
<div class="circle right"></div>
<div class="circle left"></div>
<div class="maskLeft"></div>
<div class="mask"></div>
</div>
<input id="animationTrigger" type="button" value="Start Animation" />
<input id="animationStopper" type="button" value="Stop Animation" />
CSS
@-webkit-keyframes leftMask {
0% { opacity: 1; }
49.9% { opacity: 1; }
50% { opacity: 0; }
99.9% { opacity: 0; }
100% { opacity: 1; }
}
@-webkit-keyframes leftCircle {
0% {
opacity: 0;
-webkit-transform: rotate(-180deg);
}
49.9% { opacity: 0; }
50% {
opacity: 1;
-webkit-transform: rotate(-180deg);
}
99.9% { opacity: 1; }
100% {
opacity: 0;
-webkit-transform: rotate(0deg);
}
}
@-webkit-keyframes rightCircle {
0% {
opacity: 1;
-webkit-transform: rotate(-180deg);
}
49.9% {
opacity: 1;
}
50% {
opacity: 1;
-webkit-transform: rotate(0deg);
}
99.9% {
opacity: 1;
}
100% {
opacity: 0.5;
-webkit-transform: rotate(0deg);
}
}
.radialWrapper {
position: relative;
height: 100px;
width: 100px;
}
.radialWrapper.animating {
background: rgba(0, 0, 0, 0.02);
}
.radialWrapper .mask {
height: 80%;
width: 80%;
border-radius: 100px;
position: absolute;
margin: 10%;
top: 0;
left: 0;
background: white;
}
.radialWrapper .maskLeft {
height: 100%;
width: 50%;
position: absolute;
top: 0;
left: 0;
background: white;
-webkit-animation-name: leftMask;
}
.circle {
height: 100px;
width: 100px;
border-radius: 100px;
background: black;
position: absolute;
top: 0;
left: 0;
opacity: 0;
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
transform: rotate(-180deg);
}
.circle, .radialWrapper .maskLeft {
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 10s;
}
.circle.right {
clip: rect(0 100px 100px 50px);
-webkit-animation-name: rightCircle;
}
.circle.left {
clip: rect(0 50px 100px 0);
-webkit-animation-name:...
JavaScript
/* Custom Radial Progress Indicator */
$('#animationTrigger').click(function() {
$('#rW1').addClass('animating');
});
$('#animationStopper').click(function() {
$('#rW1').removeClass('animating');
});