jquery.counterup.min.js 1.0 KB

123456789
  1. /*
  2. * jquery.counterup.js 1.0
  3. *
  4. * Copyright 2013, Benjamin Intal http://gambit.ph @bfintal
  5. * Released under the GPL v2 License
  6. *
  7. * Date: Nov 26, 2013
  8. */
  9. !function(a){a.fn.counterUp=function(b){var c=a.extend({time:400,delay:10},b);return this.each(function(){var f=a(this),g=c,d=function(){for(var u=[],l=g.time/g.delay,e=f.data("num"),p=/[0-9]+,[0-9]+/.test(e),m=(/^[0-9]+$/.test(e),/^[0-9]+\.[0-9]+$/.test(e)),h=m?(e.split(".")[1]||[]).length:0,j=l;j>=1;j--){var q=parseInt(e/l*j);if(m&&(q=parseFloat(e/l*j).toFixed(h)),p){for(;/(\d+)(\d{3})/.test(q.toString());){q=q.toString().replace(/(\d+)(\d{3})/,"$1,$2")}}u.unshift(q)}f.data("counterup-nums",u),f.text("0");var k=function(){f.data("counterup-nums")&&(f.text(f.data("counterup-nums").shift()),f.data("counterup-nums").length?setTimeout(f.data("counterup-func"),g.delay):(delete f.data("counterup-nums"),f.data("counterup-nums",null),f.data("counterup-func",null)))};f.data("counterup-func",k),setTimeout(f.data("counterup-func"),g.delay)};f.waypoint(d,{offset:"100%",triggerOnce:!0})})}}(jQuery);