-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjquery-pie-loader.min.js
1 lines (1 loc) · 1.76 KB
/
jquery-pie-loader.min.js
1
!function(t){"use strict";function e(e,n){this.element=e,this.settings=t.extend({},s,n),this._defaults=s,this._name=i,this.init()}var i="svgPie",s={easing:"easeOutCubic",dimension:200,percentage:50,duration:2e3,onStart:function(){},onComplete:function(){}};t.extend(t.easing,{easeOutCubic:function(t,e,i,s,n){return s*((e=e/n-1)*e*e+1)+i}}),t.extend(e.prototype,{init:function(){t(this.element).css({width:this.settings.dimension+"px",height:this.settings.dimension+"px"}),this.createSvg(),this.animateNumber(),this.animateStrokeDasharray(),t(this.element).addClass("rendered")},createSvg:function(){var e=this.settings.dimension/2,i=this.settings.dimension/4,s=2*Math.PI*i,n='<svg xmlns:svg="http://www.w3.org/2000/svg"xmlns="http://www.w3.org/2000/svg"><circle r="'+e+'" cx="'+e+'" cy="'+e+'"/><circle r="'+(i+.5)+'" cx="'+e+'" cy="'+e+'"style="stroke-width:'+e+"px;stroke-dasharray:0px "+s+';"/></svg><div class="percentage"></div>';t(this.element).prepend(n)},animateNumber:function(){var e=t(this.element).find(".percentage");t({percentageValue:0}).animate({percentageValue:this.settings.percentage},{duration:this.settings.duration,easing:this.settings.easing,start:this.settings.onStart,step:function(){e.text(Math.round(this.percentageValue)+"%")},complete:this.settings.onComplete})},animateStrokeDasharray:function(){var e=this.settings.percentage>=100?1:0,i=2*Math.PI*(this.settings.dimension/4+.4),s=(this.settings.percentage+e)*i/100,n=t(this.element).find("svg circle:nth-child(2)");t({strokeValue:0}).animate({strokeValue:s},{duration:this.settings.duration,easing:this.settings.easing,step:function(){n.css("stroke-dasharray",this.strokeValue+"px "+i+"px")}})}}),t.fn[i]=function(s){return this.each(function(){t.data(this,"plugin_"+i)||t.data(this,"plugin_"+i,new e(this,s))})}}(jQuery);