Přejít na obsah
akce
Výpis produktů
Ovládací prvky výpisu
18 položek celkem
(function () {
function fixSubcategories() {
var items = document.querySelectorAll('.subcategories li');
if (!items.length) return;
var w = window.innerWidth;
var width;
// desktop – 5
if (w >= 1200) {
width = '20%';
}
// tablet – 4
else if (w >= 768) {
width = '25%';
}
// mobil – 2
else {
width = '50%';
}
items.forEach(function (item) {
item.style.setProperty('width', width, 'important');
item.style.setProperty('float', 'left', 'important');
item.style.setProperty('box-sizing', 'border-box', 'important');
});
}
// hned po loadu
window.addEventListener('load', fixSubcategories);
// Classic často DOM přerenderuje → hlídáme změny
var observer = new MutationObserver(function () {
fixSubcategories();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// resize
window.addEventListener('resize', function () {
clearTimeout(window.__subcatResize);
window.__subcatResize = setTimeout(fixSubcategories, 150);
});
})();