//zwp (function(a){ a.fn.menu=function(option){ var style={ type:0,//0--无滑块;1--有滑块 defaultindex:0,//子级索引值 height:5,//滑块高度 background:"red",//滑块背景色 bottom:0,//滑块距离导航底部距离 animateease:"linear",//滑块的运动轨迹 time:500,//滑块的运动时间 zindex:-1,//滑块的层级 margin:0,//滑块左右间距 antcomplete:true,//默认滑块动画完成后调函数 startfun:null,//滑块进入方法 endfun:null//滑块离开方法 }, b=$.extend({},style,option), fun=b.type, h=b.height, bg=b.background, btm=b.bottom, e=b.animateease, t=b.time, i=b.zindex, m=b.margin, muiconw=0, pt=0, muiconwh=0, pth=0, $this=this, d=a(this), p=parseint(b.defaultindex), cl=b.antcomplete, f=function(){ a.isfunction(b.startfun) && b.startfun(p); }, r=function(){ a.isfunction(b.endfun) && b.endfun(p); }, $children=$this.children(), lg=$this.children().length, ddhv=null, ddat=null; if(lg>0){ ddhv=$children[0].tagname+".hover"; ddat=$children[0].tagname+".active"; } switch(fun) { case 1: $this.parent().css({"position":"relative","z-index":9}); $this.parent().append('
'); $this.siblings(".menuicon").css({ "height":h, "bottom":btm, "z-index":i }); $this.siblings(".menuicon").find("div").css({ "height":h, "background":bg, "marginleft":m, "marginright":m }); $children.each(function(index){ if($(this).hasclass("hover")){ muiconwh=$(this).outerwidth(); pth=$(this).position().left; $this.siblings(".menuicon").stop(true,false).animate({ "width":muiconwh, "left":pth, },{"duration":t,"easing":e}); } $(this).hover(function(){ p=$(this).index(); muiconw=$(this).outerwidth(); pt=$(this).position().left; switch(cl) { case true: $this.siblings(".menuicon").stop(true,false).animate({ "width":muiconw, "left":pt, },t,e,f); break; case false: $this.siblings(".menuicon").stop(true,false).animate({ "width":muiconw, "left":pt, },{"duration":t,"easing":e}); f(); break; }; $this.find(ddhv).addclass("active").removeclass("hover"); $(this).addclass("hover"); },function(){ r(); $(this).removeclass("hover"); $this.find(ddat).addclass("hover").removeclass("active"); }); }); $children.hover(function(){},function(){ $this.siblings(".menuicon").stop(true,false).animate({ "width":muiconwh, "left":pth, },{"duration":t,"easing":e}); }); break; case 0: $children.each(function(index){ $(this).hover(function(){ p=$(this).index(); f(); $this.find(ddhv).addclass("active").removeclass("hover"); $(this).addclass("hover"); },function(){ r(); $(this).removeclass("hover"); $this.find(ddat).addclass("hover").removeclass("active"); }); }); break; } }})(jquery), jquery.easing.jswing = jquery.easing.swing, jquery.extend(jquery.easing, { def: "easeoutquad", swing: function(a, b, c, d, e) { return jquery.easing[jquery.easing.def](a, b, c, d, e) }, easeinquad: function(a, b, c, d, e) { return d * (b /= e) * b + c }, easeoutquad: function(a, b, c, d, e) { return - d * (b /= e) * (b - 2) + c }, easeinoutquad: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b + c: -d / 2 * (--b * (b - 2) - 1) + c }, easeincubic: function(a, b, c, d, e) { return d * (b /= e) * b * b + c }, easeoutcubic: function(a, b, c, d, e) { return d * ((b = b / e - 1) * b * b + 1) + c }, easeinoutcubic: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b + c: d / 2 * ((b -= 2) * b * b + 2) + c }, easeinquart: function(a, b, c, d, e) { return d * (b /= e) * b * b * b + c }, easeoutquart: function(a, b, c, d, e) { return - d * ((b = b / e - 1) * b * b * b - 1) + c }, easeinoutquart: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b * b + c: -d / 2 * ((b -= 2) * b * b * b - 2) + c }, easeinquint: function(a, b, c, d, e) { return d * (b /= e) * b * b * b * b + c }, easeoutquint: function(a, b, c, d, e) { return d * ((b = b / e - 1) * b * b * b * b + 1) + c }, easeinoutquint: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b * b * b + c: d / 2 * ((b -= 2) * b * b * b * b + 2) + c }, easeinsine: function(a, b, c, d, e) { return - d * math.cos(b / e * (math.pi / 2)) + d + c }, easeoutsine: function(a, b, c, d, e) { return d * math.sin(b / e * (math.pi / 2)) + c }, easeinoutsine: function(a, b, c, d, e) { return - d / 2 * (math.cos(math.pi * b / e) - 1) + c }, easeinexpo: function(a, b, c, d, e) { return 0 == b ? c: d * math.pow(2, 10 * (b / e - 1)) + c }, easeoutexpo: function(a, b, c, d, e) { return b == e ? c + d: d * ( - math.pow(2, -10 * b / e) + 1) + c }, easeinoutexpo: function(a, b, c, d, e) { return 0 == b ? c: b == e ? c + d: 1 > (b /= e / 2) ? d / 2 * math.pow(2, 10 * (b - 1)) + c: d / 2 * ( - math.pow(2, -10 * --b) + 2) + c }, easeincirc: function(a, b, c, d, e) { return - d * (math.sqrt(1 - (b /= e) * b) - 1) + c }, easeoutcirc: function(a, b, c, d, e) { return d * math.sqrt(1 - (b = b / e - 1) * b) + c }, easeinoutcirc: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? -d / 2 * (math.sqrt(1 - b * b) - 1) + c: d / 2 * (math.sqrt(1 - (b -= 2) * b) + 1) + c }, easeinelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (1 == (b /= e)) return c + d; if (g || (g = .3 * e), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return - (h * math.pow(2, 10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g)) + c }, easeoutelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (1 == (b /= e)) return c + d; if (g || (g = .3 * e), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return h * math.pow(2, -10 * b) * math.sin((b * e - f) * 2 * math.pi / g) + d + c }, easeinoutelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (2 == (b /= e / 2)) return c + d; if (g || (g = e * .3 * 1.5), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return 1 > b ? -.5 * h * math.pow(2, 10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g) + c: .5 * h * math.pow(2, -10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g) + d + c }, easeinback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), d * (b /= e) * b * ((f + 1) * b - f) + c }, easeoutback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c }, easeinoutback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), 1 > (b /= e / 2) ? d / 2 * b * b * (((f *= 1.525) + 1) * b - f) + c: d / 2 * ((b -= 2) * b * (((f *= 1.525) + 1) * b + f) + 2) + c }, easeinbounce: function(a, b, c, d, e) { return d - jquery.easing.easeoutbounce(a, e - b, 0, d, e) + c }, easeoutbounce: function(a, b, c, d, e) { return 1 / 2.75 > (b /= e) ? d * 7.5625 * b * b + c: 2 / 2.75 > b ? d * (7.5625 * (b -= 1.5 / 2.75) * b + .75) + c: 2.5 / 2.75 > b ? d * (7.5625 * (b -= 2.25 / 2.75) * b + .9375) + c: d * (7.5625 * (b -= 2.625 / 2.75) * b + .984375) + c }, easeinoutbounce: function(a, b, c, d, e) { return e / 2 > b ? .5 * jquery.easing.easeinbounce(a, 2 * b, 0, d, e) + c: .5 * jquery.easing.easeoutbounce(a, 2 * b - e, 0, d, e) + .5 * d + c } }); /******************/ /* $(".menudl").menu({ type:1,//0--无滑块(默认);1--有滑块 height:5,//滑块高度 background:"#152d79",//滑块背景色 bottom:0,//滑块距离导航底部距离 animateease:"easeoutbounce",//滑块的运动轨迹 time:1000,//滑块的运动时间 zindex:-1,//滑块的层级 margin:0,//滑块左右间距 antcomplete:true,//滑块动画完成后调函数(默认) startfun:function(i){//滑块进入后回调方法 $(".menudl dd").eq(i).find(".div_a").stop(true,true).slidedown(); }, endfun:function(i){//滑块离开后回调方法 $(".menudl dd").find(".div_a").stop(true,true).slideup() } }); */