Created
October 25, 2019 01:40
-
-
Save socmia/69fba84eeed145919fcc1e1067f61424 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
document.addEventListener("scroll", scrollHandler, true); | |
function scrollHandler() { | |
currentScrollPosition = document.documentElement.scrollTop; | |
for (var i=1; i<=positionArray.length; i++){ | |
if (currentScrollPosition>=positionArray[i-1] && currentScrollPosition < positionArray[i]) { | |
var currentActive = document.getElementsByClassName('is-active')[0]; | |
if (currentActive != undefined){ | |
currentActive.classList.remove('is-active'); | |
} | |
quickLinks[i-1].classList.add('is-active'); | |
break; | |
} | |
if (currentScrollPosition>positionArray[positionArray.length-1]){ | |
var currentActive = document.getElementsByClassName('is-active'); | |
var currentActive = document.getElementsByClassName('is-active')[0]; | |
if (currentActive != undefined){ | |
currentActive.classList.remove('is-active'); | |
} | |
quickLinks[quickLinks.length-1].classList.add('is-active'); | |
break; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment