document.addEventListener("DOMContentLoaded", function () { // Pageable 초기화 new Pageable("main", { animation: 400, events: { mouse: false }, onFinish: function () { const hash = window.location.hash; const header = document.querySelector(".header"); const iframes = document.querySelectorAll("iframe"); if (hash === '#page-1') { header.style.background = "none"; iframes[0]?.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); } else { header.style.background = "#87cde5"; iframes[0]?.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*'); } } }); // 영상 버튼 클릭 시 재생/일시정지 const videoBtn = document.querySelector(".video-btn"); if (videoBtn) { videoBtn.addEventListener("click", function () { const isPaused = videoBtn.classList.contains("pause"); videoBtn.classList.toggle("pause", !isPaused); const command = isPaused ? "playVideo" : "pauseVideo"; document.querySelectorAll("iframe").forEach(iframe => { iframe.contentWindow.postMessage(`{"event":"command","func":"${command}","args":""}`, '*'); }); }); } // YouTube 팝업 $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({ disableOn: 700, type: 'iframe', mainClass: 'mfp-fade', removalDelay: 160, preloader: false, fixedContentPos: false }); // 포트폴리오 노출 제한 (모바일/PC 구분) $(".info .portfolio .popup-youtube").slice(0, 6).show(); $(".info.mo .portfolio .popup-youtube").slice(0, 3).show(); // 슬라이더 $('.bxslider').bxSlider({ pager: true, infiniteLoop: false, controls: false }); // 슬라이드 수동 제어 let slideIndex = 1; showSlides(slideIndex); window.plusSlides = function(n) { showSlides(slideIndex += n); }; window.currentSlide = function(n) { showSlides(slideIndex = n); }; function showSlides(n) { const slides = document.getElementsByClassName("y-Slides"); if (slides.length === 0) return; if (n > slides.length) slideIndex = 1; if (n < 1) slideIndex = slides.length; Array.from(slides).forEach(slide => slide.style.display = "none"); slides[slideIndex - 1].style.display = "block"; } });