Last active
May 14, 2020 10:12
-
-
Save kamlesh08/000b328651038e5ce82308f2bee4bfd3 to your computer and use it in GitHub Desktop.
JS for compatibility issues with WooPack Product Carousel & Woo Variation Gallery and Woo Variation Swatches.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (mutation.attributeName === 'class') { | |
if ( $(mutation.target).hasClass('woopack-ajax-loaded') ) { | |
if ( $('.woopack-modal-content .woo-variation-gallery-wrapper').length > 0 ) { | |
$('.woopack-modal-content .woo-variation-gallery-wrapper').WooVariationGallery(); | |
} | |
if ( $('.woopack-modal-content .variations_form').length > 0 ) { | |
$('.woopack-modal-content .variations_form').WooVariationSwatches(); | |
} | |
} | |
} | |
}); | |
}); | |
observer.observe($('.woopack-modal')[0], { | |
attributes: true | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment