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,CACT,GAAC,CAAAR,IAAA,eAAAC,MAED,WACE,IAAIS,EAAOhC,KACX,IAAIiC,SAAS,CACXC,QAASF,EAAKnC,cACdsC,QAAS,SAASC,GACXJ,EAAKf,kBACU,SAAdmB,GACFR,YAAW,WACTI,EAAK5B,YAAYiC,UAAUC,IAAI,UAC/BN,EAAK5B,YAAYS,MAAMC,iBAAmB,GAAHC,OAAMiB,EAAKpB,iBAAgB,MAClEoB,EAAKb,gBAAgBoB,SAAQ,SAAA7B,GAC3BsB,EAAKQ,eAAe9B,EACtB,GACF,GAAG+B,SAAST,EAAKlC,OAAO4C,QAE1BV,EAAKf,iBAAkB,EAG3B,EACA0B,OAAQ,kBAEZ,M,oEAAC/C,CAAA,CA5Ec,E","sources":["webpack:///./resources/js/components/generic/progress-bar.ts"],"sourcesContent":["import * as $ from \"jquery\";\nimport \"waypoints/lib/jquery.waypoints.js\";\n\nclass ProgressBar {\n componentRoot: JQuery<HTMLElement>;\n params: any;\n percentContainer: JQuery<HTMLElement>;\n progressBar?: HTMLElement;\n progressBarLength: any;\n percent: number;\n percentToAnimate: number;\n hasAnimationRun: boolean;\n animationSpeed: number;\n uiPercentsArray: any[];\n\n constructor (componentRoot: HTMLElement, params) {\n this.componentRoot = $(componentRoot);\n this.params = { ...params };\n\n this.percentContainer = $('.component--progress-bar__percent', this.componentRoot);\n this.progressBar = document.getElementById(this.params.progressBarId) as HTMLElement;\n this.progressBarLength = this.progressBar.getTotalLength();\n this.percent = Number(this.params.percent);\n this.percentToAnimate = this.progressBarLength * ((100 - this.percent) / 100);\n this.progressBar.style.strokeDashoffset = `${this.progressBarLength}px`;\n this.progressBar.style.strokeDasharray = `${this.progressBarLength}px`;\n this.hasAnimationRun = false;\n this.animationSpeed = 1000; // this is tied to CSS value\n this.uiPercentsArray = this.makePercentsArray(this.percent);\n this.init();\n }\n\n init () {\n this.updatePercent(0);\n this.bottomInView();\n }\n\n iteratePercent (count: number) {\n setTimeout(() => {\n this.updatePercent(count);\n }, (this.animationSpeed / this.percent) * count);\n }\n\n updatePercent (percent: number) {\n this.percentContainer.text(`${percent}%`);\n }\n\n makePercentsArray () {\n let percentArray = [];\n for (var count = 0; count <= this.percent; count += 1) {\n percentArray.push(count);\n }\n if (this.percent % 1 !== 0) {\n percentArray.push(this.percent);\n }\n return percentArray;\n }\n\n bottomInView () {\n var self = this;\n new Waypoint({\n element: self.componentRoot as any,\n handler: function(direction) {\n if (!self.hasAnimationRun) {\n if (direction === 'down') {\n setTimeout(() => {\n self.progressBar.classList.add('active');\n self.progressBar.style.strokeDashoffset = `${self.percentToAnimate}px`;\n self.uiPercentsArray.forEach(percent => {\n self.iteratePercent(percent);\n });\n }, parseInt(self.params.delay));\n }\n self.hasAnimationRun = true;\n }\n\n },\n offset: 'bottom-in-view'\n });\n }\n}\n\nexport default ProgressBar;\n"],"names":["ProgressBar","componentRoot","params","_classCallCheck","this","$","_objectSpread","percentContainer","progressBar","document","getElementById","progressBarId","progressBarLength","getTotalLength","percent","Number","percentToAnimate","style","strokeDashoffset","concat","strokeDasharray","hasAnimationRun","animationSpeed","uiPercentsArray","makePercentsArray","init","key","value","updatePercent","bottomInView","count","_this","setTimeout","text","percentArray","push","self","Waypoint","element","handler","direction","classList","add","forEach","iteratePercent","parseInt","delay","offset"],"sourceRoot":""}