<li><a href="" class="menu_icon_1"><span class="home"></span><i>Главная</i></a></li>
<li class="parent catalog-dropdown"><a href="" class="menu_icon_2"><span class="hamburger hamburger-animate"><span></span><span></span><span></span></span>Каталог</a>
<ul class="sub_menu">
...
</ul>
</li>
document.addEventListener("DOMContentLoaded", onDOMReady);
function onDOMReady() {
window.addEventListener('scroll', onWindowScroll)
var menu = document.getElementById('menu');
function onWindowScroll() {
if(window.document.scrollingElement.scrollTop > 150 && menu.classList.contains("default")){
menu.classList.remove("default")
menu.classList.add("fixed");
}
else {
menu.classList.remove("fixed")
menu.classList.add("default");
}
}
}
function onDOMReady() {
window.addEventListener('scroll', onWindowScroll)
}
function onWindowScroll() {
if(window.document.scrollingElement.scrollTop.scrollTop > 150 && menu.classList.contains("default")){
menu.classList.remove("default")
menu.classList.add("fixed");
}
else(window.document.scrollingElement.scrollTop.scrollTop <= 150 && menu.classList.contains("fixed")){
menu.classList.remove("fixed")
menu.classList.add("default");
}
}
var flkty1 = false;
var flkty2 = false;
function resizeScreen(){
if (window.innerWidth <= 991 && !flkty1){
console.log('INIT once time');
flkty1 = new Flickity('.main-carousel-1', {
initialIndex:0,
cellAlign:'center',
friction:0.4,
resize:true,
contain:false,
freeScroll:false,
wrapAround:false,
prevNextButtons:false,
pageDots:true,
percentPosition:true,
watchCSS:false,
});
} else if(window.innerWidth > 991 && flkty1) {
console.log('DESTROY once time');
flkty1.destroy();
flkty1 = false;
}
if (window.innerWidth <= 575 && !flkty2){
console.log('INIT once time');
flkty2 = new Flickity('.main-carousel-2', {
initialIndex:0,
cellAlign:'center',
friction:0.4,
resize:true,
contain:false,
freeScroll:false,
wrapAround:false,
prevNextButtons:false,
pageDots:true,
percentPosition:true,
watchCSS:false,
});
} else if(window.innerWidth > 575 && flkty2) {
console.log('DESTROY once time');
flkty2.destroy();
flkty2 = false;
}
}
resizeScreen();
window.addEventListener('resize', resizeScreen);