Skip to content

Commit

Permalink
fix animation range
Browse files Browse the repository at this point in the history
  • Loading branch information
gvao committed Nov 15, 2023
1 parent 20c8c39 commit 36b46ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/scripts/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 36b46ba

Please sign in to comment.