-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinc-1.0.0.min.js
7 lines (6 loc) · 994 Bytes
/
inc-1.0.0.min.js
1
2
3
4
5
6
7
/*
Inc v1.0.0
(c) 2014 Clearwave Designs, LLC. http://clearwavedesigns.com
License: MIT
*/
function Inc(t){var e=t.elem,a="input"===e.nodeName.toLowerCase()?!0:!1,n=parseFloat(e.getAttribute("data-inc-value"))||0,i=parseInt(e.getAttribute("data-inc-duration"))||0,r=parseInt(e.getAttribute("data-inc-delay"))||0,d=(t.decimal>2?2:t.decimal)||0,l=t.currency||"",c=(t.speed<30?30:t.speed)||30,o=0,u=n/(i/c),s=null,p=/\B(?=(\d{3})+(?!\d))/g,g=function(){o+=u,n>o?a?e.value=l+o.toFixed(d).toString().replace(p,","):e.innerHTML=l+o.toFixed(d).toString().replace(p,","):(clearInterval(s),a?e.value=l+n.toFixed(d).toString().replace(p,","):e.innerHTML=l+n.toFixed(d).toString().replace(p,","))};setTimeout(function(){s=setInterval(g.bind(this),c)}.bind(this),r),this.reset=function(){clearInterval(s),n=parseFloat(e.getAttribute("data-inc-value"))||0,i=parseInt(e.getAttribute("data-inc-duration"))||0,u=n/(i/c),r=parseInt(e.getAttribute("data-inc-delay"))||0,o=0,s=setInterval(g,c)}.bind(this)}