document.addEventListener("DOMContentLoaded", function () {
if (window.matchMedia("(max-width: 767px)").matches) {
let slideshows = document.querySelectorAll(".ae-swiper-container"); // Bruk riktig klasse herlet observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
let swiperInstance = entry.target.swiper;
if (swiperInstance) {
if (entry.isIntersecting) {
swiperInstance.autoplay.start(); // Start autoplay når 75% er synlig
} else {
swiperInstance.autoplay.stop(); // Stopp autoplay når mindre enn 75% er synlig
}
}
});
}, { threshold: 0.75 }); // Trigger når 75% av elementet er synligslideshows.forEach((slideshow) => {
observer.observe(slideshow);
});
}
});