"use strict";!function(t){t(function(){function t(t,i,o,e){this.element=t,this.style=t.style,this.computedStyle=window.getComputedStyle(t),this.width=i,this.height=o,this.useBackFacing=!!e,this.topLeft={x:0,y:0},this.topRight={x:i,y:0},this.bottomLeft={x:0,y:o},this.bottomRight={x:i,y:o},this.calcStyle=""}return t.useDPRFix=!1,t.dpr=1,t.prototype=function(){function i(){var t=this.topLeft.x-this.topRight.x,i=this.topLeft.y-this.topRight.y;return Math.sqrt(t*t+i*i)<=1||(t=this.bottomLeft.x-this.bottomRight.x,i=this.bottomLeft.y-this.bottomRight.y,Math.sqrt(t*t+i*i)<=1||(t=this.topLeft.x-this.bottomLeft.x,i=this.topLeft.y-this.bottomLeft.y,Math.sqrt(t*t+i*i)<=1||(t=this.topRight.x-this.bottomRight.x,i=this.topRight.y-this.bottomRight.y,Math.sqrt(t*t+i*i)<=1||(t=this.topLeft.x-this.bottomRight.x,i=this.topLeft.y-this.bottomRight.y,Math.sqrt(t*t+i*i)<=1||(t=this.topRight.x-this.bottomLeft.x,i=this.topRight.y-this.bottomLeft.y,Math.sqrt(t*t+i*i)<=1)))))}function o(t,i,o){return t.x*i.y+i.x*o.y+o.x*t.y-t.y*i.x-i.y*o.x-o.y*t.x}function e(){var t=o(this.topLeft,this.topRight,this.bottomRight),i=o(this.bottomRight,this.bottomLeft,this.topLeft);if(this.useBackFacing){if(t*i<=0)return!0}else if(t<=0||i<=0)return!0;var t=o(this.topRight,this.bottomRight,this.bottomLeft),i=o(this.bottomLeft,this.topLeft,this.topRight);if(this.useBackFacing){if(t*i<=0)return!0}else if(t<=0||i<=0)return!0;return!1}function r(){return i.apply(this)?1:e.apply(this)?2:0}function s(){var i=this.width,o=this.height,e=0,r=0,s=this.computedStyle.getPropertyValue(t.transformOriginDomStyleName);s.indexOf("px")>-1?(s=s.split("px"),e=-parseFloat(s[0]),r=-parseFloat(s[1])):s.indexOf("%")>-1&&(s=s.split("%"),e=-parseFloat(s[0])*i/100,r=-parseFloat(s[1])*o/100);for(var h=[this.topLeft,this.topRight,this.bottomLeft,this.bottomRight],f=[0,1,2,3,4,5,6,7],m=0;m<4;m++)n[m][0]=n[m+4][3]=1&m?i+e:e,n[m][1]=n[m+4][4]=m>1?o+r:r,n[m][6]=(1&m?-e-i:-e)*(h[m].x+e),n[m][7]=(m>1?-r-o:-r)*(h[m].x+e),n[m+4][6]=(1&m?-e-i:-e)*(h[m].y+r),n[m+4][7]=(m>1?-r-o:-r)*(h[m].y+r),a[m]=h[m].x+e,a[m+4]=h[m].y+r,n[m][2]=n[m+4][5]=1,n[m][3]=n[m][4]=n[m][5]=n[m+4][0]=n[m+4][1]=n[m+4][2]=0;for(var y,x,p,m,l,c,g,u=[],l=0;l<8;l++){for(var m=0;m<8;m++)u[m]=n[m][l];for(m=0;m<8;m++){p=n[m],y=m<l?m:l,x=0;for(var c=0;c<y;c++)x+=p[c]*u[c];p[l]=u[m]-=x}var d=l;for(m=l+1;m<8;m++)Math.abs(u[m])>Math.abs(u[d])&&(d=m);if(d!=l){for(c=0;c<8;c++)g=n[d][c],n[d][c]=n[l][c],n[l][c]=g;g=f[d],f[d]=f[l],f[l]=g}if(0!=n[l][l])for(m=l+1;m<8;m++)n[m][l]/=n[l][l]}for(m=0;m<8;m++)f[m]=a[f[m]];for(c=0;c<8;c++)for(m=c+1;m<8;m++)f[m]-=f[c]*n[m][c];for(c=7;c>-1;c--)for(f[c]/=n[c][c],m=0;m<c;m++)f[m]-=f[c]*n[m][c];return this.calcStyle="matrix3d("+f[0].toFixed(9)+","+f[3].toFixed(9)+", 0,"+f[6].toFixed(9)+","+f[1].toFixed(9)+","+f[4].toFixed(9)+", 0,"+f[7].toFixed(9)+",0, 0, 1, 0,"+f[2].toFixed(9)+","+f[5].toFixed(9)+", 0, 1)"}function h(i){if(i=i||this.calcStyle,t.useDPRFix){var o=t.dpr;i="scale("+o+","+o+")perspective(1000px)"+i+"translateZ("+1e3*(1-o)+"px)"}return this.style[t.transformStyleName]=i}var f={stylePrefix:""},n=[[0,0,1,0,0,0,0,0],[0,0,1,0,0,0,0,0],[0,0,1,0,0,0,0,0],[0,0,1,0,0,0,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,0,1,0,0]],a=[0,0,0,0,0,0,0,0];return function(){var i=document.createElement("div").style;f.stylePrefix="webkitTransform"in i?"webkit":"MozTransform"in i?"Moz":"msTransform"in i?"ms":"",t.transformStyleName=f.stylePrefix+(f.stylePrefix.length>0?"Transform":"transform"),t.transformDomStyleName="-"+f.stylePrefix.toLowerCase()+"-transform",t.transformOriginStyleName=f.stylePrefix+(f.stylePrefix.length>0?"TransformOrigin":"transformOrigin"),t.transformOriginDomStyleName="-"+f.stylePrefix.toLowerCase()+"-transform-origin"}(),f.calc=s,f.update=h,f.checkError=r,f}(),t})}("function"==typeof define&&define.amd?define:function(t){window.PerspectiveTransform=t()});
|