document.addEventListener('DOMContentLoaded', function () {
'use strict';
var prevScrollpos = window.pageYOffset;
var sectionInfo = document.querySelector('.header__section-info').getBoundingClientRect().top + window.pageYOffset;
var headerOneELement = document.querySelector('.header__section-navbar');
window.addEventListener('scroll', function () {
var currentScrollpos = window.pageYOffset;
// fixedHeader on scroll
function fixedHeader() {
if (currentScrollpos > sectionInfo) {
headerOneELement.classList.add('fix');
headerOneELement.classList.remove('scroll-up');
document.querySelector('.page__header').style.marginBottom = headerOneELement.offsetHeight + 'px';
if (currentScrollpos < prevScrollpos) {
headerOneELement.classList.add('scroll-up');
}
} else {
headerOneELement.classList.remove('fix');
headerOneELement.classList.remove('scroll-up');
document.querySelector('.page__header').style.marginBottom = '0';
}
prevScrollpos = currentScrollpos;
}
fixedHeader();
});
});
Что это такое?