Skip to content

Instantly share code, notes, and snippets.

@IvanofSA
Created August 5, 2020 11:36
Show Gist options
  • Save IvanofSA/446957bc6686b7c4904304f9e0973d7b to your computer and use it in GitHub Desktop.
Save IvanofSA/446957bc6686b7c4904304f9e0973d7b to your computer and use it in GitHub Desktop.
add class
const scroll = fromEvent(window, 'scroll');
scroll.subscribe(showSection);
function showSection() {
const sectionObs = section => {
const interSection = new IntersectionObserver(entrie => {
entrie[0].intersectionRatio > 0.15 ?
!section.classList.contains('active') && section.classList.add('active')
: section.classList.remove('active');
});
interSection.observe(section);
};
forEach(sectionObs, sectionsForAnimate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment