comments
This commit is contained in:
15
snowstorm.js
15
snowstorm.js
@@ -1,8 +1,10 @@
|
|||||||
const snowstorm = true; // enable/disable snowstorm
|
const snowstorm = true; // enable/disable snowstorm
|
||||||
const snowflakesCount = 500; // count of snowflakes
|
const snowflakesCount = 500; // count of snowflakes (recommended values: 300-600)
|
||||||
|
const snowFallSpeed = 4; // speed of snowfall (recommended values: 0-8)
|
||||||
|
|
||||||
let msgPrinted = false; // flag to prevent multiple console messages
|
let msgPrinted = false; // flag to prevent multiple console messages
|
||||||
|
|
||||||
// function to check and control the snowflakes
|
// function to check and control the snowstorm
|
||||||
function toggleSnowstorm() {
|
function toggleSnowstorm() {
|
||||||
const snowstormContainer = document.querySelector('.snow-container');
|
const snowstormContainer = document.querySelector('.snow-container');
|
||||||
if (!snowstormContainer) return;
|
if (!snowstormContainer) return;
|
||||||
@@ -12,7 +14,7 @@ function toggleSnowstorm() {
|
|||||||
const isDashboard = document.body.classList.contains('dashboardDocument');
|
const isDashboard = document.body.classList.contains('dashboardDocument');
|
||||||
const hasUserMenu = document.querySelector('#app-user-menu');
|
const hasUserMenu = document.querySelector('#app-user-menu');
|
||||||
|
|
||||||
// hide snowflakes if video/trailer player is active or dashboard is visible
|
// hide snowstorm if video/trailer player is active or dashboard is visible
|
||||||
if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) {
|
if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) {
|
||||||
snowstormContainer.style.display = 'none'; // hide snowstorm
|
snowstormContainer.style.display = 'none'; // hide snowstorm
|
||||||
if (!msgPrinted) {
|
if (!msgPrinted) {
|
||||||
@@ -65,9 +67,9 @@ function createSnowstorm() {
|
|||||||
|
|
||||||
function animateSnowflake(snowflake) {
|
function animateSnowflake(snowflake) {
|
||||||
// animation parameters
|
// animation parameters
|
||||||
const fallSpeed = Math.random() * 5 + 2;
|
const fallSpeed = Math.random() * snowFallSpeed + 2;
|
||||||
const horizontalWind = Math.random() * 4 - 2;
|
const horizontalWind = Math.random() * 4 - 2;
|
||||||
const verticalVariation = Math.random() * 2 - 1;
|
const verticalVariation = Math.random() * 4 - 1;
|
||||||
|
|
||||||
function fall() {
|
function fall() {
|
||||||
const currentTop = parseFloat(snowflake.style.top || 0);
|
const currentTop = parseFloat(snowflake.style.top || 0);
|
||||||
@@ -88,8 +90,7 @@ function animateSnowflake(snowflake) {
|
|||||||
fall();
|
fall();
|
||||||
}
|
}
|
||||||
|
|
||||||
createSnowstorm();
|
// initialize snowstorm after the DOM is loaded
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
if (!snowstorm) return; // exit if snowstorm is disabled
|
if (!snowstorm) return; // exit if snowstorm is disabled
|
||||||
createSnowstorm();
|
createSnowstorm();
|
||||||
|
Reference in New Issue
Block a user