( function( d, w, $ ) { 'use strict'; /* fixed category nav */ // $(function () { // $(window).on("scroll", function () { // if($(window).scrollTop() > 100) { // $('.nav-fixed').addClass('is-show'); // } else { // $('.nav-fixed').removeClass('is-show'); // } // }); // }); /* modal window and slider */ $(function(){ var open = $('.modal-open'), close = $('.modal-close'), container = $('.modal-container'), slider = $('.items-slider'); var funcSlider = function(){ slider.slick({ infinite: true, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, pauseOnHover: false, pauseOnFocus: false, speed: 1000, arrows: false, dots: true, }); }; // modal open and slick start open.on('click',function(){ $(this).next(container).addClass('is-active'); $('body').addClass('modal-active'); funcSlider(); //slick start return false; }); // modal close and slick end close.on('click',function(){ container.removeClass('is-active'); $('body').removeClass('modal-active'); setTimeout(function(){ slider.slick('unslick'); //slick end }, 300 ); }); $(document).on('click',function(e) { if(!$(e.target).closest('.modal-body').length) { container.removeClass('is-active'); $('body').removeClass('modal-active'); setTimeout(function(){ slider.slick('unslick'); //slick end }, 300 ); } }); }); /* fadein animation */ $(window).on('load scroll', function(){ $('.scroll-fadein').each(function () { var thisOffset = $(this).offset().top; var scrollPos = $(window).scrollTop(); var wh = $(window).height(); if(scrollPos > thisOffset - wh + (wh / 5)){ $(this).addClass('is-active'); } }); }); // const swiper = new Swiper(".swiper", { // loop: true, // // ページネーション // pagination: { // el: ".swiper-pagination", // clickable: true, // }, // // 前後の矢印 // navigation: { // nextEl: ".swiper-button-next", // prevEl: ".swiper-button-prev", // }, // }); $(function () { var swiper = new Swiper('.swiper', { loop: true, // 無限ループ autoplay: { delay: 4000, // 自動再生の間隔(ミリ秒) disableOnInteraction: false, // ユーザー操作後も自動再生を続ける }, speed: 1000, // スライド遷移速度(ミリ秒) pagination: { el: '.swiper-pagination', // ページネーションの要素 clickable: true, // クリックでスライド切り替え }, navigation: { nextEl: '.swiper-button-next', // 次のボタン prevEl: '.swiper-button-prev', // 前のボタン }, breakpoints: { 501: { slidesPerView: 3, // PCでは3枚表示 spaceBetween: 16, // スライド間の間隔 }, 0: { slidesPerView: 1, // スマホでは1枚表示 spaceBetween: 8, // スライド間の間隔 }, }, }); }); $(document).ready(function () { var open = $('.modal-open'), close = $('.modal-close'), container = $('.modal-container'), slider = $('.items-slider'); var isSlickInitialized = false; // モーダル内のスライダー初期化関数 var funcSlider = function () { if (!isSlickInitialized) { setTimeout(function () { // 表示後に初期化 slider.slick({ infinite: true, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, pauseOnHover: false, pauseOnFocus: false, speed: 1000, arrows: false, dots: true, }); isSlickInitialized = true; }, 100); // モーダル表示後のタイミングを確保 } }; // モーダルを開く処理 open.on('click', function (e) { e.preventDefault(); var targetId = $(this).data('modal-id'); // `data-modal-id` 属性から対象のモーダルIDを取得 $('#' + targetId).addClass('is-active'); // 対象のモーダルに `is-active` クラスを付与 $('body').addClass('modal-active'); // 背景スクロールを無効化 funcSlider(); // スライダーを初期化 }); // モーダルを閉じる処理 close.on('click', function () { container.removeClass('is-active'); // モーダルの `is-active` クラスを削除 $('body').removeClass('modal-active'); // 背景スクロールを有効化 setTimeout(function () { if (isSlickInitialized) { slider.slick('unslick'); // スライダーの終了処理 isSlickInitialized = false; } }, 300); }); // モーダル外をクリックして閉じる処理 $(document).on('click', function (e) { if (!$(e.target).closest('.modal-body').length && !$(e.target).closest('.modal-open').length) { container.removeClass('is-active'); // モーダルの `is-active` クラスを削除 $('body').removeClass('modal-active'); // 背景スクロールを有効化 setTimeout(function () { if (isSlickInitialized) { slider.slick('unslick'); // スライダーの終了処理 isSlickInitialized = false; } }, 300); } }); }); } )( document, window, jQuery );