(function (win, doc) { $(doc).ready(function () { if ($('.home__banner')) { new Swiper('.home__banner', { loop: true, effect: 'fade', autoplay: { delay: 5000 }, pagination: { el: '.swiper-pagination', clickable: true } }) } if ($('.home__news')) { if ($('.news-swiper')) { new Swiper('.home__news .news-swiper', { loop: true, autoplay: { delay: 5000 }, pagination: { el: '.swiper-pagination', clickable: true } }) } if ($('.news-view')) { var _newsSwiper = new Swiper('.home__news .news-view', { on: { slideChangeTransitionStart: function() { $('.news-view .tab').eq(this.activeIndex).addClass('active').siblings().removeClass('active') } } }) $('.news-view .tab').hover(function () { _newsSwiper.slideTo($(this).index()) }) } } if ($('.home__service .service-main__swiper')) { var _serSwiper = new Swiper('.service-main__swiper', { slidesPerView: $(doc).width() >= 1200 ? 4 : 2, spaceBetween: $(doc).width() >= 1200 ? 40 : 10 }) $('.service-main__prev').on('click', function () { _serSwiper.slidePrev() }) $('.service-main__next').on('click', function () { _serSwiper.slideNext() }) } if ($('.home__about .about-news')) { var _aboutSwiper = new Swiper('.home__about .about-news', { on: { slideChangeTransitionStart: function() { $('.about-news .tab').eq(this.activeIndex).addClass('active').siblings().removeClass('active') } } }) $('.about-news .tab').hover(function () { _aboutSwiper.slideTo($(this).index()) }) } if ($('.home__project .project-main')) { var width = 560 var main = $('.home__project .project-main') var itemLen = $(doc).width() > 1200 ? main.find('.project-main__item').length : 3 var itemWidth = main.width() / itemLen main.find('.project-main__item').each(function (e, v) { if ($(doc).width() <= 1200) { if (e > 2) $(v).hide() } $(v).css('width', itemWidth + 'px').on('mouseenter', function () { if ($(doc).width() < 1200) return $(this).addClass('active') $(this).css('width', width + 'px') $(this).siblings().css('width', ((main.width() - width) / (itemLen - 1)) + 'px') }).on('mouseleave', function () { $(this).removeClass('active') main.find('.project-main__item').css('width', itemWidth + 'px') }) }) } }) })(window, document)