Last active
September 27, 2021 12:56
-
-
Save dsturm/bc53191c89b307c6f0c3f9cdd92e4fa3 to your computer and use it in GitHub Desktop.
Elementor
This file contains hidden or 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 ($) { | |
$(document).on("elementor/popup/show", function (event, popupId, popup) { | |
var gformWrapper = $(".gform_wrapper", popup.$element); | |
if (!gformWrapper.length) { | |
return; | |
} | |
var gformId = ("" + gformWrapper.first().attr("id")).replace( | |
/^gform_wrapper_/, | |
"" | |
); | |
if (!gformId.trim()) { | |
return; | |
} | |
$(document).trigger("gform_post_render", [gformId, 1]); | |
}); | |
})(window.jQuery); |
This file contains hidden or 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 testimonialCarousels = document.querySelectorAll( | |
".elementor-widget-testimonial-carousel .swiper-container" | |
); | |
if (!testimonialCarousels.length) { | |
// No testimonial carousel detected. | |
return; | |
} | |
var setSlideStyles = function setSlideStyles(swiper) { | |
var currentSlideIndex = swiper.activeIndex; | |
var actualHeight = swiper.slides[currentSlideIndex].clientHeight; | |
swiper.slides[currentSlideIndex].style.height = "min-content"; | |
swiper.wrapperEl.style.height = actualHeight + "px"; | |
swiper.update(); | |
}; | |
var mutationObserver = new MutationObserver(function (entries, observer) { | |
return entries.forEach(function (entry) { | |
if (entry.attributeName !== "class") { | |
// Just observe class changes. | |
return; | |
} | |
if (!entry.target.classList.contains("swiper-container-initialized")) { | |
// Not initialized yet. | |
return; | |
} | |
setSlideStyles(entry.target.swiper); | |
entry.target.swiper.on("slideChange", function () { | |
setSlideStyles(this); | |
}); | |
}); | |
}); | |
// Adjust height on resize. | |
var resizeObserver = new ResizeObserver(function (entries) { | |
entries.forEach(function (entry) { | |
if (entry.target.classList.contains("swiper-container-initialized")) { | |
setSlideStyles(entry.target.swiper); | |
} | |
}); | |
}); | |
// Initialize. | |
testimonialCarousels.forEach(function (carousel) { | |
// Fix transition for height. | |
carousel.querySelector(".swiper-wrapper").style.transitionProperty = | |
"transform, height"; | |
// Initialize observer. | |
mutationObserver.observe(carousel, { | |
attributes: true, | |
}); | |
resizeObserver.observe(carousel); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment