JSFiddle - React, Tailwind, and code Playground

by godfrzero

HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script><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 type="button" value="Start Animation" id="animationTrigger"/>
<input type="button" value="Stop Animation" id="animationStopper"/>

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 .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);
  
    -webkit-animation-duration: 0;
}

.radialWrapper.animating .circle, .radialWrapper.animating .maskLeft {
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: linear;
    -webkit-animation-duration: 14s;
}

.circle.right {
    clip: rect(0 100px 100px 50px);
    -webkit-animation-name: rightCircle;
}

.circle.left {
    clip: rect(0 50px 100px 0);
   ...

JavaScript

/* Custom Radial Progress Indicator */
$('#animationTrigger').click(function() {
  $('#rW1').removeClass('animating').addClass('animating');
});

$('#animationStopper').click(function() {
  $('#rW1').removeClass('animating');
});