# easy-elements/1.3.5/widgets/counter/js/counter.js

Easy Elements for Elementor – Addons &amp; Website Templates, version 1.3.5. 66 lines.

- Page: https://pluginprobe.com/plugins/easy-elements/1.3.5/code/widgets/counter/js/counter.js
- Raw: https://pluginprobe.com/plugins/easy-elements/1.3.5/raw/widgets/counter/js/counter.js
- Modified: 2026-02-18T10:50:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-elements/1.3.5/code/widgets/counter/js/counter.js#L10-L20`.

```javascript
(function ($) {
    "use strict";

   function eelRunCounter($scope) {
      const counters = $scope.find(".eel-counter");
      if (!counters.length) return;

      const observer = new IntersectionObserver(entries => {
         entries.forEach(entry => {
               if (!entry.isIntersecting) return;

               const counter = entry.target;
               observer.unobserve(counter);

               const target = parseInt(counter.dataset.count, 10) || 0;
               const duration = parseInt(counter.dataset.duration, 10) || 1000;
               const format = counter.dataset.format || "default";

               let current = 0;
               const startTime = performance.now();

               function formatNumber(num) {
                  if (num < 1000) return num;

                  const groups = num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, {
                     comma: ",",
                     dot: ".",
                     space: " ",
                     underline: "_"
                  }[format] || "");

                  return format === "underline" ? `${groups}` : groups;
               }

               function animate(time) {
                  const progress = Math.min((time - startTime) / duration, 1);
                  current = Math.floor(progress * target);

                  if (format === "underline") {
                     counter.innerHTML = formatNumber(current);
                  } else {
                     counter.textContent = formatNumber(current);
                  }

                  if (progress < 1) requestAnimationFrame(animate);
               }

               requestAnimationFrame(animate);
         });
      }, { threshold: 0.2 });

      counters.each(function () {
         observer.observe(this);
      });
   }

   $(window).on("elementor/frontend/init", function () {
      elementorFrontend.hooks.addAction("frontend/element_ready/widget", function ($scope) {
         if ($scope.find(".eel-counter").length) {
               eelRunCounter($scope);
         }
      });
   });

})(jQuery);

```
