This commit is contained in:
CodeDevMLH
2025-09-28 21:37:48 +02:00
parent b3a531e3a9
commit b519ad0db2
2 changed files with 40 additions and 4 deletions

View File

@@ -48,78 +48,102 @@
@-webkit-keyframes leaf-shake { @-webkit-keyframes leaf-shake {
0%, 100% { 0%, 100% {
-webkit-transform: translateX(0) rotate(-15deg); -webkit-transform: translateX(0) rotate(var(--rotate-start, -20deg));
} }
50% { 50% {
-webkit-transform: translateX(80px) rotate(15deg); -webkit-transform: translateX(80px) rotate(var(--rotate-end, 20deg));
} }
} }
@keyframes leaf-shake { @keyframes leaf-shake {
0%, 100% { 0%, 100% {
transform: translateX(0) rotate(-15deg); transform: translateX(0) rotate(var(--rotate-start, -20deg));
} }
50% { 50% {
transform: translateX(80px) rotate(15deg); transform: translateX(80px) rotate(var(--rotate-end, 20deg));
} }
} }
.leaf:nth-of-type(0) { .leaf:nth-of-type(0) {
left: 0%; left: 0%;
animation-delay: 0s, 0s; animation-delay: 0s, 0s;
--rotate-start: -25deg;
--rotate-end: 22deg;
} }
.leaf:nth-of-type(1) { .leaf:nth-of-type(1) {
left: 10%; left: 10%;
animation-delay: 1s, 0.5s; animation-delay: 1s, 0.5s;
--rotate-start: -32deg;
--rotate-end: 35deg;
} }
.leaf:nth-of-type(2) { .leaf:nth-of-type(2) {
left: 20%; left: 20%;
animation-delay: 6s, 1s; animation-delay: 6s, 1s;
--rotate-start: -28deg;
--rotate-end: 28deg;
} }
.leaf:nth-of-type(3) { .leaf:nth-of-type(3) {
left: 30%; left: 30%;
animation-delay: 4s, 1.5s; animation-delay: 4s, 1.5s;
--rotate-start: -38deg;
--rotate-end: 32deg;
} }
.leaf:nth-of-type(4) { .leaf:nth-of-type(4) {
left: 40%; left: 40%;
animation-delay: 2s, 0.8s; animation-delay: 2s, 0.8s;
--rotate-start: -22deg;
--rotate-end: 38deg;
} }
.leaf:nth-of-type(5) { .leaf:nth-of-type(5) {
left: 50%; left: 50%;
animation-delay: 8s, 2s; animation-delay: 8s, 2s;
--rotate-start: -35deg;
--rotate-end: 25deg;
} }
.leaf:nth-of-type(6) { .leaf:nth-of-type(6) {
left: 60%; left: 60%;
animation-delay: 6s, 1.2s; animation-delay: 6s, 1.2s;
--rotate-start: -40deg;
--rotate-end: 40deg;
} }
.leaf:nth-of-type(7) { .leaf:nth-of-type(7) {
left: 70%; left: 70%;
animation-delay: 2.5s, 0.3s; animation-delay: 2.5s, 0.3s;
--rotate-start: -30deg;
--rotate-end: 30deg;
} }
.leaf:nth-of-type(8) { .leaf:nth-of-type(8) {
left: 80%; left: 80%;
animation-delay: 1s, 1.8s; animation-delay: 1s, 1.8s;
--rotate-start: -26deg;
--rotate-end: 36deg;
} }
.leaf:nth-of-type(9) { .leaf:nth-of-type(9) {
left: 90%; left: 90%;
animation-delay: 3s, 0.7s; animation-delay: 3s, 0.7s;
--rotate-start: -34deg;
--rotate-end: 24deg;
} }
.leaf:nth-of-type(10) { .leaf:nth-of-type(10) {
left: 25%; left: 25%;
animation-delay: 2s, 2.3s; animation-delay: 2s, 2.3s;
--rotate-start: -29deg;
--rotate-end: 33deg;
} }
.leaf:nth-of-type(11) { .leaf:nth-of-type(11) {
left: 65%; left: 65%;
animation-delay: 4s, 1.4s; animation-delay: 4s, 1.4s;
--rotate-start: -37deg;
--rotate-end: 27deg;
} }

View File

@@ -100,6 +100,12 @@ function addRandomLeaves(count) {
leaveDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`; leaveDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
} }
// set random rotation angles
const randomRotateStart = -(Math.random() * 40 + 20); // 10deg to 30deg
const randomRotateEnd = Math.random() * 40 + 20; // -10deg to -30deg
leaveDiv.style.setProperty('--rotate-start', `${randomRotateStart}deg`);
leaveDiv.style.setProperty('--rotate-end', `${randomRotateEnd}deg`);
// add the leave to the container // add the leave to the container
autumnContainer.appendChild(leaveDiv); autumnContainer.appendChild(leaveDiv);
} }
@@ -130,6 +136,12 @@ function initLeaves() {
leafDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`; leafDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
} }
// set random rotation angles for standard leaves too
const randomRotateStart = -(Math.random() * 40 + 20); // 10deg to 30deg
const randomRotateEnd = Math.random() * 40 + 20; // -10deg to -30deg
leafDiv.style.setProperty('--rotate-start', `${randomRotateStart}deg`);
leafDiv.style.setProperty('--rotate-end', `${randomRotateEnd}deg`);
leafDiv.appendChild(img); leafDiv.appendChild(img);
container.appendChild(leafDiv); container.appendChild(leafDiv);
} }