From ea97b60d493a2379ac32a8c224a39046056aece2 Mon Sep 17 00:00:00 2001 From: Maximus80 Date: Tue, 21 Feb 2017 09:11:39 +0100 Subject: [PATCH] fix product gallery lightbox trigger --- assets/js/frontend/single-product.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index a3da1c52c15..3cc0f758f23 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -198,10 +198,14 @@ jQuery( function( $ ) { var pswpElement = $( '.pswp' )[0], items = wc_product_gallery.get_gallery_items(), target = $( e.target ), - index = -1; + index = -1, + clicked; if ( ! target.is( '.woocommerce-product-gallery__trigger' ) ) { - var clicked = e.target.closest( 'figure' ); + clicked = e.target.closest( 'figure' ); + index = $( clicked ).index(); + } else { + clicked = target.parents( '.woocommerce-product-gallery' ).find( '.flex-active-slide' ); index = $( clicked ).index(); }