..
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
<script src="/seasonals/hearts.js"></script>
|
||||||
|
<link rel="stylesheet" href="/seasonal/hearts.css">
|
||||||
|
<div class="hearts-container"></div>
|
144
seperate single seasonals/Seasonals-Hearts/hearts.css
Normal file
144
seperate single seasonals/Seasonals-Hearts/hearts.css
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
.hearts-container {
|
||||||
|
display: block;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart {
|
||||||
|
position: fixed;
|
||||||
|
bottom: -10%;
|
||||||
|
z-index: 0;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
cursor: default;
|
||||||
|
-webkit-animation-name: heart-fall, heart-shake;
|
||||||
|
-webkit-animation-duration: 14s, 5s;
|
||||||
|
-webkit-animation-timing-function: linear, ease-in-out;
|
||||||
|
-webkit-animation-iteration-count: infinite, infinite;
|
||||||
|
animation-name: heart-fall, heart-shake;
|
||||||
|
animation-duration: 14s, 5s;
|
||||||
|
animation-timing-function: linear, ease-in-out;
|
||||||
|
animation-iteration-count: infinite, infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes heart-fall {
|
||||||
|
0% {
|
||||||
|
bottom: -10%
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
bottom: 100%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes heart-shake {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
-webkit-transform: translateX(0);
|
||||||
|
transform: translateX(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
-webkit-transform: translateX(80px);
|
||||||
|
transform: translateX(80px)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes heart-fall {
|
||||||
|
0% {
|
||||||
|
bottom: -10%
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
bottom: 100%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes heart-shake {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateX(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: translateX(80px)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(0) {
|
||||||
|
left: 1%;
|
||||||
|
-webkit-animation-delay: 0s, 0s;
|
||||||
|
animation-delay: 0s, 0s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(1) {
|
||||||
|
left: 10%;
|
||||||
|
-webkit-animation-delay: 1s, 1s;
|
||||||
|
animation-delay: 1s, 1s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(2) {
|
||||||
|
left: 20%;
|
||||||
|
-webkit-animation-delay: 6s, .5s;
|
||||||
|
animation-delay: 6s, .5s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(3) {
|
||||||
|
left: 30%;
|
||||||
|
-webkit-animation-delay: 4s, 2s;
|
||||||
|
animation-delay: 4s, 2s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(4) {
|
||||||
|
left: 40%;
|
||||||
|
-webkit-animation-delay: 2s, 2s;
|
||||||
|
animation-delay: 2s, 2s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(5) {
|
||||||
|
left: 50%;
|
||||||
|
-webkit-animation-delay: 8s, 3s;
|
||||||
|
animation-delay: 8s, 3s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(6) {
|
||||||
|
left: 60%;
|
||||||
|
-webkit-animation-delay: 6s, 2s;
|
||||||
|
animation-delay: 6s, 2s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(7) {
|
||||||
|
left: 70%;
|
||||||
|
-webkit-animation-delay: 2.5s, 1s;
|
||||||
|
animation-delay: 2.5s, 1s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(8) {
|
||||||
|
left: 80%;
|
||||||
|
-webkit-animation-delay: 1s, 0s;
|
||||||
|
animation-delay: 1s, 0s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(9) {
|
||||||
|
left: 90%;
|
||||||
|
-webkit-animation-delay: 3s, 1.5s;
|
||||||
|
animation-delay: 3s, 1.5s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(10) {
|
||||||
|
left: 25%;
|
||||||
|
-webkit-animation-delay: 2s, 0s;
|
||||||
|
animation-delay: 2s, 0s
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart:nth-of-type(11) {
|
||||||
|
left: 65%;
|
||||||
|
-webkit-animation-delay: 4s, 2.5s;
|
||||||
|
animation-delay: 4s, 2.5s
|
||||||
|
}
|
124
seperate single seasonals/Seasonals-Hearts/hearts.js
Normal file
124
seperate single seasonals/Seasonals-Hearts/hearts.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
const hearts = true; // enable/disable hearts
|
||||||
|
const randomSymbols = true; // enable more random symbols
|
||||||
|
const randomSymbolsMobile = false; // enable random symbols on mobile devices
|
||||||
|
const enableDiffrentDuration = true; // enable different animation duration for random symbols
|
||||||
|
const heartsCount = 25; // count of random extra symbols
|
||||||
|
|
||||||
|
let msgPrinted = false; // flag to prevent multiple console messages
|
||||||
|
|
||||||
|
// function to check and control the hearts
|
||||||
|
function toggleHearts() {
|
||||||
|
const heartsContainer = document.querySelector('.snow-container');
|
||||||
|
if (!heartsContainer) 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 hearts if video/trailer player is active or dashboard is visible
|
||||||
|
if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) {
|
||||||
|
heartsContainer.style.display = 'none'; // hide hearts
|
||||||
|
if (!msgPrinted) {
|
||||||
|
console.log('Hearts hidden');
|
||||||
|
msgPrinted = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
heartsContainer.style.display = 'block'; // show hearts
|
||||||
|
if (msgPrinted) {
|
||||||
|
console.log('Hearts visible');
|
||||||
|
msgPrinted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// observe changes in the DOM
|
||||||
|
const observer = new MutationObserver(toggleHearts);
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Array of hearts characters
|
||||||
|
const heartSymbols = ['❤️', '💕', '💞', '💓', '💗', '💖'];
|
||||||
|
|
||||||
|
|
||||||
|
function addRandomSymbols(count) {
|
||||||
|
const heartsContainer = document.querySelector('.hearts-container'); // get the hearts container
|
||||||
|
if (!heartsContainer) return; // exit if hearts container is not found
|
||||||
|
|
||||||
|
console.log('Adding random heart symbols');
|
||||||
|
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
// create a new hearts elements
|
||||||
|
const heartsDiv = document.createElement("div");
|
||||||
|
heartsDiv.className = "heart";
|
||||||
|
|
||||||
|
// pick a random hearts symbol
|
||||||
|
heartsDiv.textContent = heartSymbols[Math.floor(Math.random() * heartSymbols.length)];
|
||||||
|
|
||||||
|
|
||||||
|
// 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() * 14; // delay (0s to 14s)
|
||||||
|
const randomAnimationDelay2 = Math.random() * 5; // delay (0s to 5s)
|
||||||
|
|
||||||
|
// apply styles
|
||||||
|
heartsDiv.style.left = `${randomLeft}%`;
|
||||||
|
heartsDiv.style.animationDelay = `${randomAnimationDelay}s, ${randomAnimationDelay2}s`;
|
||||||
|
|
||||||
|
// set random animation duration
|
||||||
|
if (enableDiffrentDuration) {
|
||||||
|
const randomAnimationDuration = Math.random() * 16 + 12; // delay (12s to 16s)
|
||||||
|
const randomAnimationDuration2 = Math.random() * 7 + 3; // delay (3s to 7s)
|
||||||
|
heartsDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the hearts to the container
|
||||||
|
heartsContainer.appendChild(heartsDiv);
|
||||||
|
}
|
||||||
|
console.log('Random hearts symbols added');
|
||||||
|
}
|
||||||
|
|
||||||
|
// create hearts objects
|
||||||
|
function createHearts() {
|
||||||
|
const container = document.querySelector('.hearts-container') || document.createElement("div");
|
||||||
|
|
||||||
|
if (!document.querySelector('.hearts-container')) {
|
||||||
|
container.className = "hearts-container";
|
||||||
|
container.setAttribute("aria-hidden", "true");
|
||||||
|
document.body.appendChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
const heartsDiv = document.createElement("div");
|
||||||
|
heartsDiv.className = "heart";
|
||||||
|
heartsDiv.textContent = heartSymbols[i % heartSymbols.length];
|
||||||
|
|
||||||
|
// set random animation duration
|
||||||
|
if (enableDiffrentDuration) {
|
||||||
|
const randomAnimationDuration = Math.random() * 16 + 12; // delay (12s to 16s)
|
||||||
|
const randomAnimationDuration2 = Math.random() * 7 + 3; // delay (3s to 7s)
|
||||||
|
heartsDiv.style.animationDuration = `${randomAnimationDuration}s, ${randomAnimationDuration2}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.appendChild(heartsDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// initialize hearts after the DOM is loaded
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
if (!hearts) return; // exit if hearts is disabled
|
||||||
|
createHearts();
|
||||||
|
toggleHearts();
|
||||||
|
|
||||||
|
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
|
||||||
|
if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random heartss only on larger screens, unless enabled for mobile devices
|
||||||
|
addRandomSymbols(heartsCount);
|
||||||
|
}
|
||||||
|
});
|
22
seperate single seasonals/Seasonals-Hearts/test-site.html
Normal file
22
seperate single seasonals/Seasonals-Hearts/test-site.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Hearts Display</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: black;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<link rel="stylesheet" href="hearts.css">
|
||||||
|
<script src="hearts.js"></script>
|
||||||
|
<div class="hearts-container" aria-hidden="true"></div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Reference in New Issue
Block a user