NVM I figured it out. Here is what I needed to do. I had to really think about what you were saying. thanks for pointing me in the right direction. I will post this on github for everyone to use.
Module.register("MMM-Snowflakes", {
defaults: {
totalSnowflakes: 50 // Default number of snowflakes
},
// Start the module
start: function () {
Log.info("Starting module: " + this.name);
},
// Called when MagicMirror DOM is created
notificationReceived: function(notification, payload, sender) {
if (notification === 'MODULE_DOM_CREATED') {
this.createSnowflakes();
}
},
// Create snowflakes in the DOM
createSnowflakes: function () {
const snowContainer = document.querySelector(".initial-snow");
if (!snowContainer) {
Log.error("Snowflakes: Container not found!");
return;
}
const totalSnowflakes = this.config.totalSnowflakes; // Get from config
const snowflakeVariants = ["❄", "❅", "❆"]; // Snowflake symbols
for (let i = 0; i < totalSnowflakes; i++) {
const snowflake = document.createElement("span");
snowflake.classList.add("snowflake");
// Randomly pick a snowflake variant
const variantIndex = Math.floor(Math.random() * snowflakeVariants.length);
snowflake.innerHTML = snowflakeVariants[variantIndex];
// Randomize size, position, and animation duration
const size = Math.random() * 0.8 + 0.2; // Size between 0.2 and 1
const left = Math.random() * 100; // Random horizontal position
const duration = Math.random() * 5 + 5; // Duration between 5s and 10s
const blur = Math.random() < 0.3 ? "blur(1px)" : "none";
snowflake.style.fontSize = `${size}em`;
snowflake.style.left = `${left}vw`;
snowflake.style.animationDuration = `${duration}s`;
snowflake.style.filter = blur;
snowflake.style.setProperty("--start-x", `${Math.random() * 10 - 5}vw`);
snowflake.style.setProperty("--end-x", `${Math.random() * 10 - 5}vw`);
// Append snowflake to the container
snowContainer.appendChild(snowflake);
}
},
// Generate DOM for this module
getDom: function() {
const wrapper = document.createElement("div");
wrapper.className = "initial-snow"; // Container for snowflakes
return wrapper;
},
// Load CSS for the module
getStyles: function() {
return ["MMM-Snowflakes.css"];
}
});