Refactor space.js to remove unused randomization options, streamline object counts for mobile, and enhance code readability with updated credits
This commit is contained in:
@@ -6,13 +6,15 @@ const astronautCountConf = config.AstronautCount !== undefined ? config.Astronau
|
|||||||
const satelliteCountConf = config.SatelliteCount !== undefined ? config.SatelliteCount : 4;
|
const satelliteCountConf = config.SatelliteCount !== undefined ? config.SatelliteCount : 4;
|
||||||
const issCountConf = config.IssCount !== undefined ? config.IssCount : 1;
|
const issCountConf = config.IssCount !== undefined ? config.IssCount : 1;
|
||||||
const rocketCountConf = config.RocketCount !== undefined ? config.RocketCount : 1;
|
const rocketCountConf = config.RocketCount !== undefined ? config.RocketCount : 1;
|
||||||
const useRandomSymbols = config.EnableRandomSymbols !== undefined ? config.EnableRandomSymbols : true;
|
|
||||||
const enableRandomMobile = config.EnableRandomSymbolsMobile !== undefined ? config.EnableRandomSymbolsMobile : false;
|
|
||||||
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true;
|
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true;
|
||||||
|
const symbolCountMobile = config.SymbolCountMobile !== undefined ? config.SymbolCountMobile : 2; // Devisor to reduce number of objects on mobile
|
||||||
|
|
||||||
|
// Credit: https://lottiefiles.com/free-animation/astronaut-63lcWG4Xnh
|
||||||
const astronautImages = [
|
const astronautImages = [
|
||||||
"../Seasonals/Resources/space_assets/astronaut_1.gif"
|
"../Seasonals/Resources/space_assets/astronaut_1.gif"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Credits: https://flaticon.com
|
||||||
const planetImages = [
|
const planetImages = [
|
||||||
"../Seasonals/Resources/space_assets/planet_1.png",
|
"../Seasonals/Resources/space_assets/planet_1.png",
|
||||||
"../Seasonals/Resources/space_assets/planet_2.png",
|
"../Seasonals/Resources/space_assets/planet_2.png",
|
||||||
@@ -24,13 +26,21 @@ const planetImages = [
|
|||||||
"../Seasonals/Resources/space_assets/planet_8.png",
|
"../Seasonals/Resources/space_assets/planet_8.png",
|
||||||
"../Seasonals/Resources/space_assets/planet_9.png"
|
"../Seasonals/Resources/space_assets/planet_9.png"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Credits: https://lottiefiles.com/free-animation/s-satellite-vfnNE8AALo
|
||||||
const satelliteImages = [
|
const satelliteImages = [
|
||||||
"../Seasonals/Resources/space_assets/Satellite_1.gif",
|
"../Seasonals/Resources/space_assets/Satellite_1.gif",
|
||||||
"../Seasonals/Resources/space_assets/Satellite_2.gif"
|
"../Seasonals/Resources/space_assets/Satellite_2.gif"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Credit: https://pixabay.com/de/illustrations/raumstation-raum-struktur-8023777/
|
||||||
const issImage = "../Seasonals/Resources/space_assets/iss.png";
|
const issImage = "../Seasonals/Resources/space_assets/iss.png";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Credits:
|
||||||
|
* https://lottiefiles.com/free-animation/rocket-MYUQ3UFq3k
|
||||||
|
* https://pixabay.com/de/vectors/space-shuttle-atlantis-nasa-156012/
|
||||||
|
*/
|
||||||
const rocketImages = [
|
const rocketImages = [
|
||||||
"../Seasonals/Resources/space_assets/rocket.gif",
|
"../Seasonals/Resources/space_assets/rocket.gif",
|
||||||
"../Seasonals/Resources/space_assets/space-shuttle.png"
|
"../Seasonals/Resources/space_assets/space-shuttle.png"
|
||||||
@@ -78,26 +88,19 @@ function createSpace() {
|
|||||||
document.body.appendChild(container);
|
document.body.appendChild(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
const standardPlanetCount = 4;
|
// const standardPlanetCount = 4;
|
||||||
const standardAstronautCount = 1;
|
// const standardAstronautCount = 1;
|
||||||
const standardSatelliteCount = 2;
|
// const standardSatelliteCount = 2;
|
||||||
const standardIssCount = 1;
|
// const standardIssCount = 1;
|
||||||
const standardRocketCount = 1;
|
// const standardRocketCount = 1;
|
||||||
|
|
||||||
let isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
let isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
||||||
let pCount = planetCountConf;
|
let divisor = isMobile ? Math.max(1, symbolCountMobile) : 1;
|
||||||
let aCount = astronautCountConf;
|
let pCount = Math.floor(planetCountConf / divisor);
|
||||||
let sCount = satelliteCountConf;
|
let aCount = Math.floor(astronautCountConf / divisor);
|
||||||
let iCount = issCountConf;
|
let sCount = Math.floor(satelliteCountConf / divisor);
|
||||||
let rCount = rocketCountConf;
|
let iCount = Math.floor(issCountConf / divisor);
|
||||||
|
let rCount = Math.floor(rocketCountConf / divisor);
|
||||||
if (isMobile && !enableRandomMobile) {
|
|
||||||
pCount = standardPlanetCount;
|
|
||||||
aCount = standardAstronautCount;
|
|
||||||
sCount = standardSatelliteCount;
|
|
||||||
iCount = standardIssCount;
|
|
||||||
rCount = standardRocketCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Nebula Glow
|
// Add Nebula Glow
|
||||||
const bgGlow = document.createElement('div');
|
const bgGlow = document.createElement('div');
|
||||||
|
|||||||
Reference in New Issue
Block a user