Files
Last update 2 months 4 days
by
Arnaud-Apu-Fanovard
jQuery-menu-aim.js.téléchargement(function(e){e.fn.menuAim=function(e){return this.each(function(){t.call(this,e)}),this};function t(t){var i=e(this),s=null,o=[],a=null,r=null,n=e.extend({rowSelector:"> li",submenuSelector:"*",submenuDirection:"right",tolerance:75,enter:e.noop,exit:e.noop,activate:e.noop,deactivate:e.noop,exitMenu:e.noop},t),g=3,p=300,d=function(e){o.push({x:e.pageX,y:e.pageY}),o.length>g&&o.shift()},u=function(){r&&clearTimeout(r),n.exitMenu(this)&&(s&&n.deactivate(s),s=null)},h=function(){r&&clearTimeout(r),n.enter(this),c(this)},m=function(){n.exit(this)},f=function(){l(this)},l=function(e){if(e==s)return;s&&n.deactivate(s),n.activate(e),s=e},c=function(e){var t=v();t?r=setTimeout(function(){c(e)},t):l(e)},v=function(){if(!s||!e(s).is(n.submenuSelector))return 0;var l,d,t=i.offset(),f={x:t.left,y:t.top-n.tolerance},g={x:t.left+i.outerWidth(),y:f.y},m={x:t.left,y:t.top+i.outerHeight()+n.tolerance},u={x:t.left+i.outerWidth(),y:m.y},c=o[o.length-1],r=o[0];if(!c)return 0;if(r||(r=c),r.x<t.left||r.x>u.x||r.y<t.top||r.y>u.y)return 0;if(a&&c.x==a.x&&c.y==a.y)return 0;function h(e,t){return(t.y-e.y)/(t.x-e.x)}d=g,l=u,n.submenuDirection=="left"?(d=m,l=f):n.submenuDirection=="below"?(d=u,l=m):n.submenuDirection=="above"&&(d=f,l=g);var v=h(c,d),b=h(c,l),j=h(r,d),y=h(r,l);return v<j&&b>y?(a=c,p):(a=null,0)};i.on("mouseleave",u).find(n.rowSelector).on("mouseenter",h).on("mouseleave",m).on("click",f),e(document).on("mousemove",d)}})(jQuery)