feat: add fallback to run animations on switch
All checks were successful
test-build / guarddog (push) Successful in 21s
renovate / renovate (push) Successful in 58s
test-build / build (push) Successful in 1m51s

This commit is contained in:
2026-03-15 23:50:04 -05:00
parent f35c73b028
commit 954112e30e
2 changed files with 29 additions and 6 deletions

View File

@@ -19,8 +19,12 @@ const { forecastDays, error } = await getFiveDayForecast(latitude, longitude, ti
</div>
</div>
{error ? (
<div class="card-base p-10 text-accent text-center">
Sorry, {error.toLowerCase()}
<div class="smooth-reveal flex flex-wrap justify-center gap-4 lg:gap-6">
<div class="card-base flex flex-col justify-center items-center p-10 w-48 h-56">
<h1 class="card-text-header block text-accent text-center">
Sorry, {error.toLowerCase()}
</h1>
</div>
</div>
) : (
<div class="flex flex-wrap justify-center gap-4 lg:gap-6">

View File

@@ -93,7 +93,7 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
<!-- Footer -->
<Footer />
</main>
</div>
@@ -103,16 +103,34 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
<script>
import { initPhotoSwipe } from '@/scripts/photoswipe';
import { animateContent } from '@/scripts/animations';
const resetScroll = () => {
const scrollContainer = document.getElementById('reset-scroll');
if (scrollContainer) scrollContainer.scrollTop = 0;
};
resetScroll();
initPhotoSwipe();
animateContent();
const observer = new MutationObserver((mutations) => {
const hasNewNodes = mutations.some(
(mutation) => mutation.type === 'childList' && mutation.addedNodes.length > 0
);
if (hasNewNodes) {
animateContent();
if (typeof (window as any).HSStaticMethods !== 'undefined') {
(window as any).HSStaticMethods.autoInit();
}
}
});
const targetNode = document.getElementById('reset-scroll');
if (targetNode) {
observer.observe(targetNode, { childList: true, subtree: true });
}
document.addEventListener('swup:page:view', () => {
resetScroll();
initPhotoSwipe();
@@ -121,7 +139,7 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
(window as any).HSStaticMethods.autoInit();
}
if (typeof (window as any).rybbit === 'function') {
(window as any).rybbit('trackPageview');
(window as any).rybbit('trackPageview');
}
});
</script>
@@ -152,6 +170,7 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
/* Background that creates the "glimmer" effect */
.bg {
animation: slide 25s ease-in-out infinite alternate;
will-change: transform;
background-image: linear-gradient(-55deg, var(--bg-primary) 33.3%, var(--bg-secondary) 33.3%, var(--bg-secondary) 66.6%, var(--bg-tertiary) 66.6%);
filter: blur(40px);
top: 0;