(function ($) { $(function () { smoothScroll(); imageAutoSlideControl(); }); /********************************************* * * smoothScroll() * するするスクロール * data-smoothscroll="true" を付ける * * 固定ヘッダーの場合ヘッダーに * data-smoothscroll-fixed-header="true" を付ける * **********************************************/ function smoothScroll() { //特定のリンクをクリックしたら $('[data-smoothscroll="true"]').on('click', function () { var hash = $(this).attr('href'); if (hash === '#') { hash = 'html'; } scrollToAnchor(hash); return false; }); //別ページのページ内リンクに飛ぶ場合 var urlHash = location.hash; if(urlHash) { $('body,html').stop().scrollTop(0); $(window).on('load',function(){ setTimeout(function () { scrollToAnchor(urlHash); }, 100); }); } function scrollToAnchor(hash) { var $target = $(hash); var $fixedHeader = $('[data-smoothscroll-fixed-header="true"]'); var minusHeight = 0; var position = 0; if (!$target.length) { return false; } if ($fixedHeader.length) { minusHeight = $fixedHeader.outerHeight(); } position = $target.offset().top - minusHeight; $('body,html').stop().animate({ scrollTop: position }, 500); } } // ---------------------------------------------------- // accelvoiceスライドアニメーション // ---------------------------------------------------- function imageAutoSlideControl() { const imageSwiper = document.querySelector('.swiper_image'); if (!imageSwiper) return; // 対象がなければ何もしない new Swiper('.swiper_image', { loop: true, slidesPerView: 1, speed: 800, autoplay: { delay: 3000, disableOnInteraction: false, }, allowTouchMove: false, // 完全自動 }); } })(jQuery);