This commit is contained in:
MLH
2025-01-14 02:02:47 +01:00
parent 75cc277264
commit b1b304d3b6

View File

@ -1,5 +1,6 @@
const snowfall = true; // enable/disable snowfall
const snowflakesCount = 500; // count of snowflakes (recommended values: 300-600)
let snowflakesCount = 500; // count of snowflakes (recommended values: 300-600)
const snowflakesCountMobile = 250; // count of snowflakes on mobile devices
const snowFallSpeed = 3; // speed of snowfall (recommended values: 0-5)
let msgPrinted = false; // flag to prevent multiple console messages
@ -116,25 +117,8 @@ function animateSnowfall() {
requestAnimationFrame(animateSnowfall);
}
/*
// initialize snowfall after the DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
if (!snowfall){
console.warn('Snowfall is disabled.');
return; // exit if snowfall is disabled
}
const container = document.querySelector('.snowfall-container');
if (container) {
initializeCanvas();
snowflakes = createSnowflakes(container);
animateSnowfall();
}
});
*/
// initialize snowfall
function initializeSnowfall() {
document.addEventListener('DOMContentLoaded', () => {
if (!snowfall){
console.warn('Snowfall is disabled.');
return; // exit if snowfall is disabled
@ -143,6 +127,7 @@ function initializeSnowfall() {
if (container) {
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (screenWidth < 768) { // lower count of snowflakes on mobile devices
console.log('Mobile device detected. Reducing snowflakes count.');
snowflakesCount = snowflakesCountMobile;
}
@ -151,6 +136,4 @@ function initializeSnowfall() {
snowflakes = createSnowflakes(container);
animateSnowfall();
}
}
initializeSnowfall();
});