Skip to content

Commit 0cd2e51

Browse files
authored
Merge pull request #37 from scesi/dev
Better leaf animations to Production
2 parents f429891 + 19a72c9 commit 0cd2e51

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components/LeavesBackground.astro

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
const { count = 20 } = Astro.props;
2+
const { count = 40 } = Astro.props;
33
---
44

55
<div class="leaves-container" aria-hidden="true">
@@ -41,8 +41,11 @@ const { count = 20 } = Astro.props;
4141
}
4242

4343
@keyframes fall {
44-
to {
45-
transform: translateY(100vh);
44+
0% {
45+
transform: translateY(0) rotate(0deg);
46+
}
47+
100% {
48+
transform: translateY(100vh) rotate(var(--rotation));
4649
}
4750
}
4851

@@ -94,9 +97,12 @@ const { count = 20 } = Astro.props;
9497
const initialRotation = Math.random() * 60 - 30;
9598
htmlLeaf.style.transform = `rotate(${initialRotation}deg)`;
9699

100+
const rotationSpeed = Math.random() * 360;
101+
htmlLeaf.style.setProperty('--rotation', `${rotationSpeed}deg`);
102+
97103
const img = htmlLeaf.querySelector('img');
98104
if (img) {
99-
img.style.filter = `brightness(${Math.random() * 0.5 + 0.7})`;
105+
img.style.filter = `brightness(${Math.random() * 0.7 + 0.7})`;
100106
let transformStyle = '';
101107
if (Math.random() > 0.5) {
102108
transformStyle += 'scaleX(-1)';

0 commit comments

Comments
 (0)