forked from fgnass/spin.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spin.min.js
2 lines (2 loc) · 2.91 KB
/
spin.min.js
1
2
// https://fgnass.github.com/spin.js
(function(a,b){function M(a){F(arguments,function(c,d){a[c]===b&&(a[c]=d)});return a}function L(a){F(arguments,function(b,c){a[l][K(a,b)||b]=c});return a}function K(a,c){var e=a[l],f,g;if(e[c]!==b)return c;c=c.charAt(0).toUpperCase()+c.slice(1);for(g=0;g<C[d];g++){f=C[g]+c;if(e[f]!==b)return f}}function J(a,b){var c=[i,b,~~(a*100)].join("-"),e="{"+i+":"+a+"}",f;if(!D[c]){for(f=0;f<C[d];f++)try{I.insertRule("@"+(C[f]&&"-"+C[f].toLowerCase()+"-"||"")+"keyframes "+c+"{0%{"+i+":1}"+b+"%"+e+"to"+e+"}",I.cssRules[d])}catch(g){}D[c]=1}return c}function H(a,b,c){c&&!c[s]&&H(a,c),a.insertBefore(b,c||null);return a}function G(b){var c=a.createElement(b||"div");F(arguments,function(a,b){c[a]=b});return c}function F(a,b){var c=~~((a[d]-1)/2);for(var e=1;e<=c;e++)b(a[e*2-1],a[e*2])}var c="width",d="length",e="radius",f="lines",g="trail",h="color",i="opacity",j="speed",k="shadow",l="style",m="height",n="left",o="top",p="px",q="childNodes",r="firstChild",s="parentNode",t="position",u="relative",v="absolute",w="animation",x="transform",y="Origin",z="coord",A="#000",B=l+"Sheets",C="webkit0Moz0ms0O".split(0),D={},E;H(a.getElementsByTagName("head")[0],G(l));var I=a[B][a[B][d]-1],N=function(a){this.el=this[f](this.opts=M(a||{},f,12,g,100,d,7,c,5,e,10,h,A,i,.25,j,1))},O=N.prototype={spin:function(a){var b=this,c=b.el;a&&H(a,L(c,n,~~(a.offsetWidth/2)+p,o,~~(a.offsetHeight/2)+p),a[r]),b.on=1;if(!E){var d=b.opts,e=0,h=20/d[j],k=(1-d[i])/(h*d[g]/100),l=h/d[f];(function m(){e++;for(var a=d[f];a;a--){var g=Math.max(1-(e+a*l)%h*k,d[i]);b[i](c,d[f]-a,g,d)}b.on&&setTimeout(m,50)})()}return b},stop:function(){var a=this,b=a.el;a.on=0,b[s]&&b[s].removeChild(b);return a}};O[f]=function(a){function s(b,g){return L(G(),t,v,c,a[d]+a[c]+p,m,a[c]+p,"background",b,"boxShadow",g,x+y,n,x,"rotate("+~~(360/a[f]*q)+"deg) translate("+a[e]+p+",0)","borderRadius","100em")}var b=L(G(),t,u),l=J(a[i],a[g]),q=0,r;for(;q<a[f];q++)r=L(G(),t,v,o,1+~(a[c]/2)+p,x,"translate3d(0,0,0)",w,l+" "+1/a[j]+"s linear infinite "+(1/a[f]/a[j]*q-1/a[j])+"s"),a[k]&&H(r,L(s(A,"0 0 4px "+A),o,2+p)),H(b,H(r,s(a[h],"0 0 1px rgba(0,0,0,.1)")));return b},O[i]=function(a,b,c){a[q][b][l][i]=c};var P="behavior",Q="url(#default#VML)",R="group0roundrect0fill0stroke".split(0);(function(){var a=L(G(R[0]),P,Q),b;if(!K(a,x)&&a.adj){for(b=0;b<R[d];b++)I.addRule(R[b],P+":"+Q);O[f]=function(){function s(d,g,k){H(l,H(L(j(),"rotation",360/a[f]*d+"deg",n,~~g),H(L(G(R[1],"arcsize",1),c,b,m,a[c],n,a[e],o,-a[c]/2,"filter",k),G(R[2],h,a[h],i,a[i]),G(R[3],i,0))))}function j(){return L(G(R[0],z+"size",g+" "+g,z+y,-b+" "+ -b),c,g,m,g)}var a=this.opts,b=a[d]+a[c],g=2*b,l=j(),q=~(a[d]+a[e]+a[c])+p,r;if(a[k])for(r=1;r<=a[f];r++)s(r,-2,"progid:DXImage"+x+".Microsoft.Blur(pixel"+e+"=2,make"+k+"=1,"+k+i+"=.3)");for(r=1;r<=a[f];r++)s(r);return H(L(G(),"margin",q+" 0 0 "+q,t,u),l)},O[i]=function(a,b,c,d){d=d[k]&&d[f]||0,a[r][q][b+d][r][r][i]=c}}else E=K(a,w)})(),window.Spinner=N})(document)