const targetNavbarDesktop = document.querySelector('.targetNavbarDesktop');
const fixedNavbarDesktop = document.querySelector('.fixedNavbar');
const obFixedNavbarDesktop = new IntersectionObserver(obCallbackDesktop);
function obCallbackDesktop(payload) {
if (document.documentElement.clientWidth > 992) {
if (payload[0].boundingClientRect.y < 0) {
document.querySelector('class1').style.marginBottom = fixedNavbarDesktop.offsetHeight + 'px';
fixedNavbarDesktop.classList.add('class2');
} else {
fixedNavbarDesktop.classList.remove('class2');
document.querySelector('class1').style.marginBottom = '0';
}
}
}
obFixedNavbarDesktop.observe(targetNavbarDesktop);
const targetNavbarMobile = document.querySelector('.targetNavbarMobile');
const fixedNavbarMobile = document.querySelector('.fixedNavbar');
const obFixedNavbarMobile = new IntersectionObserver(obCallbackMobile);
function obCallbackMobile(payload) {
if (document.documentElement.clientWidth < 992) {
if (payload[0].boundingClientRect.y < 0) {
document.querySelector('class1').style.marginBottom = fixedNavbarMobile.offsetHeight + 'px';
fixedNavbarMobile.classList.add('class3');
} else {
document.querySelector('class1').style.marginBottom = '0';
fixedNavbarMobile.classList.remove('class3');
}
}
}
obFixedNavbarMobile.observe(targetNavbarMobile);
const targetNavbarDesktop = document.querySelector('.targetNavbarDesktop');
const fixedNavbarDesktop = document.querySelector('.fixedNavbarDesktop');
const obFixedNavbarDesktop = new IntersectionObserver(obCallbackDesktop);
function obCallbackDesktop(payload) {
if (document.documentElement.clientWidth > 992) {
if (payload[0].boundingClientRect.y < 0) {
document.querySelector('.class1').style.marginBottom = fixedNavbarDesktop.offsetHeight + 'px';
fixedNavbarDesktop.classList.add('class2');
} else {
fixedNavbarDesktop.classList.remove('class2');
document.querySelector('.class1').style.marginBottom = '0';
}
}
}
obFixedNavbarDesktop.observe(targetNavbarDesktop);
const targetNavbarMobile = document.querySelector('.targetNavbarMobile');
const fixedNavbarMobile = document.querySelector('.fixedNavbarMobile');
const obFixedNavbarMobile = new IntersectionObserver(obCallbackMobile);
function obCallbackMobile(payload) {
if (document.documentElement.clientWidth < 992) {
if (payload[0].boundingClientRect.y < 0) {
document.querySelector('.class1').style.marginBottom = fixedNavbarMobile.offsetHeight + 'px';
fixedNavbarMobile.classList.add('class3');
} else {
document.querySelector('.class1').style.marginBottom = '0';
fixedNavbarMobile.classList.remove('class3');
}
}
}
obFixedNavbarMobile.observe(targetNavbarMobile);