jQuery(document).ready(function ($) {
setTimeout(function () {
const carousels = [
{ id: '#carousel-1' },
{ id: '#carousel-2' },
{ id: '#carousel-3' }
];
const options = {
root: null,
rootMargin: '0px',
threshold: 0.25
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
const $carouselSection = $(entry.target);
const $slickSlider = $carouselSection.find('.slick-slider');
if ($slickSlider.length) {
if (entry.isIntersecting) {
$slickSlider.slick('slickPlay');
} else {
$slickSlider.slick('slickPause');
}
}
});
}, options);
carousels.forEach(({ id }) => {
const section = document.querySelector(id);
if (section) observer.observe(section);
});
}, 500); // 500ms delay to let Elementor finish rendering
});