File "script.js"

Full path: /home/xs854402/smcse.co.jp/public_html/test.smcse.co.jp/wp-content/themes/Sumitomo-Mitsui/js/script.js
File size: 5.47 B (5.47 KB bytes)
MIME-type: text/plain
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

/* 読込完了後body表示 */
window.addEventListener('DOMContentLoaded', function() {
    $('body').css('opacity','1');
});

const swiper = new Swiper(".js-swiper", {
    speed: 600,
    loop: true,
    effect: 'fade',
    centeredSlides: true,
    spaceBetween: 30,
    autoplay: {
        delay: 4000,
        disableOnInteraction: true,
    },
    pagination: {
        el: ".fv-swiper-pagination",
        clickable: true,
        type: 'bullets'
    },
});

setTimeout(function (){
    new Swiper(".js-topSwiper", {
        speed: 1500,
        loop: true,
        effect: 'fade',
        autoplay: {
            delay: 4000,
            disableOnInteraction: true,
        },
    });
},1000);

const howtoSwiper = new Swiper(".js-howtoSwiper", {
    speed: 600,
    loop: true,
    centeredSlides: true,
    slidesPerView: 1,
    autoplay: {
        delay: 4000,
        disableOnInteraction: true,
    },
    // pagination: {
    //     el: ".howto-swiper-pagination",
    //     clickable: true,
    //     type: 'bullets'
    // },
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
    breakpoints: {
    // 768px以上
        768: {
            spaceBetween: 40,
            slidesPerView: 1.32,
        }
    },
});

const otherSwiper = new Swiper(".js-otherSwiper", {
    speed: 600,
    loop: true,
    centeredSlides: true,
    slidesPerView: 1,
    autoplay: {
        delay: 4000,
        disableOnInteraction: true,
    },
    pagination: {
        el: ".other-swiper-pagination",
        clickable: true,
        type: 'bullets'
    },
    breakpoints: {
    // 768px以上
        768: {
            spaceBetween: 20,
            slidesPerView: 3.48,
        }
    },
});

const interviewSwiper = new Swiper(".js-interviewSwiper", {
    speed: 600,
    loop: true,
    centeredSlides: true,
    slidesPerView: 1,
    autoplay: {
        delay: 4000,
        disableOnInteraction: true,
    },
    pagination: {
        el: ".interview-swiper-pagination",
        clickable: true,
        type: 'bullets'
    },
    breakpoints: {
    // 768px以上
        768: {
            loop: false,
            centeredSlides: false,
            autoplay: false,
            allowTouchMove: false,
            slidesPerView: 4,
        }
    },
});

const internshipSwiper = new Swiper(".js-internshipSwiper", {
    speed: 600,
    loop: true,
    centeredSlides: true,
    slidesPerView: 1,
    autoplay: {
        delay: 4000,
        disableOnInteraction: true,
    },
    pagination: {
        el: ".internship-swiper-pagination",
        clickable: true,
        type: 'bullets'
    },
    breakpoints: {
    // 768px以上
        768: {
            centeredSlides: false,
            slidesPerView: 3,
            spaceBetween: 40,
        }
    },
});

const buttons = document.querySelectorAll('.btn');

buttons.forEach((button) => {
    button.addEventListener('click', () => {
        const index = button.getAttribute('data-index');
        const targetBusiness = document.getElementById(`list-${index}`);
        if (targetBusiness.classList.contains('is-switch')) {
            return;
        }
        document.querySelectorAll('.is-switch').forEach(element => {
            element.classList.remove('is-switch');
        });
        targetBusiness.classList.add('is-switch');
        button.classList.add('is-switch');
    });
});

/* フェードイン */
$(window).scroll(function () {
    const windowHeight = $(window).height();
    const scroll = $(window).scrollTop();

    $('.u-fadein').each(function () {
        const targetPosition = $(this).offset().top;
        if (scroll > targetPosition - windowHeight + 100) {
            $(this).addClass("active");
        }
    });
});

jQuery(function ($) {

    var topBtn = $('.js-pagetop');
    topBtn.hide();

    /* トップに戻るボタン表示・動作設定 */
    $(window).scroll(function () {
        if ($(this).scrollTop() > 70) {
            topBtn.fadeIn();
        } else {
            topBtn.fadeOut();
        }
    });
    topBtn.click(function () {
        $('body,html').animate({
            scrollTop: 0
        }, 300, 'swing');
        return false;
    });

    /* ドロワーメニュー */
    const breakPoint = 767;
    if( breakPoint >= window.innerWidth){
        $('.js-hamburger').click(function () {
            $(this).toggleClass('open');
            $('.js-nav').toggleClass('open');
            $('.js-logo').toggleClass('open');
        });
        $('.js-nav').click(function () {
            $(this).toggleClass('open');
            $('.js-hamburger').toggleClass('open');
            $('.js-logo').toggleClass('open');
        });
    }

    /* モーダル */
    $('.js-modalOpen').click(function () {
        $(this).next('.js-modal').toggleClass('open');
    });
    $('.js-close').click(function () {
        $(this).parent().parent().parent().parent('.js-modal').toggleClass('open');
    });

    // アコーディオンメニュー
    $('.js-accordion').click(function () {
        $(this).toggleClass('active');
        $(this).next('dd').slideToggle();
        $(this).next('dd').toggleClass('open');
    });

    /* スムーススクロール */
    $(document).on('click', 'a[href*="#"]', function () {
        let time = 400;
        let header = $('header').innerHeight();
        let target = $(this.hash);
        if (!target.length) return;
        let targetY = target.offset().top - header;
        $('html,body').animate({ scrollTop: targetY }, time, 'swing');
        return false;
    });
});