Refactor santa.js to improve mobile detection for snowflake count adjustment

This commit is contained in:
CodeDevMLH
2026-02-28 01:21:37 +01:00
parent 93d5686b77
commit 4703ba48ed

View File

@@ -310,8 +310,8 @@ function initializeSanta() {
} }
const container = document.querySelector('.santa-container'); const container = document.querySelector('.santa-container');
if (container) { if (container) {
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const isMobile = window.matchMedia("only screen and (max-width: 768px)").matches; // check if mobile device
if (screenWidth < 768) { // lower count of snowflakes on mobile devices if (isMobile) { // lower count of snowflakes on mobile devices
isMobile = true; isMobile = true;
console.log('Mobile device detected. Reducing snowflakes count.'); console.log('Mobile device detected. Reducing snowflakes count.');
snowflakesCount = snowflakesCountMobile; snowflakesCount = snowflakesCountMobile;