Refactor eid.js to define lantern counts for mobile and desktop, ensuring consistent lantern creation across devices
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
const config = window.SeasonalsPluginConfig?.Eid || {};
|
const config = window.SeasonalsPluginConfig?.Eid || {};
|
||||||
const eid = config.EnableEid !== undefined ? config.EnableEid : true;
|
const eid = config.EnableEid !== undefined ? config.EnableEid : true;
|
||||||
|
const lanternCount = config.LanternCount !== undefined ? config.LanternCount : 8;
|
||||||
|
const lanternCountMobile = config.LanternCountMobile !== undefined ? config.LanternCountMobile : 3;
|
||||||
|
|
||||||
const eidSymbols = ['🌙', '⭐', '✨'];
|
const eidSymbols = ['🌙', '⭐', '✨'];
|
||||||
|
|
||||||
@@ -39,11 +41,13 @@ observer.observe(document.body, {
|
|||||||
|
|
||||||
function createEid(container) {
|
function createEid(container) {
|
||||||
const starCount = 20;
|
const starCount = 20;
|
||||||
const lanternCount = Math.floor(Math.random() * 3) + 4; // 4 to 6 lanterns
|
|
||||||
|
let isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
||||||
|
let activeLanternCount = isMobile ? lanternCountMobile : lanternCount;
|
||||||
|
|
||||||
// Create evenly spaced lanterns
|
// Create evenly spaced lanterns
|
||||||
const segmentWidth = 100 / lanternCount;
|
const segmentWidth = 100 / activeLanternCount;
|
||||||
for (let i = 0; i < lanternCount; i++) {
|
for (let i = 0; i < activeLanternCount; i++) {
|
||||||
const symbol = document.createElement('div');
|
const symbol = document.createElement('div');
|
||||||
symbol.className = 'eid-symbol lantern-rope';
|
symbol.className = 'eid-symbol lantern-rope';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user