{"version":3,"file":"animated-title-hero-banner-CMgyDiGQ.js","sources":["../../../../../../HFC.Optimizely.FrontEnd/src/scripts/modules/animated-title-hero-banner.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\ntype AnimationConfig = {\n duration: number;\n loop: number;\n};\n\nclass AnimatedTitleHeroBanner extends Component {\n setupDefaults() {\n this.dom = {\n titleImages: this.el.querySelectorAll('.images-container .title-image')\n };\n\n const loopCounter = Number(this.el.dataset.loop) || 3;\n\n if (this.el.dataset.bypass && this.el.dataset.bypass === 'true') return;\n\n this.initBanner(loopCounter);\n }\n\n addListeners() {}\n\n initBanner(numberOfLoops: number) {\n // this.resetBanner();\n const config: AnimationConfig = {\n duration: Number(this.el.dataset.transitionTime) || (3000 as number),\n loop: numberOfLoops\n };\n\n const titleImagesCount = (this.dom.titleImages as NodeList).length;\n const titleImages = this.dom.titleImages as NodeList;\n\n this.fadeTransition(config, titleImagesCount, titleImages);\n }\n\n fadeTransition(config: AnimationConfig, titleImagesCount: number, titleImages: NodeList) {\n // we want to set the active class on the second image in the array\n // by default the first image will already have the active class\n let counter = 1;\n const animationInterval = setInterval(() => {\n if (counter >= titleImagesCount) {\n clearInterval(animationInterval);\n (titleImages[titleImagesCount - 1] as HTMLImageElement).classList.remove('active');\n (titleImages[0] as HTMLImageElement).classList.add('active');\n this.finalAnimation(config.loop);\n } else {\n (titleImages[counter - 1] as HTMLImageElement).classList.remove('active');\n (titleImages[counter] as HTMLImageElement).classList.add('active');\n counter++;\n }\n }, config.duration as number);\n }\n\n finalAnimation(loop: number) {\n loop--;\n if (loop > 0) {\n this.initBanner(loop);\n }\n }\n}\n\nexport default AnimatedTitleHeroBanner;\n"],"names":["AnimatedTitleHeroBanner","Component","loopCounter","numberOfLoops","config","titleImagesCount","titleImages","counter","animationInterval","loop"],"mappings":"qCAOA,MAAMA,UAAgCC,CAAU,CAC9C,eAAgB,CACd,KAAK,IAAM,CACT,YAAa,KAAK,GAAG,iBAAiB,gCAAgC,CAAA,EAGxE,MAAMC,EAAc,OAAO,KAAK,GAAG,QAAQ,IAAI,GAAK,EAEhD,KAAK,GAAG,QAAQ,QAAU,KAAK,GAAG,QAAQ,SAAW,QAEzD,KAAK,WAAWA,CAAW,CAC7B,CAEA,cAAe,CAAC,CAEhB,WAAWC,EAAuB,CAEhC,MAAMC,EAA0B,CAC9B,SAAU,OAAO,KAAK,GAAG,QAAQ,cAAc,GAAM,IACrD,KAAMD,CAAA,EAGFE,EAAoB,KAAK,IAAI,YAAyB,OACtDC,EAAc,KAAK,IAAI,YAExB,KAAA,eAAeF,EAAQC,EAAkBC,CAAW,CAC3D,CAEA,eAAeF,EAAyBC,EAA0BC,EAAuB,CAGvF,IAAIC,EAAU,EACR,MAAAC,EAAoB,YAAY,IAAM,CACtCD,GAAWF,GACb,cAAcG,CAAiB,EAC9BF,EAAYD,EAAmB,CAAC,EAAuB,UAAU,OAAO,QAAQ,EAChFC,EAAY,CAAC,EAAuB,UAAU,IAAI,QAAQ,EACtD,KAAA,eAAeF,EAAO,IAAI,IAE9BE,EAAYC,EAAU,CAAC,EAAuB,UAAU,OAAO,QAAQ,EACvED,EAAYC,CAAO,EAAuB,UAAU,IAAI,QAAQ,EACjEA,IACF,EACCH,EAAO,QAAkB,CAC9B,CAEA,eAAeK,EAAc,CAC3BA,IACIA,EAAO,GACT,KAAK,WAAWA,CAAI,CAExB,CACF"}