define("/Assets/enp/v2/js/ebg-module/ebg-module-tab-industry.js", ["/Assets/enp/v2/js/vendor/swiper-5.3.6.min.js"], function (s, pub) { var winW = $(window).width(); function initTabIndustry($target) { // 20220713 zwx270868 此模板移动端出现了多个tab的时候,没法左右滚动 // 现在模板结构没法改变,只能通过js给html添加结构 // 给.head添加父级div,class=head-box $('.ebg-module-tab-industry .box .head').wrap("
"); // 因.industry 这个class名字跟其他模板有冲突,现在删除这个class $('.ebg-module-tab-industry .industry').removeClass('industry'); if (winW < 992) { var headW = 0; $target.find('.con .box .head li').each(function () { headW += $(this).outerWidth(true); }); $target.find('.con .box .head').width(headW + 1); } var slidesPerView = 0; if (winW > 992) { slidesPerView = 1.5 } else if (winW > 992) { slidesPerView = 1.3 } else { slidesPerView = 1.09 } var lazyInxed = 0; var slideLength = $target.find(".swiper-slide").length; var mySwiper = new Swiper($target.find(".swiper-container"), { navigation: { // 设置左右箭头 nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, pagination: { // 设置点点点 el: '.swiper-pagination', }, grabCursor: slideLength > 1 ? true : false, simulateTouch: (winW > 750 ? false : true), // 设置pc端不能用鼠标左右滑动 autoplay: $target.data("auto-time") ? { delay: $target.data("auto-time"), stopOnLastSlide: false, disableOnInteraction: true } : false, loop: slideLength > 1 ? true : false, // 设置自动轮播 noSwiping: slideLength > 1 ? false : true, runCallbacksOnInit: true, slidesPerView: slidesPerView, roundLengths: true, effect: 'coverflow', //3d滑动 centeredSlides: true, coverflowEffect: { rotate: 0, stretch: 0, depth: 200, modifier: 1, slideShadows: true }, on: { init: function (swiper) { $target.find('.con .head li').on('click', function (e) { e.stopPropagation(); mySwiper.slideToLoop($(this).index(), 400, false); }) }, transitionStart: function () { // 左右轮播后,锁定当前tab的高亮。 $target.find('.con .box .head li').eq(this.realIndex).addClass('hover').siblings().removeClass('hover'); // 滚动条也随着左右滚动变换位置,保持高亮在最中间位置。 if (this.realIndex != lazyInxed) { $target.find('.con .box .head-box').animate({ 'scrollLeft': $target.find('.con .box .head li').eq(this.realIndex).offset().left + $target.find('.con .box .head-box').scrollLeft() - 15 - winW / 2 + $target.find('.con .box .head li').eq(this.realIndex).outerWidth() / 2 }); lazyInxed = this.realIndex; } } } }); } //模块数据 var moduleData = { init: function () { $(".ebg-module-tab-industry").each(function () { var $this = $(this); if ($this.data("swiper-init")) { return; } $this.data("swiper-init", true); initTabIndustry($this) }); } } // 元素被swiper删除重新添加了,把之前的事件删除了,需要重新添加懒加载 $(window).on('scroll.industry', function () { var scrollTop = $(window).scrollTop() + $(window).height(); var boxTop = $('.ebg-module-tab-industry').offset().top; if (scrollTop > boxTop) { var lazyLazy = new LazyLoad({ elements_selector: ".J-ebg-replace-img-lazyload", data_src: "original", }); // 处理小图标懒加载 $('.ebg-module-tab-industry .box .head li').each(function () { $(this).find('img').each(function () { $(this).attr('src', $(this).attr('data-original')) }) }) $(window).unbind('scroll.industry'); } }) return moduleData; });