#javascript #css #jquery #анимация
Хочу сделать вот такую анимацию: https://dribbble.com/shots/3633228-Avanti-e-indietro-loader .
Но застопорился :( Буду очень благодарен кто поможет доделать анимацию (желательно
доделать с помощью javascript/jquery)! Вот код:
:root {
--duration: 1.5s;
--container-size: 210px;
--box-size: 33px;
--box-border-radius: 15%;
}
html,
body {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
.circle {
width: var(--container-size);
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
}
.📦 {
width: var(--box-size);
height: var(--box-size);
position: relative;
display: block;
transform-origin: -50% center;
border-radius: 50%;
}
.📦:after {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
background-color: orange;
border-radius: 50%;
animation-delay: 5s;
}
.📦:nth-child(1) {
animation: slide var(--duration) ease-in-out infinite alternate;
}
.📦:nth-child(1):after {
animation: color-change var(--duration) ease-in-out infinite alternate;
}
.📦:nth-child(2) {
animation: flip-1 var(--duration) infinite alternate;
}
.📦:nth-child(3) {
animation: flip-2 var(--duration) infinite alternate;
}
.📦:nth-child(4) {
animation: flip-3 var(--duration) infinite alternate;
}
.📦:nth-child(5) {
animation: flip-4 var(--duration) infinite alternate;
}
.📦:nth-child(2):after {
background-color: orange;
}
.📦:nth-child(3):after {
background-color: darkorange;
}
.📦:nth-child(4):after {
background-color: tomato;
}
.📦:nth-child(5):after {
background-color: deeppink;
}
@keyframes slide {
0% {
background-color: orange;
transform: translatex(0vw);
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
100% {
background-color: deeppink;
transform: translatex(calc(var(--container-size) - (var(--box-size) *
1.54)));
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
}
@keyframes color-change {
0% {
background-color: orange;
}
100% {
background-color: deeppink;
}
}
@keyframes flip-1 {
0%,
15% {
transform: rotate(0);
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
35%,
100% {
transform: rotate(-180deg);
box-shadow: -6px -6px rgba(0,0,0,0.09);
}
}
@keyframes flip-2 {
0%,
30% {
transform: rotate(0);
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
50%,
100% {
transform: rotate(-180deg);
box-shadow: -6px -6px rgba(0,0,0,0.09);
}
}
@keyframes flip-3 {
0%,
45% {
transform: rotate(0);
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
65%,
100% {
transform: rotate(-180deg);
box-shadow: -6px -6px rgba(0,0,0,0.09);
}
}
@keyframes flip-4 {
0%,
60% {
transform: rotate(0);
box-shadow: 6px 6px rgba(0,0,0,0.09);
}
80%,
100% {
transform: rotate(-180deg);
box-shadow: -6px -6px rgba(0,0,0,0.09);
}
}
Ответы
Ответ 1
Вот вариант, только с таймингами и оформлением еще надо поколдовать... HTMLCSS :root { --duration: 5s; --half-duration: 2.5s; --container-size: 210px; --box-size: 33px; --box-border-radius: 15%; } html, body { width: 100%; height: 100%; overflow: hidden; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; } .playground { width: var(--container-size); display: flex; justify-content: space-between; align-items: center; position: relative; } .ellipse { width: 165px; height: 165px; border-radius: 50%; top: 0; left: 0; right: 0; bottom: 0; margin: auto; position: relative; border: none; transform-style: preserve-3d; transform: rotateZ(180deg) rotateY(55deg); } .ellipse .circle { width: 33px; height: 33px; border-radius: 50%; top: 0; left: 0; right: 0; bottom: 0; margin: auto; position: absolute; } .boll { margin-left: -25px; width: 33px; height: 33px; position: absolute; display: block; transform-origin: -50% center; border-radius: 50%; animation: slide var(--half-duration) ease-in-out infinite alternate; } .ellipse:nth-child(2) .circle { animation: move-1 linear infinite; animation-duration: var(--duration); } .ellipse:nth-child(3) .circle { animation: move-2 linear infinite; animation-duration: var(--duration); } .ellipse:nth-child(4) .circle { animation: move-3 linear infinite; animation-duration: var(--duration); } .ellipse:nth-child(5) .circle { animation: move-4 linear infinite; animation-duration: var(--duration); } @keyframes move-4 { 0%, 7.5% { background-color: deeppink; transform: rotateZ(360deg) translateX(40px) rotateZ(-360deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 17.5%, 50%, 82.5% { background-color: magenta; transform: rotateZ(180deg) translateX(40px) rotateZ(-180deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 92.5%, 100% { background-color: deeppink; transform: rotateZ(0) translateX(40px) rotateZ(0) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } } @keyframes move-3 { 0%, 15% { background-color: tomato; transform: rotateZ(360deg) translateX(40px) rotateZ(-360deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 25%, 50%, 75% { background-color: deeppink; transform: rotateZ(180deg) translateX(40px) rotateZ(-180deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 85%, 100% { background-color: tomato; transform: rotateZ(0) translateX(40px) rotateZ(0) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } } @keyframes move-2 { 0%, 22.5% { background-color: darkorange; transform: rotateZ(360deg) translateX(40px) rotateZ(-360deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 32.5%, 50%, 67.5% { background-color: tomato; transform: rotateZ(180deg) translateX(40px) rotateZ(-180deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 77.5%, 100% { background-color: darkorange; transform: rotateZ(0) translateX(40px) rotateZ(0) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } } @keyframes move-1 { 0%, 30% { background-color: orange; transform: rotateZ(360deg) translateX(40px) rotateZ(-360deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 40%, 50%, 60% { background-color: darkorange; transform: rotateZ(180deg) translateX(40px) rotateZ(-180deg) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } 70%, 100% { background-color: orange; transform: rotateZ(0) translateX(40px) rotateZ(0) rotateY(-70deg); box-shadow: -6px -6px rgba(0,0,0,0.09); } } @keyframes slide { 0% { background-color: deeppink; transform: translatex(calc(var(--container-size) + (var(--box-size) * 0.5))); box-shadow: 6px 6px rgba(0,0,0,0.09); } 100% { background-color: orange; transform: translatex(0vw); box-shadow: 6px 6px rgba(0,0,0,0.09); } } Смотрите здесь: JSFiddle Эллипсы позволяют вытянуть кривую обскока. Пример - здесь
Комментариев нет:
Отправить комментарий