25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

2 satır
2.1 KiB

  1. (function(o,p,c){o.HoverDir=function(t,e){this.$el=o(e),this._init(t)},o.HoverDir.defaults={speed:300,easing:"ease",hoverDelay:0,inverse:!1},o.HoverDir.prototype={_init:function(t){this.options=o.extend(!0,{},o.HoverDir.defaults,t),this.transitionProp="all "+this.options.speed+"ms "+this.options.easing,this.support=Modernizr.csstransitions,this._loadEvents()},_loadEvents:function(){var t=this;this.$el.on("mouseenter.hoverdir, mouseleave.hoverdir",function(e){var i=o(this),r=i.find(".overlay"),a=t._getDir(i,{x:e.pageX,y:e.pageY}),n=t._getStyle(a);e.type==="mouseenter"?(r.hide().css(n.from),clearTimeout(t.tmhover),t.tmhover=setTimeout(function(){r.show(0,function(){var s=o(this);t.support&&s.css("transition",t.transitionProp),t._applyAnimation(s,n.to,t.options.speed)})},t.options.hoverDelay)):(t.support&&r.css("transition",t.transitionProp),clearTimeout(t.tmhover),t._applyAnimation(r,n.from,t.options.speed))})},_getDir:function(t,e){var i=t.width(),r=t.height(),a=(e.x-t.offset().left-i/2)*(i>r?r/i:1),n=(e.y-t.offset().top-r/2)*(r>i?i/r:1),s=Math.round((Math.atan2(n,a)*(180/Math.PI)+180)/90+3)%4;return s},_getStyle:function(t){var e,i,r={left:"0px",top:"-100%"},a={left:"0px",top:"100%"},n={left:"-100%",top:"0px"},s={left:"100%",top:"0px"},h={top:"0px"},f={left:"0px"};switch(t){case 0:e=this.options.inverse?a:r,i=h;break;case 1:e=this.options.inverse?n:s,i=f;break;case 2:e=this.options.inverse?r:a,i=h;break;case 3:e=this.options.inverse?s:n,i=f;break}return{from:e,to:i}},_applyAnimation:function(t,e,i){o.fn.applyStyle=this.support?o.fn.css:o.fn.animate,t.stop().applyStyle(e,o.extend(!0,[],{duration:i+"ms"}))}};var l=function(t){p.console&&p.console.error(t)};o.fn.hoverdir=function(t){var e=o.data(this,"hoverdir");if(typeof t=="string"){var i=Array.prototype.slice.call(arguments,1);this.each(function(){if(!e){l("cannot call methods on hoverdir prior to initialization; attempted to call method '"+t+"'");return}if(!o.isFunction(e[t])||t.charAt(0)==="_"){l("no such method '"+t+"' for hoverdir instance");return}e[t].apply(e,i)})}else this.each(function(){e?e._init():e=o.data(this,"hoverdir",new o.HoverDir(t,this))});return e}})(jQuery,window);