Skip to content
document.addEventListener('DOMContentLoaded', function () {
// Only run if Vimeo Player API is available or can be loaded
function initVimeoSync() {
if (typeof Vimeo === 'undefined' || !Vimeo.Player) {
// Try to load the Vimeo player API if it's not present
var script = document.createElement('script');
script.src = 'https://player.vimeo.com/api/player.js';
script.onload = setupVimeoCarouselSync;
document.head.appendChild(script);
} else {
setupVimeoCarouselSync();
}
}
function setupVimeoCarouselSync() {
// Find all Vimeo iframes inside the specific carousel
var carousel = document.querySelector('.vimeo-sync-carousel');
if (!carousel) return;
var vimeoIframes = carousel.querySelectorAll('iframe[src*="vimeo.com"]');
if (!vimeoIframes.length) return;
// Create Vimeo player instances
var players = [];
vimeoIframes.forEach(function (iframe) {
try {
var player = new Vimeo.Player(iframe);
player.on('play', function () {
// Pause all OTHER players when this one starts playing
players.forEach(function (otherPlayer) {
if (otherPlayer !== player) {
otherPlayer.pause().catch(function () {
// Ignore errors (e.g., not ready yet)
});
}
});
});
players.push(player);
} catch (e) {
// silently ignore if something isn't a valid Vimeo iframe
}
});
}
initVimeoSync();
// In case Elementor loads content via AJAX (popups, etc.), re-run when DOM changes
document.addEventListener('elementor/popup/show', initVimeoSync);
});