Remove unnecessary comments and streamline DOM observation in seasonal scripts
This commit is contained in:
@@ -2,17 +2,18 @@ const config = window.SeasonalsPluginConfig?.Easter || {};
|
||||
|
||||
const easter = config.EnableEaster !== undefined ? config.EnableEaster : true;
|
||||
const enableBunny = config.EnableBunny !== undefined ? config.EnableBunny : true;
|
||||
const minBunnyRestTime = config.MinBunnyRestTime || 2000;
|
||||
const maxBunnyRestTime = config.MaxBunnyRestTime || 5000;
|
||||
const eggCount = config.EggCount || 15;
|
||||
|
||||
/* MARK: Bunny movement config */
|
||||
const jumpDistanceVw = 5; // Distance in vw the bunny covers per jump
|
||||
const jumpDurationMs = 770; // Time in ms the bunny spends moving during a jump
|
||||
const pauseDurationMs = 116.6666; // Time in ms the bunny pauses between jumps
|
||||
|
||||
const minBunnyRestTime = config.MinBunnyRestTime || 2000;
|
||||
const maxBunnyRestTime = config.MaxBunnyRestTime || 5000;
|
||||
const eggCount = config.EggCount || 15;
|
||||
|
||||
const rabbit = "../Seasonals/Resources/easter_images/Osterhase.gif";
|
||||
|
||||
// Credit: https://flaticon.com
|
||||
const easterEggImages = [
|
||||
"../Seasonals/Resources/easter_images/egg_1.png",
|
||||
"../Seasonals/Resources/easter_images/egg_2.png",
|
||||
@@ -197,7 +198,7 @@ function animateRabbit(rabbit) {
|
||||
|
||||
rabbit.style.transition = 'none';
|
||||
const transformScale = startFromLeft ? 'scaleX(-1)' : '';
|
||||
// Fix bounding box center-of-gravity shift when graphic is flipped
|
||||
// Set bounding box center-of-gravity shift when graphic is flipped
|
||||
rabbit.style.transformOrigin = startFromLeft ? '59% 50%' : '50% 50%';
|
||||
rabbit.style.transform = `translateX(${currentX}vw) ${transformScale}`;
|
||||
|
||||
@@ -213,8 +214,6 @@ function animateRabbit(rabbit) {
|
||||
|
||||
if (!startTime) {
|
||||
startTime = timestamp;
|
||||
// resetting gif, appending a timestamp cache-buster forces the browser
|
||||
// to reload and start the GIF strictly from the first frame.
|
||||
const currSrc = rabbit.src.split('?')[0];
|
||||
rabbit.src = currSrc + '?t=' + Date.now();
|
||||
}
|
||||
@@ -236,7 +235,6 @@ function animateRabbit(rabbit) {
|
||||
|
||||
currentX = startX + (completedLoops * jumpDistanceVw + currentLoopDistance) * direction;
|
||||
|
||||
// Update DOM without CSS transitions
|
||||
rabbit.style.transform = `translateX(${currentX}vw) ${transformScale}`;
|
||||
|
||||
// Check if finished crossing
|
||||
|
||||
Reference in New Issue
Block a user