(function ($, Drupal, settings) { "use strict"; // setInterval(() => { // const elements = document.querySelectorAll('.block-fronthistory1 .block-title-wrapper .licheng-jiantou .iconfont'); // elements.forEach((element, index) => { // setTimeout(() => { // element.style.color = 'rgba(255,255,255,1)'; // }, index * 100); // setTimeout(() => { // element.style.color = 'rgba(255,255,255,0.1)'; // }, (index + 1) * 200); // }); // }, 1500); var transform; Drupal.behaviors.frontHistory1 = { attach: function (context) { $(context).find(".front-history1 .owl-carousel").once("front-history1").each(function () { // var owlSetting = $(this).data('settings'); // if (!owlSetting) { // return // } var owl = $('.front-history1 .owl-carousel').owlCarousel({ margin: 0, loop: false, autoplayTimeout:4200, autoplay: false, dotsEach: 1, navRewind: false, nav: false, dots:false, autoplayHoverPause:true, mouseDrag:false, responsive: { 0: { items: 2, }, 768: { items: 2, }, 1024: { items: 3, }, 1400: { items: 3, }, 1604: { items: 3, } } }); var winWidth = window.outerWidth; var itemLen = $('.front-history.front-history1 .owl-carousel .owl-item').length; var currentItem = 0; var fontLen = $(".block-fronthistory1 .block-title-wrapper .licheng-jiantou").length; var fontArr = $(".block-fronthistory1 .block-title-wrapper .licheng-jiantou .iconfont"); var fontIndex = 0; firstDonghuaChange(); $('.block-fronthistory1 .block-title-wrapper .licheng-jiantou').on('click', function () { donghuaChange(); }); setInterval(function (){ donghuaChange(); },2000) function firstDonghuaChange(){ var first_liwidth =$('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).width(); var first_liwidth2d = first_liwidth / 2; var first_offset = $('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).offset().left; var first_hewidth = (first_offset + first_liwidth2d); $(".front-history.front-history1 .curr_xian").css("transform", "translate3d(" + first_hewidth + "px, 0px, 0px) scaleX(-150) scaleY(1)"); $(".block-fronthistory1 .block-title-wrapper .licheng-jiantou .iconfont").eq(fontIndex).addClass('active'); } function donghuaChange(){ fontIndex++; if(fontIndex === 3){ fontIndex = 0; } $(".block-fronthistory1 .block-title-wrapper .licheng-jiantou .iconfont").eq(fontIndex).addClass('active'); $(".block-fronthistory1 .block-title-wrapper .licheng-jiantou .iconfont").eq(fontIndex).siblings().removeClass("active"); currentItem++; if(currentItem > itemLen-1){ currentItem=0; owl.trigger('to.owl.carousel',0,0); setTimeout(function (){ firstDonghuaChange(); },1000) return; } if(winWidth>768){ if(currentItem<3){ owl.trigger('next.owl.carousel'); } if(currentItem>2){ var liwidth =$('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).width(); var liwidth2d = liwidth / 2 var offset = $('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).offset().left; var hewidth = (offset + liwidth2d); $(".front-history.front-history1 .curr_xian").css("transform", "translate3d(" + hewidth + "px, 0px, 0px) scaleX(-150) scaleY(1)"); } }else if(winWidth <= 768){ if(currentItemitemLen-2){ var liwidth2 =$('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).width(); var liwidth2d2 = liwidth2 / 2 var offset2 = $('.front-history.front-history1 .owl-carousel .owl-item').eq(currentItem).offset().left; var hewidth2 = (offset2 + liwidth2d2); $(".front-history.front-history1 .curr_xian").css("transform", "translate3d(" + hewidth2 + "px, 0px, 0px) scaleX(-150) scaleY(1)"); } } } owl.on('translated.owl.carousel', function (event) { }) }) } }; })(jQuery, Drupal, drupalSettings);