-
Notifications
You must be signed in to change notification settings - Fork 14
/
mylib-transform-min.js
1 lines (1 loc) · 7.65 KB
/
mylib-transform-min.js
1
var API,E,Q;if(API&&API.getAnElement){(function(){var K=API.getAnElement;var J=K();var L=function(d,c){if(!c){c=K()}if(c&&typeof c.style[d]!="string"){d=d.charAt(0).toUpperCase()+d.substring(1);var e=["Moz","O","Webkit","Khtml"];for(var b=e.length;b--;){if(typeof c.style[e[b]+d]!="undefined"){return e[b]+d}}return null}return d};API.findProprietaryStyle=L;var Z=API.elementUniqueId,a=API.isHostObjectProperty,X=API.map,S=API.forEach;var U=L("transform",J),R=U+"Origin";var P,M,W,T,G=[1,0,0,1],O;var N={},Y={};var A=/progid:DXImageTransform.Microsoft.Matrix\s*\([^\)]+\)/,H=/%$/;var C,B;var V=Math.PI;var D=function(b){return b*V/180};var F=function(c,b){return[c[0]*b[0]+c[1]*b[2],c[0]*b[1]+c[1]*b[3],c[2]*b[0]+c[3]*b[2],c[2]*b[1]+c[3]*b[3]]};var I={skew:function(b){return[1,Math.tan(D(b)),Math.tan(D(b)),1]},skewX:function(b){return[1,0,Math.tan(D(b)),1]},skewY:function(b){return[1,Math.tan(D(b)),0,1]},rotate:function(c){var b=D(c);return[Math.cos(b),Math.sin(b),-Math.sin(b),Math.cos(b)]},scale:function(b){return[b,0,0,b]},scaleX:function(b){return[b,0,0,1]},scaleY:function(b){return[1,0,0,b]},flip:function(b){return[-1,0,0,-1]},flipH:function(b){return[-1,0,0,1]},flipV:function(b){return[1,0,0,-1]}};if(U){if(J&&typeof J.style[U]=="string"){O=(function(){var b=API.createElement("div");b.style[U]="matrix(1,0,0,1,0,0)";return !b.style[U]})}P=function(f){var d,b,g,c=f.style[U];if(typeof c=="string"){if(O&&(b=N[Z(f)])){return b}d=c.match(/matrix\(([\.\d]+),([\.\d]+),([\.\d]+),([\.\d]+),([\.\d]+,)?([\.\d]+)?\)/i);if(d){return X(d.slice(1,5),function(e){return +e})}}else{if(c&&API.isHostMethod(c,"getCSSMatrix")){try{b=c.getCSSMatrix()}catch(h){}if(b){S(["a","b","c","d"],function(e){if(isNaN(b[e])){g=true}});if(!g){return[b.a,b.b,b.c,b.d]}}}}return G.slice(0)};M=function(c,b){if(O){N[Z(c)]=b}c.style[U]=["matrix(",b[0].toFixed(8),",",b[1].toFixed(8),",",b[2].toFixed(8),",",b[3].toFixed(8),",0,0)"].join("")};T=function(c,b){Y[Z(c)]=b;c.style[R]=b.reverse().join(" ")};W=function(c,b,d){return Y[Z(c)]||["50%","50%"]}}else{if(J&&a(J,"filters")&&a(J,"style")&&typeof J.style.filter=="string"){P=function(c){var b=c.filters["DXImageTransform.Microsoft.Matrix"];if(b){return[b.M11,b.M21,b.m12,b.m22]}return G.slice(0)};M=function(e,b,f){var c=["progid:DXImageTransform.Microsoft.Matrix(M11=",b[0].toFixed(8),",","M12=",b[2].toFixed(8),",","M21=",b[1].toFixed(8),",","M22=",b[3].toFixed(8),",sizingMethod='auto expand'",")"].join("");if(!f&&e.currentStyle&&!e.currentStyle.hasLayout){e.style.zoom="1"}var d=e.style.filter;if(!d){e.style.filter=c}else{if(A.test(d)){e.style.filter=d.replace(A,c)}else{e.style.filter+=" "+c}}}}}if(M){B=function(c,b){M(c,C(b))};API.setElementTransformMatrix=function(c,b){M(c,b)};API.getElementTransformMatrix=function(c,b){return P(c)};C=function(d){var c=G.slice(0),b;for(var e in d){if(API.isOwnProperty(d,e)&&(b=I[e])){c=F(c,b(d[e]))}}return c};API.setElementTransform=B;if(T){API.getElementTransformOrigin=function(b){return W(b)};API.setElementTransformOrigin=function(c,b){T(c,b)}}API.attachDocumentReadyListener(function(){var r,g,h,m,q;var f=function(t,u){var v={},i={},s=API.effects["transform"+t];return function(AB,x,y,AD){var AC,z,AA,w=function(){v[z]=null;if(i[z]){i[z](AB)}};if(y&&y.duration){z=Z(AB);if(v[z]){v[z].stop(true)}AA=new API.EffectTimer();y.effects=s;AC=y.effectParams||{};AC["target"+(t||"Transform")]=x;y.effectParams=AC;i[Z(AB)]=AD;v[z]=AA;AA.start(AB,y,w)}else{u(AB,x);if(AD){AD(AB)}}}};if(API.effects){m=API.effects.transform=(function(){var u,t,v,s;return function(w,y,x,i){if(i==1){if(x.transform){x.matrix=C(x.transform)}else{if(!x.targetTransform){t={};v={};for(u=x.transformOperations.length;u--;){s=x.transformOperations[u];switch(s){case"flip":case"flipH":case"flipV":t[s]=true;break;case"scale":case"scaleX":case"scaleY":t[s]=0;v[s]=1;break;case"rotate":t.rotate=90;v.rotate=0;break;case"skew":case"skewX":case"skewY":t[s]=45;v[s]=0}}x.matrix=C(t);x.targetTransform=v}else{x.matrix=P(w)}}x.targetMatrix=C(x.targetTransform)}q(w,y,x,i)}})();API.effects.transformOrigin=(function(){var t,i,u,s;return function(w,y,x,v){switch(v){case 1:t=x.origin||W(w);i=x.targetOrigin;u=H.test(t[0]);s=H.test(i[0]);if(u&&s||!u&&!s){t[0]=parseFloat(t[0]);i[0]=parseFloat(i[0]);x.originXPercent=u;u=H.test(t[1]);s=H.test(i[1]);if(u&&s||!u&&!s){t[1]=parseFloat(t[1]);i[1]=parseFloat(i[1]);x.originYPercent=u;x.sourceOrigin=t;x.targetOrigin=i}}w.style.visibility="visible";break;case 3:h(w,x.origin);return }i=x.targetOrigin;if(x.sourceOrigin){t=x.sourceOrigin;h(w,[(t[0]+(i[0]-t[0])*y)+(x.originXPercent?"%":""),(t[1]+(i[1]-t[1])*y)+(x.originXPercent?"%":"")])}else{h(w,[i[0],i[1]])}}})();q=API.effects.transformMatrix=(function(){var u,t,v,s;return function(w,y,x,i){switch(i){case 1:if(!x.matrix){x.matrix=P(w)}w.style.visibility="visible";break;case 3:g(w,x.targetMatrix,true);return }t=[];v=x.matrix;s=x.targetMatrix;for(u=4;u--;){t[u]=(v[u]+(s[u]-v[u])*y)}g(w,t,true)}})();g=M;API.setElementTransformMatrix=M=f("Matrix",M);M.async=true;r=B;API.setElementTransform=B=f("",B);B.async=true;if(T){h=T;API.setElementTransformOrigin=T=f("Origin",T);T.async=true}var o=function(s,u,t,i){if(i==1){switch(t.axes){case 1:t.transformOperations=["flipV"];break;case 2:t.transformOperations=["flipH"];break;default:t.transformOperations=["flip"]}}m(s,u,t,i)};API.effects.flip=o;API.effects.flipH=function(s,u,t,i){if(i==1){t.axes=2}o(s,u,t,i)};API.effects.flipV=function(s,u,t,i){if(i==1){t.axes=1}o(s,u,t,i)};var d=function(s,u,t,i){if(i==1){switch(t.axes){case 1:t.transformOperations=["scaleY"];break;case 2:t.transformOperations=["scaleX"];break;default:t.transformOperations=["scale"]}}m(s,u,t,i)};API.effects.scale=d;API.effects.scaleX=function(s,u,t,i){if(i==1){t.axes=2}d(s,u,t,i)};API.effects.scaleY=function(s,u,t,i){if(i==1){t.axes=1}d(s,u,t,i)};var c=function(s,u,t,i){if(i==1){switch(t.axes){case 1:t.transformOperations=["skewY"];break;case 2:t.transformOperations=["skewX"];break;default:t.transformOperations=["skew"]}}m(s,u,t,i)};API.effects.skew=c;API.effects.skewX=function(s,u,t,i){if(i==1){t.axes=2}c(s,u,t,i)};API.effects.skewY=function(s,u,t,i){if(i==1){t.axes=1}c(s,u,t,i)};API.effects.rotate=function(s,u,t,i){if(i==1){t.transformOperations=["rotate"]}m(s,u,t,i)};API.effects.spin=(function(){var t,i,s=I.rotate;return function(v,x,w,u){switch(u){case 1:w.matrix=P(v);if(w.spin){w.matrix=F(w.matrix,s(w.spin))}else{w.spin=0}if(!w.targetSpin){w.targetSpin=360}v.style.visibility="visible";break;case 3:g(v,w.matrix,true);return }t=w.spin;i=w.targetSpin;g(v,F(w.matrix,s(t+(i-t)*x)),true)}})();var l,n,k=["flip","flipH","flipV","skew","skewX","skewY","scale","scaleX","scaleY","rotate","spin","transform"];var j=API.showElement,e=API.effects;var p=function(t,i){var s=e[t];return function(u,v){u.effects=s;j(this.element(),i,u,v);return this}};var b=function(t,i){var s=e[t];return function(u,v){u.effects=s;this.forEach(function(w){j(w,i,u,v)});return this}};if(j){if(E&&E.prototype){for(l=k.length;l--;){n=k[l];E.prototype[n+"In"]=p(n,true);E.prototype[n+"Out"]=p(n,false)}}if(Q&&Q.prototype){for(l=k.length;l--;){n=k[l];Q.prototype[n+"In"]=b(n,true);Q.prototype[n+"Out"]=b(n,false)}}}}});if(E&&E.prototype){E.prototype.setTransform=function(c,b,d){B(this.element(),c,b,d);return this};E.prototype.getTransformMatrix=function(){return P(this.element())};E.prototype.setTransformMatrix=function(c,b,d){M(this.element(),c,b,d);return this};if(T){E.prototype.setTransformOrigin=function(b,c,d){T(this.element(),b,c,d);return this}}}if(Q&&Q.prototype){Q.prototype.setTransform=function(c,b,d){this.forEach(function(e){B(e,c,b,d)});return this};Q.prototype.setTransformMatrix=function(b,c,d){this.forEach(function(e){M(e,b,c,d)});return this};if(T){Q.prototype.setTransformOrigin=function(b,c,d){this.forEach(function(e){T(e,b,c,d)});return this}}}}J=null})()}