Enhance game animations with rotation and elastic easing; update event details display in calendar
This commit is contained in:
@@ -871,44 +871,39 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if animation is enabled
|
// Function to animate a single game element
|
||||||
const gameAnimationEnabled = getCookie('gameAnimation') === 'true';
|
function animateGame(game) {
|
||||||
|
anime({
|
||||||
if (gameAnimationEnabled) {
|
targets: game,
|
||||||
// Function to animate a single game element
|
translateY: [-50, 0], // Fly in from above
|
||||||
function animateGame(game) {
|
rotate: [-10, 0], // Rotate back to normal
|
||||||
anime({
|
opacity: [0, 1], // Fade in
|
||||||
targets: game,
|
duration: 1000, // Animation duration
|
||||||
translateY: [-50, 0], // Fly in from above
|
easing: 'easeOutElastic(1, 0.5)', // Elastic easing for a bouncy effect
|
||||||
opacity: [0, 1], // Fade in
|
|
||||||
duration: 800,
|
|
||||||
easing: 'easeOutExpo',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an Intersection Observer to detect when games come into view
|
|
||||||
const observer = new IntersectionObserver((entries) => {
|
|
||||||
entries.forEach(entry => {
|
|
||||||
if (entry.isIntersecting) {
|
|
||||||
// Animate the game when it comes into view
|
|
||||||
animateGame(entry.target);
|
|
||||||
|
|
||||||
// Stop observing the element after animating it
|
|
||||||
observer.unobserve(entry.target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Select all game elements and hide them initially
|
|
||||||
const games = document.querySelectorAll('.game');
|
|
||||||
games.forEach(game => {
|
|
||||||
game.style.opacity = '0'; // Hide games
|
|
||||||
game.style.transform = 'translateY(-50px)'; // Move them above
|
|
||||||
observer.observe(game); // Start observing the game
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
<script>
|
// Create an Intersection Observer to detect when games come into view
|
||||||
|
const observer = new IntersectionObserver((entries, observer) => {
|
||||||
|
entries.forEach(entry => {
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
// Animate the game when it comes into view
|
||||||
|
animateGame(entry.target);
|
||||||
|
|
||||||
|
// Stop observing the element after animating it
|
||||||
|
observer.unobserve(entry.target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select all game elements and hide them initially
|
||||||
|
const games = document.querySelectorAll('.game');
|
||||||
|
games.forEach(game => {
|
||||||
|
game.style.opacity = '0'; // Hide games initially
|
||||||
|
game.style.transform = 'translateY(-50px) rotate(-10deg)'; // Move them above and rotate slightly
|
||||||
|
observer.observe(game); // Start observing the game
|
||||||
|
});
|
||||||
|
|
||||||
// Utility function to get a cookie
|
// Utility function to get a cookie
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
const cookies = document.cookie.split(';');
|
const cookies = document.cookie.split(';');
|
||||||
@@ -926,17 +921,18 @@
|
|||||||
const games = document.querySelectorAll('.game');
|
const games = document.querySelectorAll('.game');
|
||||||
games.forEach(game => {
|
games.forEach(game => {
|
||||||
game.style.opacity = '0'; // Hide games initially
|
game.style.opacity = '0'; // Hide games initially
|
||||||
game.style.transform = 'translateY(-50px)'; // Move them above
|
game.style.transform = 'translateY(-50px) rotate(-10deg)'; // Move them above and rotate slightly
|
||||||
});
|
});
|
||||||
|
|
||||||
// Use Anime.js to animate the games
|
// Use Anime.js to animate the games
|
||||||
anime({
|
anime({
|
||||||
targets: '.game',
|
targets: '.game',
|
||||||
translateY: [-50, 0], // Fly in from above
|
translateY: [-50, 0], // Fly in from above
|
||||||
|
rotate: [-10, 0], // Rotate back to normal
|
||||||
opacity: [0, 1], // Fade in
|
opacity: [0, 1], // Fade in
|
||||||
delay: anime.stagger(100), // Stagger animation for each card
|
delay: anime.stagger(150), // Stagger animation for each card
|
||||||
duration: 800, // Animation duration
|
duration: 1000, // Animation duration
|
||||||
easing: 'easeOutExpo',
|
easing: 'easeOutElastic(1, 0.5)', // Elastic easing for a bouncy effect
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,7 @@
|
|||||||
<h2>Event Details</h2>
|
<h2>Event Details</h2>
|
||||||
<p id="event-date">Date: Not selected</p>
|
<p id="event-date">Date: Not selected</p>
|
||||||
<p id="event-description">No event selected.</p>
|
<p id="event-description">No event selected.</p>
|
||||||
|
<p id="event-extra-description" style="display: none;">This is star word day</p>
|
||||||
<button id="close-details">Close</button>
|
<button id="close-details">Close</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -259,11 +260,15 @@
|
|||||||
const eventText = events[dateKey] || 'No event selected.';
|
const eventText = events[dateKey] || 'No event selected.';
|
||||||
eventDate.textContent = `Date: ${dateKey}`;
|
eventDate.textContent = `Date: ${dateKey}`;
|
||||||
eventDescription.textContent = eventText;
|
eventDescription.textContent = eventText;
|
||||||
eventDescription.className = ''; // Clear previous class
|
|
||||||
if (eventText !== 'No event selected.') {
|
// Show extra description for "Gay Day"
|
||||||
const sanitizedClassName = eventText.replace(/[^a-zA-Z0-9-]/g, '').replace(/\s+/g, '-').toLowerCase();
|
const extraDescription = document.getElementById('event-extra-description');
|
||||||
eventDescription.classList.add(sanitizedClassName); // Set sanitized class name based on event name
|
if (dateKey === '2025-05-04') {
|
||||||
|
extraDescription.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
extraDescription.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
eventDetails.classList.add('active'); // Show sidebar
|
eventDetails.classList.add('active'); // Show sidebar
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,5 +301,3 @@
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<div class="Gay Day">hi mom</div>
|
|
||||||
<p class="Gay Day">hi mom</p>
|
|
||||||
+2
-2
@@ -149,12 +149,12 @@
|
|||||||
// Make the title visible
|
// Make the title visible
|
||||||
const title = document.querySelector('h1');
|
const title = document.querySelector('h1');
|
||||||
if (title) {
|
if (title) {
|
||||||
title.style.opacity = '1';
|
title.style.opacity = '1'; // Ensure the title is fully visible
|
||||||
title.style.transform = 'none';
|
title.style.transform = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make all buttons visible
|
// Make all buttons visible
|
||||||
const buttons = document.querySelectorAll('.button, .calendar-button');
|
const buttons = document.querySelectorAll('.button, .calendar-button, .button-container');
|
||||||
buttons.forEach(button => {
|
buttons.forEach(button => {
|
||||||
button.style.opacity = '1'; // Ensure the button is fully visible
|
button.style.opacity = '1'; // Ensure the button is fully visible
|
||||||
button.style.transform = 'none'; // Reset any transform styles
|
button.style.transform = 'none'; // Reset any transform styles
|
||||||
|
|||||||
Reference in New Issue
Block a user