Refactor summer object creation to use configurable bubble and dust counts

This commit is contained in:
CodeDevMLH
2026-02-19 03:18:26 +01:00
parent 20da9899e4
commit 007e55a612

View File

@@ -1,7 +1,8 @@
const config = window.SeasonalsPluginConfig?.Summer || {}; const config = window.SeasonalsPluginConfig?.Summer || {};
const summer = config.EnableSummer !== undefined ? config.EnableSummer : true; // enable/disable summer const summer = config.EnableSummer !== undefined ? config.EnableSummer : true; // enable/disable summer
const summerCount = config.ObjectCount || 30; // default count const bubbleCount = config.BubbleCount || 20;
const dustCount = config.DustCount || 50;
const randomSummer = config.EnableRandomSummer !== undefined ? config.EnableRandomSummer : true; // enable random objects const randomSummer = config.EnableRandomSummer !== undefined ? config.EnableRandomSummer : true; // enable random objects
const randomSummerMobile = config.EnableRandomSummerMobile !== undefined ? config.EnableRandomSummerMobile : false; // enable random objects on mobile const randomSummerMobile = config.EnableRandomSummerMobile !== undefined ? config.EnableRandomSummerMobile : false; // enable random objects on mobile
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different animation duration const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different animation duration
@@ -71,17 +72,17 @@ function createBubble(container, isDust = false) {
container.appendChild(bubble); container.appendChild(bubble);
} }
function addRandomSummerObjects(count) { function addRandomSummerObjects() {
const container = document.querySelector('.summer-container'); const container = document.querySelector('.summer-container');
if (!container) return; if (!container) return;
// Add bubbles // Add bubbles
for (let i = 0; i < count; i++) { for (let i = 0; i < bubbleCount; i++) {
createBubble(container, false); createBubble(container, false);
} }
// Add some dust particles (more of them, they are subtle) // Add some dust particles (more of them, they are subtle)
for (let i = 0; i < count * 2; i++) { for (let i = 0; i < dustCount; i++) {
createBubble(container, true); createBubble(container, true);
} }
} }
@@ -135,7 +136,7 @@ function initializeSummer() {
const screenWidth = window.innerWidth; const screenWidth = window.innerWidth;
if (randomSummer && (screenWidth > 768 || randomSummerMobile)) { if (randomSummer && (screenWidth > 768 || randomSummerMobile)) {
addRandomSummerObjects(summerCount); addRandomSummerObjects();
} }
} }