From 18fcf6dd83709beccc45c68a68b8091fe4798b0c Mon Sep 17 00:00:00 2001 From: saicaca Date: Mon, 28 Oct 2024 03:19:25 +0800 Subject: [PATCH] fix: fix blurry text caused by `translate` --- src/layouts/Layout.astro | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 0d807db..f00273e 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -109,7 +109,7 @@ const bannerOffset = /> ))} - @@ -160,7 +165,6 @@ const bannerOffset = bannerOffset, 'banner-height-home': `${BANNER_HEIGHT_HOME}vh`, 'banner-height': `${BANNER_HEIGHT}vh`, - 'banner-height-extend': `${BANNER_HEIGHT_EXTEND}vh` }}> @tailwind components; @layer components { @@ -459,6 +463,13 @@ function scrollFunction() { } window.onscroll = scrollFunction +// calculate the --banner-height-extend, which needs to be a multiple of 4 to avoid blurry text +window.onresize = () => { + let offset = Math.floor(window.innerHeight * (BANNER_HEIGHT_EXTEND / 100)); + offset = offset - offset % 4; + document.documentElement.style.setProperty('--banner-height-extend', `${offset}px`); +} +