/** * Minified by jsDelivr using Terser v5.39.0. * Original file: /gh/leo-mattar/egglife@master/assets/js/egglife-hero.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ document.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelector(".js-home-slider");void 0!==t&&null!=t&&(new homeHeroSlider).init()}));class homeHeroSlider{constructor(){this.header=document.querySelector(".c-header"),this.sliderTarget=document.querySelector(".js-home-slider"),this.titleTargets=document.querySelectorAll(".js-hero-slider__title"),this.titleWrapper=document.querySelector(".c-hero-slider__title-wrapper"),this.titleElement=document.querySelector(".js-hero-slider__title-element"),this.bgTargets=document.querySelectorAll(".js-hero-slider__bg"),this.sliderBg=document.querySelector(".js-hero-slider-bg"),this.bgColors=[],this.sliderTrasitionTarget=document.querySelector(".js-hero-slider-transition"),this.sliderTrasitionPlaceholderTarget=document.querySelector(".js-hero-slider-transition-placeholder"),this.sliderProductsTargets=document.querySelectorAll(".js-hero-slider__product"),this.sliderAnimateInTargets=document.querySelectorAll(".js-home-slider-animate-in"),this.sliderInstance=null,this.autoPlayTimer=5,this.playSpeed=0,this.tweenAnimations=1,this.manageResizeFn=null,this.tlSlidesStatus=null,this.tlLoad=null,this.ease="power3.inOut",this.easeSecondary="expo.out",this.firstInteraction=!0,this.isAnimating=!1,this.indexObject={current:0,next:1,prev:this.titleTargets.length-1},this.windowSize={width:window.innerWidth,height:window.innerHeight},this.resizeFn=null}init(){this.markupSetup(),this.attachListeners(),this.sliderStatus(),this.loadAnimation()}loadAnimation(){this.tlLoad=gsap.timeline({paused:!0,onStart:t=>{gsap.set(this.titleElement,{opacity:1})},onComplete:t=>{this.loadComplete(),gsap.set([this.sliderTrasitionTarget,this.sliderTrasitionPlaceholderTarget],{clearProps:"scale"}),gsap.set(this.sliderAnimateInTargets,{clearProps:"y"})}}),this.tlLoad.play();let t=this.titleElement.querySelectorAll(".c-hm-title");new SplitType(t,{types:"words",tagName:"span"});this.tlLoad.add("start").to(this.header,{y:0,duration:this.tweenAnimations,ease:this.ease},"start").fromTo(this.titleElement.querySelectorAll(".word"),{autoAlpha:0,yPercent:135},{autoAlpha:1,yPercent:0,duration:this.tweenAnimations,ease:this.easeSecondary,stagger:.05},"start").fromTo(this.sliderAnimateInTargets,{opacity:0,y:60},{opacity:1,y:0,duration:this.tweenAnimations,ease:this.easeSecondary,stagger:.2},"start+=0.5").fromTo([this.sliderTrasitionTarget,this.sliderTrasitionPlaceholderTarget],{scale:0,opacity:0},{scale:1,opacity:1,duration:this.tweenAnimations,ease:this.easeSecondary},"start+=0.3")}loadComplete(){document.querySelector(".c-body").classList.remove("no-scroll"),window.Scroll.start(),this.tlSlidesStatus.play()}markupSetup(){this.titleWrapper.style.position="relative";for(let t=0;t0&&(this.titleTargets[t].classList.remove("hide"),this.titleTargets[t].style.cssText="\n display: block; \n position: absolute;\n opacity: 0;\n ");this.setTitleWrapperWidth(this.titleTargets[0].querySelector(".t-display-2")),this.sliderBg.style.cssText="\n pointer-events: none; \n ";for(let t=0;t0&&(this.sliderProductsTargets[t].style.cssText="\n opacity: 0;\n pointer-events: none;\n ")}attachListeners(){window.addEventListener("resize",(()=>{this.windowSize={width:window.innerWidth,height:window.innerHeight}}),!0)}sliderStatus(){this.tlSlidesStatus=gsap.timeline({paused:!0,onStart:t=>{},onComplete:t=>{this.nextSlide()}}),this.tlSlidesStatus.fromTo(this.sliderTarget,{pointerEvents:"auto"},{pointerEvents:"auto",duration:this.autoPlayTimer}),this.tlSlidesStatus.play()}animateSlider(t,e){this.isAnimating=!0;const i=this.titleTargets[t],s=this.titleTargets[e],r=this.bgColors[t],a=this.bgColors[e],o=this.sliderProductsTargets[t],n=this.sliderProductsTargets[e],l=document.querySelectorAll("[home-title-wrap]");let d=2.5;this.windowSize.width<991&&(d=3),this.animateInTl=gsap.timeline({onStart:t=>{this.tlSlidesStatus.restart(),this.manageIndexObject(e),this.setTitleWrapperWidth(s.querySelector(".t-display-2")),e===this.titleTargets.length-1?gsap.to(l,{color:"white",duration:1.4,ease:this.easeSecondary}):0===e&&gsap.to(l,{color:"#521fcc",duration:1.6,ease:this.easeSecondary}),gsap.set(i,{opacity:1,yPercent:0,pointerEvents:"auto",position:"absolute"})},onComplete:t=>{this.isAnimating=!1,gsap.set(i,{display:"none",clearProps:"opacity, y"}),gsap.set(s.querySelectorAll(".word"),{clearProps:"opacity, y"}),gsap.set(i.querySelectorAll(".word"),{clearProps:"opacity, y"}),gsap.set(this.sliderTrasitionTarget,{clearProps:"all"}),this.firstInteraction&&(this.titleTargets[0].style.cssText="\n display: block; \n position: absolute;\n opacity: 0;\n ",this.firstInteraction=!1)}}),this.animateInTl.add("start").fromTo(i.querySelectorAll(".word"),{opacity:1,y:0},{opacity:0,y:-60,duration:this.tweenAnimations,ease:this.easeSecondary,stagger:.2},"start+=0.01").fromTo(s,{opacity:0,yPercent:100,pointerEvents:"none",display:"block",position:"relative"},{opacity:1,yPercent:0,pointerEvents:"auto",duration:this.tweenAnimations,ease:this.easeSecondary},"start+=0.3").fromTo(s.querySelectorAll(".word"),{opacity:0,y:20},{opacity:1,y:0,duration:this.tweenAnimations,ease:this.easeSecondary,stagger:.2},"start+=0.2").fromTo(this.sliderBg,{backgroundColor:r},{backgroundColor:a,duration:this.tweenAnimations,ease:this.ease},"start+=0.2").fromTo(this.sliderTrasitionTarget,{scale:1,transformOrigin:"center"},{scale:d,duration:this.tweenAnimations,ease:this.ease},"start+=0.1").fromTo(this.sliderTrasitionTarget,{opacity:1},{opacity:0,duration:this.tweenAnimations,ease:this.ease},"start+=0.4").fromTo(o,{opacity:1,yPercent:0,rotation:0},{opacity:0,yPercent:50,rotation:15,duration:1.5*this.tweenAnimations,ease:this.easeSecondary},"start+=0.1").fromTo(n,{opacity:0,yPercent:50,rotation:-15},{opacity:1,yPercent:0,rotation:0,duration:1.5*this.tweenAnimations,ease:this.easeSecondary},"start+=0.15")}manageIndexObject(t,e){e||(this.indexObject.current=t,t===this.titleTargets.length-1?this.indexObject.next=0:this.indexObject.next=t+1,0===this.indexObject.current?this.indexObject.prev=this.titleTargets.length-1:this.indexObject.prev=t-1)}nextSlide(){this.isAnimating||this.animateSlider(this.indexObject.current,this.indexObject.next)}setTitleWrapperWidth(t){let e=t.clientWidth,i=parseFloat((100*e/this.windowSize.width).toFixed(2));gsap.to(this.titleWrapper,{width:i+"vw",duration:this.tweenAnimations,ease:this.easeSecondary,delay:.2})}} //# sourceMappingURL=/sm/371bd69ed923695300181db17a023052cb499e4c24bf612b6aaed02d20368ce9.map