Это один из способов сделать это. Вы можете попытаться скрыть оригинальный div с помощью элемента, который анимирует, как вы хотите.
В приведенном ниже примере я просто использовал psuedo ::before
для элемента #half-donut
, который я перемещаю слева направо. Надеюсь, это даст вам представление о том, как подойти к этой задаче.
$(document).ready(function(){
$('#half-donut').addClass('first-start');
$('#half-donut::before').addClass('start-anim');
setTimeout(function() {
$('#half-donut').addClass('first-pause');
}, 1700);
});
body {
background-color: #000;
}
#half-donut {
z-index: 0;
position:relative;
width: 200px;
height: 100px;
background-color: #fff;
border-radius: 200px 200px 0% 0%;
margin-right: 3px;
display: flex;
justify-content: center;
align-items: flex-end;
}
#half-donut::before {
position: absolute;
z-index: 1;
top: 0;
right: -20%;
overflow: hidden;
content: "";
background-color: black;
width: 100%;
height: 100%;
margin-right: 3px;
display: flex;
justify-content: center;
align-items: flex-end;
animation: start 2s linear;
}
#figlio {
z-index: 2;
width: 140px;
height: 75px;
background: #000;
border-radius: 140px 140px 0% 0%;
}
@keyframes start {
0% {
right: -20%;
}
33% {
right: -33%;
}
66% {
right: -66%;
}
100% {
right: -100%;
}
}
@keyframes first {
0% {
background-color: green;
}
33% {
background-color: yellow;
}
66% {
background-color: orange;
}
100% {
background-color: red;
}
}
.first-start {
animation: first 2s linear;
}
.start-anim {
animation: start 2s linear;
}
.first-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="half-donut">
<div id="figlio"></div>
</div>