2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
"use strict";(()=>{(self.webpackChunkFalcon_theme=self.webpackChunkFalcon_theme||[]).push([[31],{7031:(b,m,f)=>{f.r(m),f.d(m,{default:()=>g});var h=f(9482);function g({swiper:t,extendParams:v,on:d}){v({controller:{control:void 0,inverse:!1,by:"slide"}}),t.controller={control:void 0};function T(a,i){const l=function(){let o,e,c;return(y,_)=>{for(e=-1,o=y.length;o-e>1;)c=o+e>>1,y[c]<=_?e=c:o=c;return o}}();this.x=a,this.y=i,this.lastIndex=a.length-1;let n,r;return this.interpolate=function(o){return o?(r=l(this.x,o),n=r-1,(o-this.x[n])*(this.y[r]-this.y[n])/(this.x[r]-this.x[n])+this.y[n]):0},this}function x(a){t.controller.spline=t.params.loop?new T(t.slidesGrid,a.slidesGrid):new T(t.snapGrid,a.snapGrid)}function E(a,i){const l=t.controller.control;let n,r;const s=t.constructor;function o(e){if(e.destroyed)return;const c=t.rtlTranslate?-t.translate:t.translate;t.params.controller.by==="slide"&&(x(e),r=-t.controller.spline.interpolate(-c)),(!r||t.params.controller.by==="container")&&(n=(e.maxTranslate()-e.minTranslate())/(t.maxTranslate()-t.minTranslate()),(Number.isNaN(n)||!Number.isFinite(n))&&(n=1),r=(c-t.minTranslate())*n+e.minTranslate()),t.params.controller.inverse&&(r=e.maxTranslate()-r),e.updateProgress(r),e.setTranslate(r,t),e.updateActiveIndex(),e.updateSlidesClasses()}if(Array.isArray(l))for(let e=0;e<l.length;e+=1)l[e]!==i&&l[e]instanceof s&&o(l[e]);else l instanceof s&&i!==l&&o(l)}function S(a,i){const l=t.constructor,n=t.controller.control;let r;function s(o){o.destroyed||(o.setTransition(a,t),a!==0&&(o.transitionStart(),o.params.autoHeight&&(0,h.Y3)(()=>{o.updateAutoHeight()}),(0,h.yV)(o.wrapperEl,()=>{n&&o.transitionEnd()})))}if(Array.isArray(n))for(r=0;r<n.length;r+=1)n[r]!==i&&n[r]instanceof l&&s(n[r]);else n instanceof l&&i!==n&&s(n)}function u(){t.controller.control&&t.controller.spline&&(t.controller.spline=void 0,delete t.controller.spline)}d("beforeInit",()=>{if(typeof window!="undefined"&&(typeof t.params.controller.control=="string"||t.params.controller.control instanceof HTMLElement)){const a=document.querySelector(t.params.controller.control);if(a&&a.swiper)t.controller.control=a.swiper;else if(a){const i=l=>{t.controller.control=l.detail[0],t.update(),a.removeEventListener("init",i)};a.addEventListener("init",i)}return}t.controller.control=t.params.controller.control}),d("update",()=>{u()}),d("resize",()=>{u()}),d("observerUpdate",()=>{u()}),d("setTranslate",(a,i,l)=>{!t.controller.control||t.controller.control.destroyed||t.controller.setTranslate(i,l)}),d("setTransition",(a,i,l)=>{!t.controller.control||t.controller.control.destroyed||t.controller.setTransition(i,l)}),Object.assign(t.controller,{setTranslate:E,setTransition:S})}}}]);})();
|