mirror of
https://github.com/medialab-prado/datamad2017.git
synced 2024-12-27 13:11:22 +01:00
1 line
No EOL
928 B
JavaScript
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); |