Comment out active section highlighting

This commit is contained in:
Maciej Matuszewski 2018-01-13 20:08:25 +01:00
parent 437f0615eb
commit 2732540766
1 changed files with 14 additions and 14 deletions

View File

@ -18,25 +18,25 @@ function setActiveClassNames() {
});
}
function listenForActiveSection() {
const $sections = document.querySelectorAll(SECTION_SELECTOR);
const $header = document.querySelector(HEADER_SELECTOR);
// function listenForActiveSection() {
// const $sections = document.querySelectorAll(SECTION_SELECTOR);
// const $header = document.querySelector(HEADER_SELECTOR);
document.addEventListener('scroll', () => {
const scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
const $sectionsArray = [...$sections];
const $activeSections = $sectionsArray.filter(($section) => {
return $section.offsetTop <= scrollPosition + $header.offsetHeight;
});
// document.addEventListener('scroll', () => {
// const scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
// const $sectionsArray = [...$sections];
// const $activeSections = $sectionsArray.filter(($section) => {
// return $section.offsetTop <= scrollPosition + $header.offsetHeight;
// });
const $activeSection = $activeSections[$activeSections.length - 1];
// const $activeSection = $activeSections[$activeSections.length - 1];
history.pushState(undefined, undefined, `#${$activeSection.id}`);
});
}
// history.pushState(undefined, undefined, `#${$activeSection.id}`);
// });
// }
export default function init() {
listenForActiveSection();
// listenForActiveSection();
return new SmoothScroll(LINKS_SELECTOR, {
header: HEADER_SELECTOR,