fix inits

This commit is contained in:
MLH
2024-12-22 02:23:48 +01:00
parent d5c697afdf
commit 65a5753f59
9 changed files with 79 additions and 46 deletions

View File

@ -135,7 +135,8 @@ function initLeaves() {
} }
} }
// initialize leaves and add random leaves after the DOM is loaded // initialize leaves and add random leaves
function initializeLeaves() {
if (!leaves) return; // exit if leaves are disabled if (!leaves) return; // exit if leaves are disabled
initLeaves(); initLeaves();
toggleAutumn(); toggleAutumn();
@ -144,3 +145,6 @@ const screenWidth = window.innerWidth; // get the screen width to detect mobile
if (randomLeaves && (screenWidth > 768 || randomLeavesMobile)) { // add random leaves only on larger screens, unless enabled for mobile devices if (randomLeaves && (screenWidth > 768 || randomLeavesMobile)) { // add random leaves only on larger screens, unless enabled for mobile devices
addRandomLeaves(leafCount); addRandomLeaves(leafCount);
} }
}
initializeLeaves();

View File

@ -109,7 +109,8 @@ function initChristmas() {
} }
} }
// initialize christmas and add random christmas symbols after the DOM is loaded // initialize christmas and add random christmas symbols
function initializeChristmas() {
if (!christmas) return; // exit if christmas is disabled if (!christmas) return; // exit if christmas is disabled
initChristmas(); initChristmas();
toggleChristmas(); toggleChristmas();
@ -118,3 +119,6 @@ const screenWidth = window.innerWidth; // get the screen width to detect mobile
if (randomChristmas && (screenWidth > 768 || randomChristmasMobile)) { // add random christmas only on larger screens, unless enabled for mobile devices if (randomChristmas && (screenWidth > 768 || randomChristmasMobile)) { // add random christmas only on larger screens, unless enabled for mobile devices
addRandomChristmas(christmasCount); addRandomChristmas(christmasCount);
} }
}
initializeChristmas();

View File

@ -151,7 +151,11 @@ function startFireworks() {
}, intervalOfFireworks); // Interval between fireworks }, intervalOfFireworks); // Interval between fireworks
} }
// Initialize fireworks and add random fireworks after the DOM is loaded // Initialize fireworks and add random fireworks
function initializeFireworks() {
if (!fireworks) return; // exit if fireworks are disabled if (!fireworks) return; // exit if fireworks are disabled
startFireworks(); startFireworks();
toggleFirework(); toggleFirework();
}
initializeFireworks();

View File

@ -122,7 +122,8 @@ function createHalloween() {
} }
} }
// initialize halloween after the DOM is loaded // initialize halloween
function initializeHalloween() {
if (!halloween) return; // exit if halloween is disabled if (!halloween) return; // exit if halloween is disabled
createHalloween(); createHalloween();
toggleHalloween(); toggleHalloween();
@ -131,3 +132,6 @@ const screenWidth = window.innerWidth; // get the screen width to detect mobile
if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random halloweens only on larger screens, unless enabled for mobile devices if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random halloweens only on larger screens, unless enabled for mobile devices
addRandomSymbols(halloweenCount); addRandomSymbols(halloweenCount);
} }
}
initializeHalloween();

View File

@ -111,7 +111,8 @@ function createHearts() {
} }
// initialize hearts after the DOM is loaded // initialize hearts
function initializeHearts() {
if (!hearts) return; // exit if hearts is disabled if (!hearts) return; // exit if hearts is disabled
createHearts(); createHearts();
toggleHearts(); toggleHearts();
@ -120,3 +121,6 @@ const screenWidth = window.innerWidth; // get the screen width to detect mobile
if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random heartss only on larger screens, unless enabled for mobile devices if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random heartss only on larger screens, unless enabled for mobile devices
addRandomSymbols(heartsCount); addRandomSymbols(heartsCount);
} }
}
initializeHearts();

View File

@ -1,7 +1,7 @@
// theme-configs.js // theme-configs.js
const automateThemeSelection = false; // Set to false to disable automatic theme selection based on the current month const automateThemeSelection = false; // Set to false to disable automatic theme selection based on the current month
const defaultTheme = 'snowflakes'; // The theme to use if automatic theme selection is disabled const defaultTheme = 'snowfall'; // The theme to use if automatic theme selection is disabled
// theme configurations // theme configurations
const themeConfigs = { const themeConfigs = {

View File

@ -99,6 +99,12 @@ function animateSnowflake(snowflake) {
fall(); fall();
} }
// initialize snowfall after the DOM is loaded // initialize snowfall
if (!snowfall) return; // exit if snowfall is disabled function initializeSnowfall() {
if (!snowfall) {
return; // exit if snowfall is disabled
}
createSnowflakes(); createSnowflakes();
}
initializeSnowfall();

View File

@ -117,7 +117,8 @@ function initSnowflakes() {
} }
} }
// initialize snowflakes and add random snowflakes after the DOM is loaded // initialize snowflakes and add random snowflakes
function initializeSnowflakes() {
if (!snowflakes) return; // exit if snowflakes are disabled if (!snowflakes) return; // exit if snowflakes are disabled
initSnowflakes(); initSnowflakes();
toggleSnowflakes(); toggleSnowflakes();
@ -126,3 +127,6 @@ const screenWidth = window.innerWidth; // get the screen width to detect mobile
if (randomSnowflakes && (screenWidth > 768 || randomSnowflakesMobile)) { // add random snowflakes only on larger screens, unless enabled for mobile devices if (randomSnowflakes && (screenWidth > 768 || randomSnowflakesMobile)) { // add random snowflakes only on larger screens, unless enabled for mobile devices
addRandomSnowflakes(snowflakeCount); addRandomSnowflakes(snowflakeCount);
} }
}
initializeSnowflakes();

View File

@ -97,7 +97,10 @@ function animateSnowflake(snowflake) {
fall(); fall();
} }
// initialize snowstorm after the DOM is loaded // initialize snowstorm
function initializeSnowstorm() {
if (!snowstorm) return; // exit if snowstorm is disabled if (!snowstorm) return; // exit if snowstorm is disabled
createSnowstorm(); createSnowstorm();
}
initializeSnowstorm();