From 79a042a35b5863df148d3a9606d6581716848062 Mon Sep 17 00:00:00 2001 From: Ryan Feigenbaum Date: Mon, 10 Jul 2023 13:56:20 -0400 Subject: [PATCH] tweaksville population you --- assets/css/components/card.css | 2 +- assets/js/app/app.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/assets/css/components/card.css b/assets/css/components/card.css index 26b4d684..e3bda4e7 100644 --- a/assets/css/components/card.css +++ b/assets/css/components/card.css @@ -285,6 +285,6 @@ } } -.fade-in { +.sm-observed { opacity: 1; } diff --git a/assets/js/app/app.js b/assets/js/app/app.js index cf784b78..f910b612 100644 --- a/assets/js/app/app.js +++ b/assets/js/app/app.js @@ -33,16 +33,19 @@ function animateOnScroll() { entries.forEach((entry) => { const el = entry.target; const ratio = entry.intersectionRatio; + + if (ratio > 0.5) { + // remove from observation + el.classList.add('sm-observed'); + observer.unobserve(el); + } + const calculatedRatio = (num) => { - if (num < 0.1) { + if (num < 0.25) { return 0; } - if (num > 0.6) { - return 1; - } - - return num; + return 1; }; el.style.opacity = calculatedRatio(ratio); });