Refactor seasonal scripts to enhance mobile detection using matchMedia for responsive behavior
This commit is contained in:
@@ -184,8 +184,8 @@ function initializeSnowstorm() {
|
||||
}
|
||||
const container = document.querySelector('.snowstorm-container');
|
||||
if (container) {
|
||||
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
|
||||
if (screenWidth < 768) { // lower count of snowflakes on mobile devices
|
||||
const isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
||||
if (isMobile) { // lower count of snowflakes on mobile devices
|
||||
console.log('Mobile device detected. Reducing snowflakes count.');
|
||||
snowflakesCount = snowflakesCountMobile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user