I have the following function but the else if statement doesn't work properly, only the first one is working.
There's a function to switch between .grid and .grid-sm but this only makes the selected grid icon ative or inactive. It also changes on click..
Could you please give me any advice ? Thank you
function blockHover(status) {
var screenLg = $('body').find('.container').width() == 1170;
if ($('.product_list').is('.grid')){
$(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){
if (screenLg)
{
var pcHeight = $(this).parent().outerHeight();
var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
$(this).parent().addClass('hovered');
$(this).find('.button-container').show();
}
});
$(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){
if (screenLg)
{
$(this).parent().removeClass('hovered');
$(this).find('.button-container').hide();
}
});
} else if($('.product_list').is('.grid-sm')) {
$('.product_list .info-grid-sm').show();
$(document).off('mouseenter').on('mouseenter', '.grid-sm li.ajax_block_product.gr-sm .product-container', function(e){
if (screenLg)
{
var pcHeight = $(this).parent().outerHeight();
var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
$(this).parent().addClass('hovered');
$(this).find('.info-grid-sm').removeClass('hide');
}
});
$(document).off('mouseleave').on('mouseleave', '.grid-sm li.ajax_block_product.gr-sm .product-container', function(e){
if (screenLg)
{
$(this).parent().removeClass('hovered');
$(this).find('.info-grid-sm').addClass('hide');
}
});
}
}
Aucun commentaire:
Enregistrer un commentaire