document.addEventListener('DOMContentLoaded', function () { const isPC = window.innerWidth > 768; const options = { perPage: 1, perMove: 1, type: "loop", autoplay: false, // ← 最初は止めておく interval: 6000, speed: 2000, arrows: true, pagination: true, pauseOnHover: false, pauseOnFocus: false, gap: 10, padding: { right: '35%' }, breakpoints: { 768: { perPage: 1, padding: "0%", gap: 0, }, }, }; // 各スライダーに対して処理 document.querySelectorAll('.fac-splide01').forEach((el) => { const splide = new Splide(el, options).mount(); // PC時のみ Intersection Observer で画面に入ったら再生 if (isPC) { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { splide.Components.Autoplay.play(); observer.unobserve(entry.target); // 一度だけ起動 } }); }, { threshold: 0.3 // 30%見えたら起動 }); observer.observe(el); } }); });