jquery 사용자 정의 슬라이딩 단추

6017 단어 htmljqueryUP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <script src="http://localhost:8080/js/jquery-1.3.2.js"></script>
  <style>
	#messageBT span{
				width:46px;height:46px;margin-bottom:15px;float:left;margin-left: 25px;cursor: pointer;position:relative;
				margin-top: 0;
	}
</style>
 </HEAD>

 <BODY>

  <div style='border:1px solid;width:500px; heigth:30px' id='messageBT' >
	<span style='heigth:100%; width:0px;display:none' id='i'>
	0
	</span>
	<span style='heigth:100%; width:40px' id='a'>
	1
	</span>
	<span style='heigth:100%; width:40px' id='b'>
	2
	</span>
	<span style='heigth:100%; width:40px' id='c'>
	3
	</span>
	<span style='heigth:100%; width:40px' id='d'>
	4
	</span>
	<span style='heigth:100%; width:40px' id='e'>
	5
	</span>
	<span style='heigth:100%; width:40px' id='f'>
	6
	</span>
	<span style='heigth:100%; width:40px' id='g'>
	7
	</span>
	<span style='heigth:100%; width:0px;display:none' id='h'>
	8
	</span>
  </div>
  <input type='button' value=' ' onclick='javascript:soliderControl.left()'>
  <input type='button' value=' ' onclick='javascript:soliderControl.rigth()'>
   <script>
	function solider(objName){
		this.control=$("#"+objName);
		this.objName=objName
		this.maxSpanNum=7;
		this.minSpanNum=1;
		this.moveType=0;			//      0         1          
		var temp=this;
		this.control.bind('mousewheel',function (event, delta){
			if(temp.moveType==0){return;}
			temp.moveType=0
			$('#message').html("mousewheel:"+temp.moveType)
			var dir = event.wheelDelta > 0 ? 'Up' : 'Down'
			//alert(dir+":"+event.wheelDelta)
			if(dir=='Up'){
				temp.left()
				temp.moveType=1
			}else if(dir=='Down'){
				temp.rigth()
				temp.moveType=1
				
			}
			return false;
		})
		this.control.bind('mouseover',function (){
			temp.moveType=1
			$('#message').html("mouseover:"+temp.moveType)
		})
		this.control.bind('mouseout',function (){
			temp.moveType=0
			$('#message').html("mouseout:"+temp.moveType)
		})
		//     
		//                              
		this.left=function (){
			//                        
			if(this.checkHidden(1)<1){
				return;
			}
			//     
			if(this.checkVisible()<=this.minSpanNum){
				return;
			}
			this.leftHide($("#"+this.objName+" span:visible:first"))
			//                            
			if(this.checkVisible()>this.maxSpanNum){
				return;
			}
			var nodeName=$("#"+this.objName+" span:visible:last").attr('id');
			this.rigthShow($('#'+nodeName+" +span:hidden:first"));
		}
		//    
		this.rigth=function (){
			//     
			if(this.checkVisible()<this.minSpanNum){
				return;
			}
			//                        
			if(this.checkHidden(0).attr('id')==null){
				return;
			}
			var nodeName=$("#"+this.objName+" span:visible:first").attr('id');
			this.rigthShow( $('#'+nodeName).prev());
			//                            
			if(this.checkVisible()>this.maxSpanNum){
				this.rigthHide($("#"+this.objName+" span:visible:last"))
			}
		}
		//              
		this.checkVisible=function (){
			return $("#"+this.objName+" span:visible").length;
		} 
		//           
		this.checkHidden=function (type){
			//type 0         1        
			if(0==type){
				var nodeName=$("#"+this.objName+" span:visible:first").attr('id');
				return $('#'+nodeName).prev();
			}else if(1==type){
				var nodeName=$("#"+this.objName+" span:visible:last").attr('id');
				return $('#'+nodeName+" +span:hidden:first").length;
			}
		}
		//      
		this.leftHide=function (jobj){
			jobj.animate({width:'0'},"normal",function(){$(this).hide();})
		}
		//      
		this.leftShow=function (jobj){
			jobj.animate({width:'46'},"normal",function(){$(this).show();})
		}
		//      
		this.rigthHide=function (jobj){
			jobj.animate({width:'0'},"normal",function(){$(this).hide();})
		}
		//      
		this.rigthShow=function (jobj){
			jobj.animate({width:'46'},"normal",function(){$(this).show();})
		}
	}
	var soliderControl=new solider("messageBT");
 </script>
 <div id='message'>
	1111111111111
 </div>
 </BODY>
</HTML>
=-=심심할 때 쓴 글인데 비판 경배 부탁드립니다.
마우스 스크롤 jquery 지원 첫 번째 발표 흥분 중

좋은 웹페이지 즐겨찾기