js 实现左右移动

/** * 底部工具栏左右控制js * @author:tangw 2010-11-07 */ var RL = {}; RL = { defCount:6, arWindow:[], startIndex: 0, endIndex:5, currShowW:"", up:function(){//向上 var len = this.arWindow.length; if( this.endIndex == (len-1) ){ this.setStyle("f_v_w_down", ""); } var sid = --this.startIndex; var eid = this.endIndex; if(sid==0){ this.setStyle("f_v_w_up", "none"); } var _eid = this.arWindow[eid]; this.setStyle("f_v_window_min_"+_eid, "none"); var _sid = this.arWindow[sid]; this.setStyle("f_v_window_min_"+_sid, "block"); this.endIndex--; }, down:function(){//向下 var len = this.arWindow.length; this.setStyle("f_v_w_up", "block"); var id = this.arWindow[this.startIndex]; this.setStyle("f_v_window_min_"+id, "none"); var count = ++this.endIndex; if( count == len-1 ){ this.setStyle("f_v_w_down","none"); } var eid = this.arWindow[count]; this.setStyle("f_v_window_min_"+eid,"block"); this.startIndex++; }, addW:function(id){ var count = this.arWindow.length; if( count > (this.defCount-1)){ this.setStyle("f_v_w_down","block"); } this.arWindow[count] = id; }, setStyle:function(id,str){ var o = this.getObj(id); if(o){ o.style.display = str; } }, getObj:function(id){ return document.getElementById(id); }, getArCount:function(id){ var c = 0; var len = this.getLen(); for(var i=0;i<len;i++){ if( id == this.arWindow[i]){ c= i; break; } } return c; }, getLen:function(){ return this.arWindow.length; }, removeAr:function(c){ var len = this.getLen(); this.arWindow = this.arWindow.slice(0,c).concat(this.arWindow.slice(c+1,len)); }, removeW:function(id){ var len = this.getLen(); var currIndex = this.getArCount(id);//当前位置 if( len >= (this.defCount+1) ){ if( currIndex<=this.startIndex ){//当前 <= 开始 if( currIndex<this.startIndex ){ //直接隐藏 this.setStyle("f_v_window_min_"+id, "none"); }else{ var e = this.endIndex+1; //隐藏 this.setStyle("f_v_window_min_"+id, "none"); //显示 var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } }else if( currIndex>=this.endIndex ){// 当前>=结束 if( currIndex==this.endIndex ){ var e = -1; if( currIndex==(len-1) ){ if(this.startIndex>0){ e = --this.startIndex; --this.endIndex; } }else{ e = this.endIndex+1; } if(e!=-1){ var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } }else{ //直接隐藏 this.setStyle("f_v_window_min_"+id, "none"); } }else if( this.startIndex < currIndex < this.endIndex){ //开始<当前<结束 var e = -1; if( this.startIndex == 0 ){ e = this.endIndex+1; }else{ if( this.endIndex == (len-1) ){ e = --this.startIndex; --this.endIndex; }else{ e = this.endIndex+1; } } this.setStyle("f_v_window_min_"+id, "none"); if( e!=-1){ var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } } //删除 this.removeAr(currIndex); //控制样式 this.setStyle("f_v_w_up",this.startIndex==0?"none":"block"); this.setStyle("f_v_w_down",this.endIndex == (this.getLen()-1)?"none":"block"); }else{ this.removeAr(currIndex); } } }

转载于:https://www.cnblogs.com/tw5566/archive/2010/11/23/2247878.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值