diff --git a/TODO.md b/TODO.md index 648850a..1a5b4d6 100644 --- a/TODO.md +++ b/TODO.md @@ -33,7 +33,6 @@ - [Feat] [Payload] Endpoints should provide a simple text-based version of the content (for OG purposes) - [Feat] [WebManifest] Add shortcuts https://web.dev/patterns/web-apps/shortcuts - [Feat] [PWA] Rich install UI https://web.dev/patterns/web-apps/richer-install-ui/ -- [Feat] Try using CSS instead of JS for parallax effect - [Feat] More data caching between the CMS and Astro - [Feat] [Folders] Support for nameless section - [Feat] [Scripts] Can't run the scripts using node (ts-node?) diff --git a/src/components/AppLayout/components/AppLayoutBackgroundImg.astro b/src/components/AppLayout/components/AppLayoutBackgroundImg.astro index 2ebeee2..fa908e8 100644 --- a/src/components/AppLayout/components/AppLayoutBackgroundImg.astro +++ b/src/components/AppLayout/components/AppLayoutBackgroundImg.astro @@ -20,19 +20,20 @@ const uniqueId = getRandomId(); {/* ------------------------------------------- HTML ------------------------------------------- */} - +
+ +
{/* ------------------------------------------- CSS -------------------------------------------- */} @@ -46,42 +47,59 @@ const uniqueId = getRandomId(); } } - img { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: -9999; + @keyframes parallax { + from { + transform: translateY(0); + } + to { + transform: translateY(calc((100cqb - 100lvh) * var(--parallax-amount))); + } + } + + div { + container-type: size; + position: absolute; + inset: 0; + z-index: -9999; + overflow: hidden; + + animation: fadeIn 3s forwards; + } + + img { width: 100%; max-height: 100%; + min-height: 100lvh; object-fit: cover; object-position: 50% 0; - animation: fadeIn 3s forwards; - - @media (max-width: 650.5px) { - display: none; - } - mask-image: linear-gradient(to bottom, rgba(0 0 0 / 100%) min(50vh, 50%), transparent), - linear-gradient(to right, rgba(0 0 0 / 10%), rgba(0 0 0 / 20%) 640px, black 1200px); + linear-gradient(to right, rgba(0 0 0 / 20%) 640px, black 1200px); mask-composite: intersect; + + @supports (animation-timeline: scroll(root)) { + --parallax-amount: 0.4; + animation-name: parallax; + animation-timing-function: linear; + animation-timeline: scroll(root); + } } {/* ------------------------------------------- JS --------------------------------------------- */}