Reset gallery position on variation change
This commit is contained in:
parent
7b2be1d62f
commit
0715146e89
|
@ -565,6 +565,7 @@
|
|||
|
||||
window.setTimeout( function() {
|
||||
$( 'body' ).trigger( 'woocommerce_init_gallery' );
|
||||
$( 'body' ).trigger( 'woocommerce_gallery_reset_slide_position' );
|
||||
$( window ).trigger( 'resize' );
|
||||
}, 10 );
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -125,6 +125,10 @@ jQuery( function( $ ) {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'woocommerce_gallery_reset_slide_position', function(){
|
||||
$( '.woocommerce-product-gallery' ).flexslider( 0 );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&wc_single_product_params.flexslider_enabled&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled&&this.init_photoswipe()},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:wc_single_product_params.flexslider.animationLoop,start:function(){var b=a(".woocommerce-product-gallery__image"),c=0;b.each(function(){var b=a(this).height();b>c&&(c=b)}),b.each(function(){a(this).css("min-height",c)})}})},init_zoom:function(){var b=a(".woocommerce-product-gallery__image"),c=!1;wc_single_product_params.flexslider_enabled||(b=b.first()),a(b).each(function(b,d){var e=a(d).find("img");if(e.attr("width")>a(".woocommerce-product-gallery").width())return c=!0,!1}),c&&(b.trigger("zoom.destroy"),b.zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){wc_single_product_params.zoom_enabled&&(a(".woocommerce-product-gallery--with-images").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>'),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe)),a(document).on("click",".woocommerce-product-gallery__image a",this.trigger_photoswipe)},trigger_photoswipe:function(c){c.preventDefault();var d,e=a(".pswp")[0],f=b.get_gallery_items(),g=a(c.target);d=g.is(".woocommerce-product-gallery__trigger")?g.parents(".woocommerce-product-gallery").find(".flex-active-slide"):c.target.closest("figure");var h={index:a(d).index(),shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},i=new PhotoSwipe(e,PhotoSwipeUI_Default,f.items,h);i.init()}};b.init()});
|
||||
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&wc_single_product_params.flexslider_enabled&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled&&this.init_photoswipe()},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:wc_single_product_params.flexslider.animationLoop,start:function(){var b=a(".woocommerce-product-gallery__image"),c=0;b.each(function(){var b=a(this).height();b>c&&(c=b)}),b.each(function(){a(this).css("min-height",c)})}}),a("body").on("woocommerce_gallery_reset_slide_position",function(){a(".woocommerce-product-gallery").flexslider(0)})},init_zoom:function(){var b=a(".woocommerce-product-gallery__image"),c=!1;wc_single_product_params.flexslider_enabled||(b=b.first()),a(b).each(function(b,d){var e=a(d).find("img");if(e.attr("width")>a(".woocommerce-product-gallery").width())return c=!0,!1}),c&&(b.trigger("zoom.destroy"),b.zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){wc_single_product_params.zoom_enabled&&(a(".woocommerce-product-gallery--with-images").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>'),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe)),a(document).on("click",".woocommerce-product-gallery__image a",this.trigger_photoswipe)},trigger_photoswipe:function(c){c.preventDefault();var d,e=a(".pswp")[0],f=b.get_gallery_items(),g=a(c.target);d=g.is(".woocommerce-product-gallery__trigger")?g.parents(".woocommerce-product-gallery").find(".flex-active-slide"):c.target.closest("figure");var h={index:a(d).index(),shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},i=new PhotoSwipe(e,PhotoSwipeUI_Default,f.items,h);i.init()}};b.init()});
|
Loading…
Reference in New Issue