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 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 = ['🌙', '⭐', '✨'];
|
||||
|
||||
@@ -39,11 +41,13 @@ observer.observe(document.body, {
|
||||
|
||||
function createEid(container) {
|
||||
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
|
||||
const segmentWidth = 100 / lanternCount;
|
||||
for (let i = 0; i < lanternCount; i++) {
|
||||
const segmentWidth = 100 / activeLanternCount;
|
||||
for (let i = 0; i < activeLanternCount; i++) {
|
||||
const symbol = document.createElement('div');
|
||||
symbol.className = 'eid-symbol lantern-rope';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user