Skip to content

Instantly share code, notes, and snippets.

@brayn003
Created May 8, 2020 16:04
Show Gist options
  • Save brayn003/ec48861fc229abbea3db8413906a9387 to your computer and use it in GitHub Desktop.
Save brayn003/ec48861fc229abbea3db8413906a9387 to your computer and use it in GitHub Desktop.
Wheeling code
window.addEventListener("wheel", event => {
const delta = Math.sign(event.deltaY);
//console.info(delta);
if (delta > 0) {
nextSection();
}
else if (delta < 0) {
previousSection();
}
});
const sections = document.querySelectorAll(".section");
let activeIndex = 0;
function nextSection() {
console.log('this', activeIndex)
if (activeIndex = sections.length) return;
let previousService = section[activeIndex - 1];
previousService.classList.add("previous");
let activeService = section[activeIndex];
activeService.classList.add("inView");
let nextService = section[activeIndex + 1];
nextService.classList.add("next");
activeIndex++;
//update the above variables
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment