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,WAAM,OAAAlD,Q","sources":["webpack://app-counter2/./src/ts/index.ts"],"sourcesContent":["var winAny = window as any;\r\nwinAny.appCounter2 ??= {};\r\nwinAny.appCounter2.init ??= initAppCounter2;\r\nwinAny.appCounter2.domIds ??= [];\r\n\r\nfunction initAppCounter2({ domId } : { domId: string }) {\r\n winAny.appCounter2.domIds.push(domId);\r\n checkCounters();\r\n}\r\n\r\nwindow.addEventListener('scroll', () => checkCounters());\r\n\r\nfunction checkCounters() {\r\n winAny.appCounter2.domIds\r\n .forEach((domId: string) => {\r\n Array.from(document.getElementsByClassName(domId))\r\n .forEach((counter: HTMLElement) => {\r\n if (!counter.classList.contains('app-counter2-js-seen') && isElementInViewport(counter)) {\r\n startCounter(counter, counter.getAttribute('data-count'), 2000);\r\n counter.classList.add('app-counter2-js-seen')\r\n }\r\n });\r\n });\r\n}\r\n\r\nfunction isElementInViewport (counter: HTMLElement) {\r\n var rect = counter.getBoundingClientRect();\r\n\r\n return (\r\n rect.top >= 0 &&\r\n rect.left >= 0 &&\r\n rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\r\n rect.right <= (window.innerWidth || document.documentElement.clientWidth)\r\n );\r\n}\r\n\r\nfunction startCounter(counter: any, lastVal: any, duration: any) {\r\n let startTime: any = Date.now();\r\n const step = () => {\r\n //calculate the value to be used in calculating the number to be displayed\r\n const progress = Math.min((Date.now() - startTime) / duration, 1);\r\n //calculate what to be displayed using the value gotten above\r\n counter.innerHTML = commify(Math.floor(progress * lastVal));\r\n // counter.innerHTML = Math.floor(progress * lastVal).toLocaleString('de-DE');\r\n //checking to make sure the counter does not exceed the last value (lastVal)\r\n if (progress < 1) window.requestAnimationFrame(step);\r\n else window.cancelAnimationFrame(window.requestAnimationFrame(step));\r\n };\r\n\r\n window.requestAnimationFrame(step);\r\n}\r\n\r\nfunction commify(n: number) {\r\n var parts = n.toString().split(\".\");\r\n const numberPart = parts[0];\r\n const decimalPart = parts[1];\r\n const thousands = /\\B(?=(\\d{3})+(?!\\d))/g;\r\n return numberPart.replace(thousands, \"'\") + (decimalPart ? \".\" + decimalPart : \"\");\r\n}"],"names":["winAny","window","checkCounters","appCounter2","domIds","forEach","domId","Array","from","document","getElementsByClassName","counter","classList","contains","rect","getBoundingClientRect","top","left","bottom","innerHeight","documentElement","clientHeight","right","innerWidth","clientWidth","isElementInViewport","lastVal","duration","startTime","Date","now","step","n","parts","numberPart","decimalPart","thousands","progress","Math","min","innerHTML","floor","toString","split","replace","requestAnimationFrame","cancelAnimationFrame","startCounter","getAttribute","add","init","push","addEventListener"],"sourceRoot":""}