You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
2.9 KiB
1 lines
2.9 KiB
import"./modulepreload-polyfill.js";function x(){const r=document.querySelector(".banner-section__swiper"),i=document.querySelector(".banner-section__pause-btn"),t=i?i.querySelector("img"):null;if(!r||typeof Swiper>"u")return;const s=new Swiper(r,{loop:!0,speed:800,autoplay:{disableOnInteraction:!1}});if(!i||!t||!s.autoplay)return;const e="assets/images/pause.png",o="assets/images/play.png";let a=!1;const u=()=>{t.src=a?o:e,t.alt=a?"播放":"暂停",i.setAttribute("aria-label",a?"播放轮播":"暂停轮播")};i.addEventListener("click",()=>{a=!a,a?s.autoplay.stop():s.autoplay.start(),u()}),u()}function g(){const r=parseFloat(getComputedStyle(document.documentElement).fontSize);return(Number.isFinite(r)?r:16)*.625}function _(){const r=document.querySelector(".section-2__cards-swiper");if(!r||typeof Swiper>"u")return;const i="section-2__card--expanded",t=$(r).find(".section-2__card");if(!t.length)return;const s=window.matchMedia("(min-width: 993px)");let e=null,o=null;function a(n){if(!e)return;const c=e.slides[n];if(!c)return;const d=c.getBoundingClientRect(),w=e.el.getBoundingClientRect(),h=6;(d.left<w.left-h||d.right>w.right+h)&&e.slideTo(n,Math.min(450,e.params.speed))}const u={prev:2,next:3};function f(n){const c=n.target;c instanceof HTMLElement&&(!c.classList.contains("swiper-slide")||n.propertyName!=="width"||e&&(clearTimeout(o),o=setTimeout(()=>{o=null,e.update();const d=t.index(t.filter("."+i).first());d>=0&&a(d)},60)))}function S(){e||!s.matches||(e=new Swiper(r,{slidesPerView:"auto",spaceBetween:g(),slidesPerGroup:2,watchSlidesProgress:!0,watchOverflow:!0,observer:!0,observeParents:!0,resizeObserver:!0}),r.addEventListener("transitionend",f))}function b(){e&&(r.removeEventListener("transitionend",f),clearTimeout(o),o=null,e.destroy(!0,!0),e=null)}function p(){s.matches?(e||S(),e&&(e.params.spaceBetween=g(),e.update())):b()}function l(n){t.removeClass(i),n.addClass(i),e&&requestAnimationFrame(()=>{e.update()})}function v(){l(t.first())}if(t.filter("."+i).length||v(),p(),e){const n=t.index(t.filter("."+i).first());requestAnimationFrame(()=>{e.update(),n>=0&&a(n)})}t.on("mouseenter",function(){s.matches&&l($(this))}),t.on("click",function(n){if(s.matches&&e){if(n.target.closest(".section-2__card-arrow, .section-2__plus-btn"))return;const c=t.index(this);if(c===u.prev){e.slidePrev();return}if(c===u.next){e.slideNext();return}return}l($(this))});function m(){if(p(),e){const n=t.index(t.filter("."+i).first());requestAnimationFrame(()=>{e.update(),n>=0&&a(n)})}}window.addEventListener("resize",m),s.addEventListener("change",m)}function E(){const r=window.counterUp.default,i=s=>{s.forEach(e=>{const o=e.target;e.isIntersecting&&!o.classList.contains("is-visible")&&(r(o,{duration:1e3,delay:16}),o.classList.add("is-visible"))})},t=new IntersectionObserver(i,{threshold:1});document.querySelectorAll(".counter").forEach(s=>{t.observe(s)})}function y(){x(),_(),E()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y();
|