$(document).ready(function () { // **************************** // main visual // 텍스트효과 function animateSlideText(slide, directionOut = false) { gsap.fromTo($(slide).find('.slide-text'), { opacity: 0, x: directionOut ? 0 : -50 }, { opacity: directionOut ? 0 : 1, x: directionOut ? 50 : 0, duration: directionOut ? 0.3 : 0.6, stagger: 0.15, ease: "power2.out" } ); } var swiper1 = new Swiper("#main_visual .s1Swiper", { loop: true, speed: 1000, // navigation: { // nextEl: ".s1Swiper_arrow .swiper-button-next", // prevEl: ".s1Swiper_arrow .swiper-button-prev", // }, autoplay: { delay: 3000, disableOnInteraction: false, }, on: { init: function () { animateSlideText(this.slides[this.activeIndex]); }, slideChangeTransitionStart: function () { animateSlideText(this.slides[this.activeIndex], true); }, slideChangeTransitionEnd: function () { animateSlideText(this.slides[this.activeIndex]); } } }); // **************************** // 의료진소개 팝업 $(document).on('click', '.modal-open', function (e) { e.preventDefault(); $('#' + $(this).data('modal')).addClass('open'); }); $(document).on('click', '.modal-overlay', function (e) { if ($(e.target).is('.modal-overlay')) $(this).removeClass('open'); }); $(document).on('click', '.modal-close', function () { $(this).closest('.modal-overlay').removeClass('open'); }); $(document).on('keydown', function (e) { if (e.key === 'Escape') $('.modal-overlay.open').removeClass('open'); }); // ============================== // 병원소개 장비 슬라이드 var swiper2 = new Swiper("#section1 .mySwiper", { loop: true, slidesPerView: 1, spaceBetween: 30, speed: 1000, // navigation: { // nextEl: ".s7Swiper_arrow .swiper-button-next", // prevEl: ".s7Swiper_arrow .swiper-button-prev", // }, autoplay: { delay: 3000, disableOnInteraction: false, }, pagination: { el: '.pagination1', clickable: true, }, zoom: true }); // 카운터 const counterEl = document.querySelector('.counter'); if (counterEl) { const target = parseInt(counterEl.textContent.replace(/,/g, '')); const duration = 1500; let started = false; const counterObserver = new IntersectionObserver(([entry]) => { if (entry.isIntersecting && !started) { started = true; const start = performance.now(); const tick = (now) => { const elapsed = Math.min((now - start) / duration, 1); const val = Math.floor(elapsed * target); counterEl.textContent = val.toLocaleString(); if (elapsed < 1) requestAnimationFrame(tick); else counterEl.textContent = target.toLocaleString(); }; requestAnimationFrame(tick); } }, { threshold: 0.5 }); counterObserver.observe(counterEl); } // ============================== // 진료과목 슬라이드 var swiper2 = new Swiper("#section2 .mySwiper", { loop: true, slidesPerView: 1, spaceBetween: 30, speed: 500, // navigation: { // nextEl: ".s7Swiper_arrow .swiper-button-next", // prevEl: ".s7Swiper_arrow .swiper-button-prev", // }, autoplay: { delay: 3000, disableOnInteraction: false, }, pagination: { el: '.pagination2', clickable: true, }, effect: 'fade', fadeEffect: { crossFade: true }, }); // ============================== // ============================== // ============================== // ============================== const navLinks = $('header nav > ul > li a'); const currentPath = window.location.pathname; // 서브페이지 on 처리 navLinks.each(function () { const href = $(this).attr('href'); if (!href) return; if (!href.includes('#') && currentPath.includes(href)) { navLinks.removeClass('on'); $(this).addClass('on'); } }); // notice, price 서브페이지 아니면 IntersectionObserver 실행 if (!currentPath.includes('notice') && !currentPath.includes('price')) { const sections = document.querySelectorAll('section[id]'); const observer = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { navLinks.removeClass('on'); navLinks.filter('[href*="#' + entry.target.id + '"]').addClass('on'); } }); }, { threshold: 0.3 }); sections.forEach(function (section) { observer.observe(section); }); } });