鼠标滚轮滑动整屏幕

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 

<script type="text/javascript" src="http://luxury.bjhoutai.com/js/jquery-1.8.2.min.js"></script> 

<script type="text/javascript" src="http://img.zjhm.com/0Allppzt/js/jquery.mousewheel.min.js"></script>

</head>

<style>

*{ margin:0px; padding:0px; }

img{ border:0;width:100%;margin:0px; padding:0px; *margin-top:-3px;}

body{overflow-x: hidden; overflow-y: hidden;} 

#mrt{position:fixed; top:0px;}

</style>

<body>

<div id='mrt'>

    <img src='http://img.zjhm.com/newluxury/images/jdt0101_660×372.jpg'>

    <img src='http://img.zjhm.com/newluxury/images/jdt0102_660×372.jpg'>

    <img src='http://img.zjhm.com/newluxury/images/jdt0103_660×372.jpg'>

    <img src='http://img.zjhm.com/newluxury/images/jdt0104_660×372.jpg'>

</div>

<script>

var timing,mrt_top=0,time=0,windowsheight = document.documentElement.clientHeight;  

for(var  x= 0; x<$('#mrt').find('img').length;x++){

$('#mrt').find('img')[x].style.height = windowsheight+'px';

}

$(document).mousewheel(function (e, detail) {  //detail鼠标上下滑动,正负值

if(time==0){

time = 1; 

timing = setTimeout('test()',1000);

mrt_top = $('#mrt').offset().top;

if(detail>0 && mrt_top<0){   

$("#mrt").animate({top:mrt_top+windowsheight+"px"},1000);

}else if(detail<0 && mrt_top>(-windowsheight*($('#mrt').find('img').length-1))){  

$("#mrt").animate({top:mrt_top-windowsheight+"px"},1000);

}else if(mrt_top<=(-windowsheight*($('#mrt').find('img').length-1)) || mrt_top>=0){

clearTimeout(timing);

time = 0;

}

}

})

function test(){time--;}

</script>

</body>

</html>

posted @ 2015-04-23 11:36  mrt_yy  阅读(215)  评论(0编辑  收藏  举报