js 实现左右移动 - 大米文子
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);
}
}
}