..
This commit is contained in:
21
halloween.js
21
halloween.js
@ -1,6 +1,7 @@
|
||||
const halloween = true; // enable/disable halloween
|
||||
const randomSymbols = true; // enable more random symbols
|
||||
const randomSymbolsMobile = false; // enable random symbols on mobile devices
|
||||
const enableDiffrentDuration = true; // enable different duration for the random halloween symbols
|
||||
const halloweenCount = 25; // count of random extra symbols
|
||||
|
||||
let msgPrinted = false; // flag to prevent multiple console messages
|
||||
@ -43,9 +44,9 @@ observer.observe(document.body, {
|
||||
|
||||
|
||||
const images = [
|
||||
"./seasonals/halloween_images/ghost_20x20.png",
|
||||
"./seasonals/halloween_images/bat_20x20.png",
|
||||
"./seasonals/halloween_images/pumpkin_20x20.png",
|
||||
"./seasonals/halloween_images/ghost_20x20.png",
|
||||
"./seasonals/halloween_images/bat_20x20.png",
|
||||
"./seasonals/halloween_images/pumpkin_20x20.png",
|
||||
];
|
||||
|
||||
// remove commented out image array to enable test site working, comment out above images array for that
|
||||
@ -86,6 +87,13 @@ function addRandomSymbols(count) {
|
||||
halloweenDiv.style.left = `${randomLeft}%`;
|
||||
halloweenDiv.style.animationDelay = `${randomAnimationDelay}s, ${randomAnimationDelay2}s`;
|
||||
|
||||
// set random animation duration
|
||||
if (enableDiffrentDuration) {
|
||||
const randomAnimationDuration = Math.random() * 10 + 6; // delay (6s to 10s)
|
||||
const randomAnimationDuration2 = Math.random() * 5 + 2; // delay (2s to 5s)
|
||||
halloweenDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||
}
|
||||
|
||||
// add the halloween to the container
|
||||
halloweenContainer.appendChild(halloweenDiv);
|
||||
}
|
||||
@ -110,6 +118,13 @@ function createHalloween() {
|
||||
const img = document.createElement("img");
|
||||
img.src = imageSrc;
|
||||
|
||||
// set random animation duration
|
||||
if (enableDiffrentDuration) {
|
||||
const randomAnimationDuration = Math.random() * 10 + 6; // delay (6s to 10s)
|
||||
const randomAnimationDuration2 = Math.random() * 5 + 2; // delay (2s to 5s)
|
||||
halloweenDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||
}
|
||||
|
||||
halloweenDiv.appendChild(img);
|
||||
container.appendChild(halloweenDiv);
|
||||
});
|
||||
|
Reference in New Issue
Block a user