typo
This commit is contained in:
27
snowfall.js
27
snowfall.js
@@ -1,5 +1,6 @@
|
|||||||
const snowfall = true; // enable/disable snowfall
|
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)
|
const snowFallSpeed = 3; // speed of snowfall (recommended values: 0-5)
|
||||||
|
|
||||||
let msgPrinted = false; // flag to prevent multiple console messages
|
let msgPrinted = false; // flag to prevent multiple console messages
|
||||||
@@ -116,25 +117,8 @@ function animateSnowfall() {
|
|||||||
requestAnimationFrame(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
|
// initialize snowfall
|
||||||
function initializeSnowfall() {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
if (!snowfall){
|
if (!snowfall){
|
||||||
console.warn('Snowfall is disabled.');
|
console.warn('Snowfall is disabled.');
|
||||||
return; // exit if snowfall is disabled
|
return; // exit if snowfall is disabled
|
||||||
@@ -143,6 +127,7 @@ function initializeSnowfall() {
|
|||||||
if (container) {
|
if (container) {
|
||||||
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
|
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
|
||||||
if (screenWidth < 768) { // lower count of snowflakes on mobile devices
|
if (screenWidth < 768) { // lower count of snowflakes on mobile devices
|
||||||
|
console.log('Mobile device detected. Reducing snowflakes count.');
|
||||||
snowflakesCount = snowflakesCountMobile;
|
snowflakesCount = snowflakesCountMobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +136,4 @@ function initializeSnowfall() {
|
|||||||
snowflakes = createSnowflakes(container);
|
snowflakes = createSnowflakes(container);
|
||||||
animateSnowfall();
|
animateSnowfall();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
initializeSnowfall();
|
|
Reference in New Issue
Block a user