Update rain animation and refactor rain.js comments for clarity
This commit is contained in:
@@ -22,5 +22,5 @@
|
|||||||
0% { transform: translateY(-30vh) translateX(0) rotate(20deg); opacity: 0; }
|
0% { transform: translateY(-30vh) translateX(0) rotate(20deg); opacity: 0; }
|
||||||
5% { opacity: 1; }
|
5% { opacity: 1; }
|
||||||
95% { opacity: 1; }
|
95% { opacity: 1; }
|
||||||
100% { transform: translateY(110vh) translateX(-40vh) rotate(20deg); opacity: 0; }
|
100% { transform: translateY(180vh) translateX(-60vh) rotate(20deg); opacity: 0; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// 1. Read Configuration
|
|
||||||
const config = window.SeasonalsPluginConfig?.Rain || {};
|
const config = window.SeasonalsPluginConfig?.Rain || {};
|
||||||
|
|
||||||
const enabled = config.EnableRain !== undefined ? config.EnableRain : true;
|
const enabled = config.EnableRain !== undefined ? config.EnableRain : true;
|
||||||
@@ -8,7 +7,7 @@ const rainSpeed = config.RainSpeed || 1.0;
|
|||||||
|
|
||||||
let msgPrinted = false;
|
let msgPrinted = false;
|
||||||
|
|
||||||
// 2. Toggle Function
|
// Toggle Function
|
||||||
function toggleRain() {
|
function toggleRain() {
|
||||||
const container = document.querySelector('.rain-container');
|
const container = document.querySelector('.rain-container');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
@@ -33,7 +32,6 @@ function toggleRain() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. MutationObserver
|
|
||||||
const observer = new MutationObserver(toggleRain);
|
const observer = new MutationObserver(toggleRain);
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
@@ -41,7 +39,6 @@ observer.observe(document.body, {
|
|||||||
attributes: true
|
attributes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. Element Creation
|
|
||||||
function createElements() {
|
function createElements() {
|
||||||
const container = document.querySelector('.rain-container') || document.createElement('div');
|
const container = document.querySelector('.rain-container') || document.createElement('div');
|
||||||
|
|
||||||
@@ -67,7 +64,6 @@ function createElements() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Initialization
|
|
||||||
function initializeRain() {
|
function initializeRain() {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
createElements();
|
createElements();
|
||||||
|
|||||||
Reference in New Issue
Block a user