datamad2017/js/jquery.countTo.min.js
Vitaliy Zasadnyy 95607eea61 Initial commit
2014-07-28 22:27:01 +03:00

1 line
No EOL
928 B
JavaScript

!function(t){function e(t,e){return t.toFixed(e.decimals)}t.fn.countTo=function(e){return e=e||{},t(this).each(function(){function o(){c+=r,u++,s(c),"function"==typeof a.onUpdate&&a.onUpdate.call(n,c),i>u||(p.removeData("countTo"),clearInterval(l.interval),c=a.to,"function"==typeof a.onComplete&&a.onComplete.call(n,c))}function s(t){var e=a.formatter.call(n,t,a);p.text(e)}var a=t.extend({},t.fn.countTo.defaults,{from:t(this).data("from"),to:t(this).data("to"),speed:t(this).data("speed"),refreshInterval:t(this).data("refresh-interval"),decimals:t(this).data("decimals")},e),i=Math.ceil(a.speed/a.refreshInterval),r=(a.to-a.from)/i,n=this,p=t(this),u=0,c=a.from,l=p.data("countTo")||{};p.data("countTo",l),l.interval&&clearInterval(l.interval),l.interval=setInterval(o,a.refreshInterval),s(c)})},t.fn.countTo.defaults={from:0,to:0,speed:1e3,refreshInterval:100,decimals:0,formatter:e,onUpdate:null,onComplete:null}}(jQuery);