-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (24 loc) · 932 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener('DOMContentLoaded', () => {
const rainContainer = document.querySelector('.rain');
// Function to create a drop
function createDrop() {
const drop = document.createElement('div');
drop.classList.add('drop');
// Randomize position and animation duration
drop.style.left = Math.random() * 100 + 'vw';
drop.style.animationDuration = Math.random() * 0.5 + 0.5 + 's';
drop.style.animationDelay = Math.random() * 2 + 's';
// Append the drop to the container
rainContainer.appendChild(drop);
// Remove the drop after animation ends
drop.addEventListener('animationend', () => {
drop.remove();
});
}
// Create multiple drops
for (let i = 0; i < 100; i++) {
createDrop();
}
// Create new drops continuously
setInterval(createDrop, 200);
});