Is there a way to make this javascript function active only when the screen width is at least 1070px? Currently, I have two different headers for screens smaller than 1070px, causing padding to be added regardless of the presence of "navbar_top". Can media queries solve this issue?
window.addEventListener('scroll', function() {
if (window.scrollY > 190) {
document.getElementById('navbar_top').classList.add('fixed-top');
} else {
document.getElementById('navbar_top').classList.remove('fixed-top');
document.body.style.paddingTop = 170 + 'px';
}
});