вот сделал, но как то немного тормозит, можно ли это оптимизировать?
$(window).resize(function() {
blockResize(".catalog_leader", ".catalog_item_card");
})
function blockResize(blockName, itemName) {
if ($(blockName).width() < 800) { //3 товара
$(blockName + " " + itemName).css("width", "33.3%");
$(blockName + " " + itemName).slice(3,6).hide();
}
if ($(blockName).width() < 1000 && $(blockName).width() >= 800) { //4 товаров
$(blockName + " " + itemName).css("width", "25%");
$(blockName + " " + itemName).slice(4,6).hide();
$(blockName + " " + itemName).slice(3,4).show();
}
if ($(blockName).width() < 1200 && $(blockName).width() >= 1000) { //5 товаров
$(blockName + " " + itemName).css("width", "20%");
$(blockName + " " + itemName).slice(5,6).hide();
$(blockName + " " + itemName).slice(3,5).show();
}
if ($(blockName).width() >= 1200) { //6 товаров
$(blockName + " " + itemName).css("width", "16.6%");
$(blockName + " " + itemName).slice(3,6).show();
}
}