From 36b46ba1bdbf5faae57960ce826096e1ce30c616 Mon Sep 17 00:00:00 2001 From: Yuri Galvao Date: Wed, 15 Nov 2023 18:54:45 -0300 Subject: [PATCH] fix animation range --- src/scripts/animation.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scripts/animation.js b/src/scripts/animation.js index 61ef991..9aefb97 100644 --- a/src/scripts/animation.js +++ b/src/scripts/animation.js @@ -8,8 +8,9 @@ const showElementOnWindow = if (!type === "scroll") return; const { scrollY, innerHeight } = window; - const limit = scrollY + innerHeight * 0.5; - const percent = limit / offsetTop; + const limit = scrollY + innerHeight / 2; + const distance = offsetTop - limit; + const percent = 1 - distance / (innerHeight / 2) Array.from(children).forEach((child) => { child.style.opacity = 0;