Refactor resurrection.js to remove random symbol functionality and adjust symbol count initialization for mobile responsiveness

This commit is contained in:
CodeDevMLH
2026-02-28 01:21:33 +01:00
parent 71d07aa0f3
commit 93d5686b77

View File

@@ -1,10 +1,9 @@
const config = window.SeasonalsPluginConfig?.Resurrection || {}; const config = window.SeasonalsPluginConfig?.Resurrection || {};
const enableResurrection = config.EnableResurrection !== undefined ? config.EnableResurrection : true; // enable/disable resurrection const enableResurrection = config.EnableResurrection !== undefined ? config.EnableResurrection : true; // enable/disable resurrection
const enableRandomSymbols = config.EnableRandomSymbols !== undefined ? config.EnableRandomSymbols : true; // enable random symbols
const enableRandomSymbolsMobile = config.EnableRandomSymbolsMobile !== undefined ? config.EnableRandomSymbolsMobile : false; // enable random symbols on mobile
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different durations const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different durations
const symbolCount = config.SymbolCount !== undefined ? config.SymbolCount : 12; // count of symbols const symbolCount = config.SymbolCount !== undefined ? config.SymbolCount : 12; // count of symbols
const symbolCountMobile = config.SymbolCountMobile !== undefined ? config.SymbolCountMobile : 5; // count of symbols on mobile
let animationEnabled = true; let animationEnabled = true;
let statusLogged = false; let statusLogged = false;
@@ -78,10 +77,7 @@ function createSymbol(imageSrc, leftPercent, delaySeconds) {
function addSymbols(count) { function addSymbols(count) {
const container = document.querySelector('.resurrection-container'); const container = document.querySelector('.resurrection-container');
if (!container || !enableRandomSymbols) return; if (!container) return;
const isDesktop = window.innerWidth > 768;
if (!isDesktop && !enableRandomSymbolsMobile) return;
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const imageSrc = images[Math.floor(Math.random() * images.length)]; const imageSrc = images[Math.floor(Math.random() * images.length)];
@@ -91,7 +87,7 @@ function addSymbols(count) {
} }
} }
function initResurrection() { function initResurrection(count) {
let container = document.querySelector('.resurrection-container'); let container = document.querySelector('.resurrection-container');
if (!container) { if (!container) {
container = document.createElement('div'); container = document.createElement('div');
@@ -107,13 +103,17 @@ function initResurrection() {
container.appendChild(createSymbol(imageSrc, left, delay)); container.appendChild(createSymbol(imageSrc, left, delay));
}); });
const extraCount = Math.max(symbolCount - images.length, 0); const extraCount = Math.max(count - images.length, 0);
addSymbols(extraCount); addSymbols(extraCount);
} }
function initializeResurrection() { function initializeResurrection() {
if (!enableResurrection) return; if (!enableResurrection) return;
initResurrection();
const isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
const count = !isMobile ? symbolCount : symbolCountMobile;
initResurrection(count);
toggleResurrection(); toggleResurrection();
} }