The concept is straightforward - within your main HTML, you have anchors that correspond to icons in a menu list.
When an anchor becomes visible as the user scrolls, all other menu items are deactivated while the connected one is activated.
Your task is to determine which anchor is currently in view when the user scrolls. You can utilize external libraries such as InView library or create your own function to track window scrolling events.
The basic structure of your code should resemble the following:
//Main scroll listener
window.addEventListener("scroll", checkAnchors);
function checkAnchors(){
//Check for visibility of all anchors and identify the currently visible one
if (visibleAnchor) {
triggerMenu(visibleAnchor);
}
}
function triggerMenu(visibleAnchor) {
//Deactivate all menu items and activate the one linked to the visibleAnchor
}