Newer
Older
pre-www / src / assets / js / vendor / swiper / modules / effect-creative.min.mjs
import{c as createShadow}from"../shared/create-shadow.min.mjs";import{e as effectInit}from"../shared/effect-init.min.mjs";import{e as effectTarget}from"../shared/effect-target.min.mjs";import{e as effectVirtualTransitionEnd}from"../shared/effect-virtual-transition-end.min.mjs";import{l as getSlideTransformEl}from"../shared/utils.min.mjs";function EffectCreative(e){let{swiper:t,extendParams:r,on:s}=e;r({creativeEffect:{limitProgress:1,shadowPerProgress:!1,progressMultiplier:1,perspective:!0,prev:{translate:[0,0,0],rotate:[0,0,0],opacity:1,scale:1},next:{translate:[0,0,0],rotate:[0,0,0],opacity:1,scale:1}}});const a=e=>"string"==typeof e?e:`${e}px`;effectInit({effect:"creative",swiper:t,on:s,setTranslate:()=>{const{slides:e,wrapperEl:r,slidesSizesGrid:s}=t,i=t.params.creativeEffect,{progressMultiplier:o}=i,l=t.params.centeredSlides;if(l){const e=s[0]/2-t.params.slidesOffsetBefore||0;r.style.transform=`translateX(calc(50% - ${e}px))`}for(let r=0;r<e.length;r+=1){const s=e[r],n=s.progress,c=Math.min(Math.max(s.progress,-i.limitProgress),i.limitProgress);let f=c;l||(f=Math.min(Math.max(s.originalProgress,-i.limitProgress),i.limitProgress));const m=s.swiperSlideOffset,p=[t.params.cssMode?-m-t.translate:-m,0,0],d=[0,0,0];let h=!1;t.isHorizontal()||(p[1]=p[0],p[0]=0);let g={translate:[0,0,0],rotate:[0,0,0],scale:1,opacity:1};c<0?(g=i.next,h=!0):c>0&&(g=i.prev,h=!0),p.forEach(((e,t)=>{p[t]=`calc(${e}px + (${a(g.translate[t])} * ${Math.abs(c*o)}))`})),d.forEach(((e,r)=>{let s=g.rotate[r]*Math.abs(c*o);t.browser&&t.browser.isSafari&&Math.abs(s)/90%2==1&&(s+=.001),d[r]=s})),s.style.zIndex=-Math.abs(Math.round(n))+e.length;const w=p.join(", "),y=`rotateX(${d[0]}deg) rotateY(${d[1]}deg) rotateZ(${d[2]}deg)`,M=f<0?`scale(${1+(1-g.scale)*f*o})`:`scale(${1-(1-g.scale)*f*o})`,u=f<0?1+(1-g.opacity)*f*o:1-(1-g.opacity)*f*o,v=`translate3d(${w}) ${y} ${M}`;if(h&&g.shadow||!h){let e=s.querySelector(".swiper-slide-shadow");if(!e&&g.shadow&&(e=createShadow("creative",s)),e){const t=i.shadowPerProgress?c*(1/i.limitProgress):c;e.style.opacity=Math.min(Math.max(Math.abs(t),0),1)}}const E=effectTarget(i,s);E.style.transform=v,E.style.opacity=u,g.origin&&(E.style.transformOrigin=g.origin)}},setTransition:e=>{const r=t.slides.map((e=>getSlideTransformEl(e)));r.forEach((t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach((t=>{t.style.transitionDuration=`${e}ms`}))})),effectVirtualTransitionEnd({swiper:t,duration:e,transformElements:r,allSlides:!0})},perspective:()=>t.params.creativeEffect.perspective,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}export{EffectCreative as default};
//# sourceMappingURL=effect-creative.min.mjs.map