查看文章 |
X-menu
2007-07-18 12:10
/* new XMenu("#Xmenu a", {}); */ var XMenu = new Class({ Implements: [Chain, Options], options: { mode: 'width', offset:{ over:0, normal:0, out:0 }, options: { transition: Fx.Transitions.Quad.easeOut, duration: 400, wait: false } }, initialize: function(){ var params = $A(arguments).associate({'options': 'object', 'elements': true}); this.setOptions(params.options || {} ); if( !(this.elements = $$(params.elements)) || this.elements.length < 2 ){ return null; } this.options.offset.normal = parseInt(this.options.offset.normal) || this.elements[0].getStyle( this.options.mode ).toInt(); this.options.offset.over = parseInt(this.options.offset.over) || Math.ceil(this.options.offset.normal * 1.5); this.options.offset.out = parseInt(this.options.offset.out) || ( (this.options.offset.normal * this.elements.length - this.options.offset.over)/( this.elements.length -1) +0); var fx = new Fx.Elements(this.elements, this.options.options); this.elements.each(function(el, i) { el.addEvent("mouseenter", function(event) { var o = {}; o[i] = {}; o[i][this.options.mode] = [el.getStyle(this.options.mode).toInt(), this.options.offset.over]; this.elements.each(function(_el, j) { if(i != j) { var w = _el.getStyle(this.options.mode).toInt(); if(w != this.options.offset.out){ o[j] = {}; o[j][this.options.mode] = [w, this.options.offset.out]; } } }.bind(this) ); fx.start(o); }.bind(this)); }.bind(this)); this.elements.addEvent("mouseleave", function(event) { var o = {}; this.elements.each(function(el, i) { o[i] = {}; o[i][this.options.mode] = [el.getStyle(this.options.mode).toInt(), this.options.offset.normal]; }.bind(this)); fx.start(o); }.bind(this)) } }); |
最近读者: