-
Notifications
You must be signed in to change notification settings - Fork 0
/
logos_entire.js
2 lines (2 loc) · 7.46 KB
/
logos_entire.js
1
2
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}};!function(b,c,d){var e,f,g;return g="logosDistort",f={enable:!0,effectWeight:1,enableSmoothing:!0,smoothingMultiplier:1,activeOnlyInside:!1,outerBuffer:1.1,elementDepth:140,directions:[1,1,1,1,-1,-1,1,1],weights:[31e-6,18e-5,164e-7,19e-7,12e-5],container:c,cssClasses:{smartContainer:"ld-smart-container",overlapContainer:"ld-overlap-container",parent3d:"ld-3d-parent",transformTarget:"ld-transform-target",active:"ld-transform-active",object3d:"ld-3d-object"},onInit:function(){},onDestroy:function(){}},e=function(){function e(c,d){this.element=c,this.applyTransform=a(this.applyTransform,this),this.settings=b.extend({},f,d),this._defaults=f,this._name=g,this.container=b(this.settings.container),this.$el=b(this.element),this.winW=this.container.innerWidth(),this.winH=this.container.innerHeight(),this.center=this.getCenterOfContainer(),this.outerCon=null,this.outerConParent=null,this.transformTarget=null,this.objects3d=null,this.mouseX=this.mouseY=0,this.effectX=this.effectY=0,this.has3dSupport=this.has3d(),this.paused=!1,this.raf=null,this.init()}return e.prototype.init=function(){var a;return this.createEnvironment(),this.settings.onInit(),a=this,b(d).on("mousemove",function(b){return a.mouseX=b.pageX,a.mouseY=b.pageY,!a.settings.enableSmoothing&&a.has3dSupport?a.draw():void 0}),b(c).on("resize",function(){return a.resizeHandler()}),this.has3dSupport?this.draw():void 0},e.prototype.createEnvironment=function(){var a,c,d,e,f;for(this.objects3d=this.$el.children(),this.$el.html(""),f=this.objects3d,d=0,e=f.length;e>d;d++)a=f[d],b(a).addClass(""+this.settings.cssClasses.object3d);return this.outerConParent=b("<div class='"+this.settings.cssClasses.smartContainer+"'></div>"),this.outerCon=b("<div class='"+this.settings.cssClasses.overlapContainer+"'></div>"),c=b("<div class='"+this.settings.cssClasses.parent3d+"'></div>"),this.transformTarget=b("<div class='"+this.settings.cssClasses.transformTarget+" "+this.settings.cssClasses.active+"'></div>"),this.$el.append(this.outerConParent.append(this.outerCon.append(c.append(this.transformTarget.append(this.objects3d))))),this.calculateOuterContainer(),this.calculate3dObjects()},e.prototype.setImageDefaults=function(a){var c;return c=this,a.is("img")?a.one("load",function(){return c.calculatePerspective(a)}).each(function(){return this.complete?b(this).load():void 0}):c.calculatePerspective(a)},e.prototype.calculateOuterContainer=function(){var a,b;return b=this.outerConParent.innerWidth()*this.settings.outerBuffer,a=this.outerConParent.innerHeight()*this.settings.outerBuffer,this.outerCon.css({width:b.toFixed(2),height:a.toFixed(2),left:-((b-this.winW)/2).toFixed(2),top:-((a-this.winH)/2).toFixed(2)})},e.prototype.calculate3dObjects=function(){var a,c,d,e,f;for(e=this.objects3d,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(this.setImageDefaults(b(a)));return f},e.prototype.calculatePerspective=function(a){var c,d,e,f,g,h,i,j,k,l;return a=b(a),f=a.index()+1,this.objects3d.length>4&&(f-=this.objects3d.length/2),g=f*this.settings.elementDepth,d=this.getAspectRatio(),e=this.getAspectRatio(a),c=isNaN(e[0])||a.is("div")?d:e,i=(this.outerConParent.innerHeight()*this.settings.outerBuffer).toFixed(2),l=(i*c[0]).toFixed(2),l<this.winW*this.settings.outerBuffer&&(h=this.winW/l,l=(l*h*this.settings.outerBuffer).toFixed(2),i=(i*h*this.settings.outerBuffer).toFixed(2)),j=-((l-this.winW)/2).toFixed(2),k=-((i-this.winH)/2).toFixed(2),a.attr("style","transform: translate3d("+j+"px, "+k+"px, "+g+"px); width:"+l+"px; height:"+i+"px;")},e.prototype.draw=function(){var a;return a=this,this.settings.enableSmoothing?setInterval(function(){return a.calculateSmoothing(),a.changePerspective(a.transformTarget,a.effectX,a.effectY)},15):(this.effectX=this.mouseX,this.effectY=this.mouseY,this.paused?void 0:(this.changePerspective(this.transformTarget,this.effectX,this.effectY),this.raf=requestAnimationFrame(function(){return a.draw()})))},e.prototype.start=function(){var a;return a=!1,this.draw()},e.prototype.stop=function(){var a;return a=!0},e.prototype.changePerspective=function(a,c,d){var e;return e=this,requestAnimationFrame(function(){return b(a).attr("style",e.calculateTransform(c,d))})},e.prototype.calculateTransform=function(a,b){var c,d,e,f,g,h,i,j;return c=(this.settings.directions[0]*(1-this.applyTransform(this.getDistanceFromCenter(a,b),0)*this.settings.effectWeight)).toFixed(5),d=(this.settings.directions[1]*this.applyTransform(this.getDistanceFromCenterY(a),1)*this.settings.effectWeight).toFixed(5),e=(this.settings.directions[2]*this.applyTransform(this.getDistanceFromEdgeCenterAndCenter(a,b),2)*this.settings.effectWeight).toFixed(5),f=(this.settings.directions[3]*(1-this.applyTransform(this.getDistanceFromCenter(a,b),3)*this.settings.effectWeight)).toFixed(5),g=(this.settings.directions[4]*this.applyTransform(this.getDistanceFromCenterX(b),4)*this.settings.effectWeight).toFixed(5),h=(this.settings.directions[5]*d).toFixed(5),i=(this.settings.directions[6]*g).toFixed(5),j=(this.settings.directions[7]*Math.abs(f)).toFixed(5),"transform: matrix3d("+c+", 0, "+d+", 0, "+e+", "+f+", "+g+", 0, "+h+", "+i+", "+j+", 0, 0, 0, 100, 1)"},e.prototype.applyTransform=function(a,b){return a*this.settings.weights[b]},e.prototype.getDistanceFromCenter=function(a,b){return this.getDistance2d(a,b,this.center.x,this.center.y)},e.prototype.getDistanceFromCenterY=function(a){return a-this.center.x/2},e.prototype.getDistanceFromCenterX=function(a){return a-this.center.y/2},e.prototype.getDistanceFromEdgeCenterAndCenter=function(a,b){var c,d,e;return c=this.getDistanceFromCenter(a,b),d=this.getDistanceFromCenterX(b),e=this.getDistanceFromCenterY(a),-(c/100*(d/50)*(e/50))},e.prototype.calculateSmoothing=function(){return this.effectX+=(this.mouseX-this.effectX)/(20*this.settings.smoothingMultiplier),this.effectY+=(this.mouseY-this.effectY)/(20*this.settings.smoothingMultiplier)},e.prototype.getDistance2d=function(a,b,c,d){return Math.sqrt(Math.pow(a-c,2)+Math.pow(b-d,2))},e.prototype.getCenterOfContainer=function(){return{x:this.winW/2,y:this.winH/2}},e.prototype.getAspectRatio=function(a){return null==a&&(a=c),a=b(a),[a.innerWidth()/a.innerHeight(),a.innerHeight()/a.innerWidth()]},e.prototype.resizeHandler=function(){return this.container=b(this.settings.container),this.winW=this.container.innerWidth(),this.winH=this.container.innerHeight(),this.center=this.getCenterOfContainer(),this.calculateOuterContainer(),this.calculate3dObjects()},e.prototype.has3d=function(){var a,b,e,f;a=d.createElement("p"),f={WebkitTransform:"-webkit-transform",OTransform:"-o-transform",MSTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"},b=void 0,d.body.insertBefore(a,d.body.lastChild);for(e in f)void 0!==a.style[e]&&(a.style[e]="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",b=c.getComputedStyle(a),b=b.getPropertyValue(f[e]));return null!=b?"none"!==b:!1},e.prototype.destroy=function(){$elem=this.$el;var a=$elem.find("img");return $elem.empty(),a.each(function(){b(this).removeClass(),b(this).removeAttr("style"),$elem.append(b(this))}),this.hook("onDestroy"),this.$el.removeData("plugin_"+g)},e.prototype.hook=function(a){return null!=options[a]?options[a].call(this.element):void 0},e}(),b.fn[g]=function(a){return this.each(function(){if("string"==typeof a){var c=Array.prototype.slice.call(arguments,1),d=b.data(this,"plugin_"+g);d[a].apply(d,c)}else if(!b.data(this,"plugin_"+g))return b.data(this,"plugin_"+g,new e(this,a))})}}(jQuery,window,document)}).call(this);
//# sourceMappingURL=jquery.logosDistort.min.map