const carousels = document.querySelectorAll('.carousel');
carousels.forEach(carousel => {
const images = carousel.querySelectorAll('img');
const totalWidth = Array.from(images).reduce((sum, img) => sum + img.width + 20, 0); // 20 = 2 * margin (10px)
const containerWidth = carousel.parentElement.offsetWidth;
// Calculate animation duration based on the total width of images and container width
const duration = (totalWidth / containerWidth) * 2; // 20s is the base duration
const animationName = carousel.classList.contains('scroll-left') ? 'scroll-left' : 'scroll-right';
// Apply the new animation duration
carousel.style.animation = `${animationName} ${duration}s linear infinite`;
});
-->