Skip to content

Commit

Permalink
tweaksville population you
Browse files Browse the repository at this point in the history
  • Loading branch information
royalfig committed Jul 10, 2023
1 parent 1e3814b commit 79a042a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/css/components/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,6 @@
}
}

.fade-in {
.sm-observed {
opacity: 1;
}
15 changes: 9 additions & 6 deletions assets/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 79a042a

Please sign in to comment.