Refactor Santa feature: reorganize present images and Santa image constants for clarity
This commit is contained in:
@@ -11,6 +11,21 @@ const minSantaRestTime = config.MinSantaRestTime || 3; // minimum time santa res
|
|||||||
const maxPresentFallSpeed = config.MaxPresentFallSpeed || 5; // maximum speed of falling presents in seconds
|
const maxPresentFallSpeed = config.MaxPresentFallSpeed || 5; // maximum speed of falling presents in seconds
|
||||||
const minPresentFallSpeed = config.MinPresentFallSpeed || 2; // minimum speed of falling presents in seconds
|
const minPresentFallSpeed = config.MinPresentFallSpeed || 2; // minimum speed of falling presents in seconds
|
||||||
|
|
||||||
|
// credits: flaticon.com
|
||||||
|
const presentImages = [
|
||||||
|
'../Seasonals/Resources/santa_images/gift1.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift2.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift3.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift4.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift5.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift6.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift7.png',
|
||||||
|
'../Seasonals/Resources/santa_images/gift8.png',
|
||||||
|
];
|
||||||
|
|
||||||
|
// credits: https://www.animatedimages.org/img-animated-santa-claus-image-0420-85884.htm
|
||||||
|
const santaImage = '../Seasonals/Resources/santa_images/santa.gif';
|
||||||
|
|
||||||
let msgPrinted = false; // flag to prevent multiple console messages
|
let msgPrinted = false; // flag to prevent multiple console messages
|
||||||
let isMobile = false; // flag to detect mobile devices
|
let isMobile = false; // flag to detect mobile devices
|
||||||
let canvas, ctx; // canvas and context for drawing snowflakes
|
let canvas, ctx; // canvas and context for drawing snowflakes
|
||||||
@@ -52,12 +67,10 @@ function toggleSnowfall() {
|
|||||||
|
|
||||||
// observe changes in the DOM
|
// observe changes in the DOM
|
||||||
const observer = new MutationObserver(toggleSnowfall);
|
const observer = new MutationObserver(toggleSnowfall);
|
||||||
|
|
||||||
// start observation
|
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
childList: true, // observe adding/removing of child elements
|
childList: true,
|
||||||
subtree: true, // observe all levels of the DOM tree
|
subtree: true,
|
||||||
attributes: true // observe changes to attributes (e.g. class changes)
|
attributes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
let resizeObserver; // Observer for resize events
|
let resizeObserver; // Observer for resize events
|
||||||
@@ -179,22 +192,6 @@ function updateSnowflakes() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// credits: flaticon.com
|
|
||||||
const presentImages = [
|
|
||||||
'../Seasonals/Resources/santa_images/gift1.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift2.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift3.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift4.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift5.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift6.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift7.png',
|
|
||||||
'../Seasonals/Resources/santa_images/gift8.png',
|
|
||||||
];
|
|
||||||
|
|
||||||
// credits: https://www.animatedimages.org/img-animated-santa-claus-image-0420-85884.htm
|
|
||||||
const santaImage = '../Seasonals/Resources/santa_images/santa.gif';
|
|
||||||
|
|
||||||
|
|
||||||
function createSantaElement() {
|
function createSantaElement() {
|
||||||
const santa = document.createElement('img');
|
const santa = document.createElement('img');
|
||||||
santa.src = santaImage;
|
santa.src = santaImage;
|
||||||
|
|||||||
Reference in New Issue
Block a user