add seperate single files
@ -0,0 +1,3 @@
|
|||||||
|
<script src="seasonals/autumn.js"></script>
|
||||||
|
<link rel="stylesheet" href="seasonals/autumn.css">
|
||||||
|
<div class="autumn-container"></div>
|
133
seperate single seasonals/Seasonals-Autumn/autumn.css
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
.autumn-container {
|
||||||
|
display: block;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf {
|
||||||
|
position: fixed;
|
||||||
|
top: -10%;
|
||||||
|
font-size: 1em;
|
||||||
|
color: #fff;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
text-shadow: 0 0 5px #000;
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
cursor: default;
|
||||||
|
-webkit-animation-name: leaf-fall, leaf-shake;
|
||||||
|
-webkit-animation-duration: 7s, 3s;
|
||||||
|
-webkit-animation-timing-function: linear, ease-in-out;
|
||||||
|
-webkit-animation-iteration-count: infinite, infinite;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
animation-name: leaf-fall, leaf-shake;
|
||||||
|
animation-duration: 7s, 3s;
|
||||||
|
animation-timing-function: linear, ease-in-out;
|
||||||
|
animation-iteration-count: infinite, infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes leaf-fall {
|
||||||
|
0% {
|
||||||
|
top: -10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
top: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes leaf-shake {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
-webkit-transform: translateX(0);
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
-webkit-transform: translateX(80px);
|
||||||
|
transform: translateX(80px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes leaf-fall {
|
||||||
|
0% {
|
||||||
|
top: -10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
top: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes leaf-shake {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: translateX(80px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(0) {
|
||||||
|
left: 0%;
|
||||||
|
animation-delay: 0s, 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(1) {
|
||||||
|
left: 10%;
|
||||||
|
animation-delay: 1s, 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(2) {
|
||||||
|
left: 20%;
|
||||||
|
animation-delay: 6s, 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(3) {
|
||||||
|
left: 30%;
|
||||||
|
animation-delay: 4s, 2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(4) {
|
||||||
|
left: 40%;
|
||||||
|
animation-delay: 2s, 2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(5) {
|
||||||
|
left: 50%;
|
||||||
|
animation-delay: 8s, 3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(6) {
|
||||||
|
left: 60%;
|
||||||
|
animation-delay: 6s, 2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(7) {
|
||||||
|
left: 70%;
|
||||||
|
animation-delay: 2.5s, 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(8) {
|
||||||
|
left: 80%;
|
||||||
|
animation-delay: 1s, 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(9) {
|
||||||
|
left: 90%;
|
||||||
|
animation-delay: 3s, 1.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(10) {
|
||||||
|
left: 25%;
|
||||||
|
animation-delay: 2s, 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaf:nth-of-type(11) {
|
||||||
|
left: 65%;
|
||||||
|
animation-delay: 4s, 2.5s;
|
||||||
|
}
|
171
seperate single seasonals/Seasonals-Autumn/autumn.js
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
const leaves = true; // enable/disable leaves
|
||||||
|
const randomLeaves = true; // enable random leaves
|
||||||
|
const randomLeavesMobile = false; // enable random leaves on mobile devices
|
||||||
|
const enableDiffrentDuration = true; // enable different duration for the random leaves
|
||||||
|
const leafCount = 25; // count of random extra leaves
|
||||||
|
|
||||||
|
|
||||||
|
let msgPrinted = false; // flag to prevent multiple console messages
|
||||||
|
|
||||||
|
// function to check and control the leaves
|
||||||
|
function toggleAutumn() {
|
||||||
|
const autumnContainer = document.querySelector('.autumn-container');
|
||||||
|
if (!autumnContainer) return;
|
||||||
|
|
||||||
|
const videoPlayer = document.querySelector('.videoPlayerContainer');
|
||||||
|
const trailerPlayer = document.querySelector('.youtubePlayerContainer');
|
||||||
|
const isDashboard = document.body.classList.contains('dashboardDocument');
|
||||||
|
const hasUserMenu = document.querySelector('#app-user-menu');
|
||||||
|
|
||||||
|
// hide leaves if video/trailer player is active or dashboard is visible
|
||||||
|
if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) {
|
||||||
|
autumnContainer.style.display = 'none'; // hide leaves
|
||||||
|
if (!msgPrinted) {
|
||||||
|
console.log('Autumn hidden');
|
||||||
|
msgPrinted = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
autumnContainer.style.display = 'block'; // show leaves
|
||||||
|
if (msgPrinted) {
|
||||||
|
console.log('Autumn visible');
|
||||||
|
msgPrinted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// observe changes in the DOM
|
||||||
|
const observer = new MutationObserver(toggleAutumn);
|
||||||
|
|
||||||
|
// start observation
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true, // observe adding/removing of child elements
|
||||||
|
subtree: true, // observe all levels of the DOM tree
|
||||||
|
attributes: true // observe changes to attributes (e.g. class changes)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const images = [
|
||||||
|
"./seasonals/autumn_images/acorn1.png",
|
||||||
|
"./seasonals/autumn_images/acorn2.png",
|
||||||
|
"./seasonals/autumn_images/leaf1.png",
|
||||||
|
"./seasonals/autumn_images/leaf2.png",
|
||||||
|
"./seasonals/autumn_images/leaf3.png",
|
||||||
|
"./seasonals/autumn_images/leaf4.png",
|
||||||
|
"./seasonals/autumn_images/leaf5.png",
|
||||||
|
"./seasonals/autumn_images/leaf6.png",
|
||||||
|
"./seasonals/autumn_images/leaf7.png",
|
||||||
|
"./seasonals/autumn_images/leaf8.png",
|
||||||
|
"./seasonals/autumn_images/leaf9.png",
|
||||||
|
"./seasonals/autumn_images/leaf10.png",
|
||||||
|
"./seasonals/autumn_images/leaf11.png",
|
||||||
|
"./seasonals/autumn_images/leaf12.png",
|
||||||
|
"./seasonals/autumn_images/leaf13.png",
|
||||||
|
"./seasonals/autumn_images/leaf14.png",
|
||||||
|
"./seasonals/autumn_images/leaf15.png",
|
||||||
|
];
|
||||||
|
|
||||||
|
// remove commented out image array to enable test site working, comment out above images array for that
|
||||||
|
/*
|
||||||
|
const images = [
|
||||||
|
"./images/acorn1.png",
|
||||||
|
"./images/acorn2.png",
|
||||||
|
"./images/leaf1.png",
|
||||||
|
"./images/leaf2.png",
|
||||||
|
"./images/leaf3.png",
|
||||||
|
"./images/leaf4.png",
|
||||||
|
"./images/leaf5.png",
|
||||||
|
"./images/leaf6.png",
|
||||||
|
"./images/leaf7.png",
|
||||||
|
"./images/leaf8.png",
|
||||||
|
"./images/leaf9.png",
|
||||||
|
"./images/leaf10.png",
|
||||||
|
"./images/leaf11.png",
|
||||||
|
"./images/leaf12.png",
|
||||||
|
"./images/leaf13.png",
|
||||||
|
"./images/leaf14.png",
|
||||||
|
"./images/leaf15.png",
|
||||||
|
];
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addRandomLeaves(count) {
|
||||||
|
const autumnContainer = document.querySelector('.autumn-container'); // get the leave container
|
||||||
|
if (!autumnContainer) return; // exit if leave container is not found
|
||||||
|
|
||||||
|
console.log('Adding random leaves');
|
||||||
|
|
||||||
|
// Array of leave characters
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
// create a new leave element
|
||||||
|
const leaveDiv = document.createElement('div');
|
||||||
|
leaveDiv.className = "leaf";
|
||||||
|
|
||||||
|
// pick a random leaf symbol
|
||||||
|
const imageSrc = images[Math.floor(Math.random() * images.length)];
|
||||||
|
const img = document.createElement("img");
|
||||||
|
img.src = imageSrc;
|
||||||
|
|
||||||
|
leaveDiv.appendChild(img);
|
||||||
|
|
||||||
|
|
||||||
|
// set random horizontal position, animation delay and size(uncomment lines to enable)
|
||||||
|
const randomLeft = Math.random() * 100; // position (0% to 100%)
|
||||||
|
const randomAnimationDelay = Math.random() * 12; // delay (0s to 12s)
|
||||||
|
const randomAnimationDelay2 = Math.random() * 5; // delay (0s to 5s)
|
||||||
|
|
||||||
|
// apply styles
|
||||||
|
leaveDiv.style.left = `${randomLeft}%`;
|
||||||
|
leaveDiv.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)
|
||||||
|
leafDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the leave to the container
|
||||||
|
autumnContainer.appendChild(leaveDiv);
|
||||||
|
}
|
||||||
|
console.log('Random leaves added');
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize standard leaves
|
||||||
|
function initLeaves() {
|
||||||
|
const container = document.querySelector('.autumn-container') || document.createElement("div");
|
||||||
|
|
||||||
|
if (!document.querySelector('.autumn-container')) {
|
||||||
|
container.className = "autumn-container";
|
||||||
|
container.setAttribute("aria-hidden", "true");
|
||||||
|
document.body.appendChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
const leafDiv = document.createElement("div");
|
||||||
|
leafDiv.className = "leaf";
|
||||||
|
|
||||||
|
const img = document.createElement("img");
|
||||||
|
img.src = images[Math.floor(Math.random() * images.length)];
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
leafDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
leafDiv.appendChild(img);
|
||||||
|
container.appendChild(leafDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize leaves and add random leaves after the DOM is loaded
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
if (!leaves) return; // exit if leaves are disabled
|
||||||
|
initLeaves();
|
||||||
|
toggleAutumn();
|
||||||
|
|
||||||
|
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
|
||||||
|
if (randomLeaves && (screenWidth > 768 || randomLeavesMobile)) { // add random leaves only on larger screens, unless enabled for mobile devices
|
||||||
|
addRandomLeaves(leafCount);
|
||||||
|
}
|
||||||
|
});
|
BIN
seperate single seasonals/Seasonals-Autumn/images/acorn1.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/acorn2.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf1.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf10.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf11.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf12.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf13.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf14.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf15.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf2.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf3.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf4.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf5.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf6.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf7.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf8.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
seperate single seasonals/Seasonals-Autumn/images/leaf9.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
20
seperate single seasonals/Seasonals-Autumn/test-site.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Autumn Display</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="autumn-container"></div>
|
||||||
|
<script src="autumn.js"></script>
|
||||||
|
<link rel="stylesheet" href="autumn.css">
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|