Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
melonmasteristaken authored Jun 4, 2024
1 parent 210815b commit eb9d87d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

//firefly.js
const fireflies = document.querySelector('.fireflies');

for (let i = 0; i < 12; i++) { // Create 10 fireflies
for (let i = 0; i < 10; i++) { // Create 10 fireflies
const firefly = document.createElement('div');
firefly.classList.add('firefly');
firefly.style.top = `${random(-200, 200)}px`;
firefly.style.left = `${random(-200, 200)}px`;
firefly.style.top = `${random(0, 100)}vh`; // Move to random vertical position
firefly.style.left = `${random(0, 100)}vw`; // Move to random horizontal position
firefly.style.animationDelay = `${random(0, 2)}s`;

// Add movement animation
// Add movement animation with fade-out
firefly.animate([
{ top: `${random(-200, 200)}px`, left: `${random(-200, 200)}px` },
{ top: `${random(-200, 200)}px`, left: `${random(-200, 200)}px` }
{
top: `${random(0, 100)}vh`,
left: `${random(0, 100)}vw`,
opacity: 1
},
{
top: `${random(0, 100)}vh`,
left: `${random(0, 100)}vw`,
opacity: 0
}
], {
duration: 2000, // 2 seconds
duration: 4000, // 4 seconds
iterations: Infinity, // Repeat indefinitely
easing: 'ease-out' // Smooth animation
});
Expand Down

0 comments on commit eb9d87d

Please sign in to comment.