Raffales-LMS/public/raffels/assets/js/counterup.min.js

1 line
890 B
JavaScript
Raw Permalink Normal View History

2024-04-16 09:58:24 +00:00
!function(t){"use strict";t.fn.counterUp=function(e){var n=t.extend({time:400,delay:10},e);return this.each(function(){var e=t(this),u=n;e.waypoint({offset:"100%",handler:function(){var t=[],n=u.time/u.delay,a=e.text(),r=/[0-9]+,[0-9]+/.test(a);a=a.replace(/,/g,"");/^[0-9]+$/.test(a);for(var o=/^[0-9]+\.[0-9]+$/.test(a),c=o?(a.split(".")[1]||[]).length:0,s=n;s>=1;s--){var d=parseInt(a/n*s);if(o&&(d=parseFloat(a/n*s).toFixed(c)),r)for(;/(\d+)(\d{3})/.test(d.toString());)d=d.toString().replace(/(\d+)(\d{3})/,"$1,$2");t.unshift(d)}e.data("counterup-nums",t),e.text("0");e.data("counterup-func",function(){e.text(e.data("counterup-nums").shift()),e.data("counterup-nums").length?setTimeout(e.data("counterup-func"),u.delay):(e.data("counterup-nums"),e.data("counterup-nums",null),e.data("counterup-func",null))}),setTimeout(e.data("counterup-func"),u.delay),this.destroy()}})})}}(jQuery);