Created
August 5, 2020 11:36
-
-
Save IvanofSA/446957bc6686b7c4904304f9e0973d7b to your computer and use it in GitHub Desktop.
add class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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