-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add raindrop ripple background
- Loading branch information
1 parent
5772286
commit 490b47e
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Components/Backgrounds/Raindrop-Ripple-Background/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Raindrop Ripple Effect</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="background"></div> | ||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
28 changes: 28 additions & 0 deletions
28
Components/Backgrounds/Raindrop-Ripple-Background/script.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const numDrops = 50; | ||
const bg = document.getElementById('background'); | ||
|
||
for (let i = 0; i < numDrops; i++) { | ||
const drop = document.createElement('div'); | ||
drop.className = 'raindrop'; | ||
bg.appendChild(drop); | ||
|
||
const size = Math.random() * 10 + 2; // Random size between 2 and 12 px | ||
const duration = Math.random() * 2 + 1; // Random duration between 1 and 3 seconds | ||
const delay = Math.random() * 5; // Random delay between 0 and 5 seconds | ||
const x = Math.random() * window.innerWidth; // Random horizontal position | ||
const y = -Math.random() * window.innerHeight; // Start above viewport | ||
|
||
// Applying drop properties | ||
drop.style.width = `${size}px`; | ||
drop.style.height = `${size}px`; | ||
drop.style.left = `${x}px`; | ||
drop.style.animationDuration = `${duration}s`; | ||
drop.style.animationDelay = `${delay}s`; | ||
|
||
// Removing drop after animation | ||
drop.addEventListener('animationend', function () { | ||
drop.remove(); | ||
}); | ||
} | ||
}); |
39 changes: 39 additions & 0 deletions
39
Components/Backgrounds/Raindrop-Ripple-Background/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
body, html { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
#background { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: #2c3e50; | ||
pointer-events: none; | ||
} | ||
|
||
.raindrop { | ||
position: absolute; | ||
background-color: #77aaff; | ||
border-radius: 50%; | ||
pointer-events: none; | ||
animation: fall linear infinite; | ||
} | ||
|
||
@keyframes fall { | ||
0% { | ||
transform: translateY(-100px); | ||
opacity: 0; | ||
} | ||
50% { | ||
opacity: 1; | ||
} | ||
100% { | ||
transform: translateY(calc(100vh + 100px)); | ||
opacity: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters