<!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=gb1312" />
<title>无缝滚动</title>
<style type="text/css">
body,div,ul,li{margin:0;padding:0;}
#box{position:relative;width:210px;height:700px;border:2px solid #5E8743;margin-left:960px;margin-top:200px}
#box div{position:absolute;top:50%;left:50%;width:160px;height:555px;overflow:hidden;margin:-285px 0 0 -80px;}
#box .up,#box .down{position:absolute;left:50%;width:48px;height:48px;z-index:10;cursor:pointer;overflow:hidden;margin-left:-24px;text-indent:-9999px;}
#box .up{top:10px;background-position:0 0;}
#box .down{bottom:10px;background-position:0 bottom;}
#box ul{position:absolute;width:160px;}
#box li{width:160px;height:37px;list-style:none;text-align:center;margin-left:8px}
#box a{color:#fff;font-weight:700;text-decoration:none;}
#box img{display:block;margin-bottom:5px;border:2px solid #ccc;}
</style>
<script type="text/javascript">
//获取id
function $ (id)
{
return typeof id === "string" ? document.getElementById(id) : id;
}
//获取tagName
function $$ (elem, oParent)
{
return (oParent || document).getElementsByTagName(elem);
}
//获取class
function $$$ (className, oParent)
{
var aClass = [];
var reClass = new RegExp("(//s|^)" + className + "($|//s)");
var aElem = $$("*", oParent);
for (var i = 0; i < aElem.length; i++) reClass.test(aElem[i].className) && aClass.push(aElem[i]);
return aClass
}
//初始化对象
function Roll ()
{
this.initialize.apply(this, arguments)
}
Roll.prototype =
{
initialize: function (obj)
{
var _this = this;
this.obj = $(obj);
this.oUp = $$$("up", this.obj)[0];
this.oDown = $$$("down", this.obj)[0];
this.oList = $$$("list", this.obj)[0];
this.aItem = this.oList.children;
this.timer = null;
this.iNow = 0;
this.iHeight = this.aItem[0].offsetHeight;
this.oUp.onclick = function ()
{
_this.up()
};
this.oDown.onclick = function ()
{
_this.down()
}
},
up: function ()
{
this.oList.insertBefore(this.aItem[this.aItem.length - 1], this.oList.firstChild);
this.oList.style.top = -this.iHeight + "px";
this.doMove(0)
},
down: function ()
{
this.doMove(-this.iHeight, function ()
{
this.oList.appendChild(this.aItem[0]);
this.oList.style.top = 0;
})
},
doMove: function (iTarget, callBack)
{
var _this = this;
clearInterval(this.timer)
this.timer = setInterval(function ()
{
var iSpeed = (iTarget - _this.oList.offsetTop) / 5;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
_this.oList.offsetTop == iTarget ? (clearInterval(_this.timer), callBack && callBack.apply(_this)) : _this.oList.style.top = iSpeed + _this.oList.offsetTop + "px"
}, 30)
}
};
window.onload = function ()
{
new Roll("box");
};
</script>
</head>
<body>
<div id="box">
    <span class="up"><img src="images/1.jpg"></span>
    <span class="down"><img src="images/1.jpg"></span>
    <div>
        <ul class="list">
            <li><a href="javascript:;"><img <img src="images/L-D.jpg" /></a></li>
            <li><a href="javascript:;"><img src="images/L-15.jpg"/></a></li>
            <li onclick="Jump(3)"><img src="images/L-14.jpg">14</li>
<li onclick="Jump(4)"><img src="images/L-13.jpg">13</li>
<li onclick="Jump(5)"><img src="images/L-12.jpg">12</li>
<li onclick="Jump(6)"><img src="images/L-11.jpg">11</li>
<li onclick="Jump(7)"><img src="images/L-10.jpg">10</li>
<li onclick="Jump(1)"><img src="images/L-9.jpg">9</li>
<li onclick="Jump(2)"><img src="images/L-8.jpg">8</li>
<li onclick="Jump(3)"><img src="images/L-7.jpg">7</li>
<li onclick="Jump(4)"><img src="images/L-6.jpg">6</li>
<li onclick="Jump(5)"><img src="images/L-5.jpg">5</li>
<li onclick="Jump(6)"><img src="images/L-4.jpg">4</li>
<li onclick="Jump(7)"><img src="images/L-3.jpg">3</li>
<li onclick="Jump(1)"><img src="images/L-2.jpg">2</li>
<li onclick="Jump(2)"><img src="images/L-1.jpg">1</li>
<li onclick="Jump(4)"><img src="images/L-fu1.jpg">0</li>
        </ul>
    </div>
</div>
</body>
</html>我不想让它一直循环,想要它在到达最上或者最下的时候不能继续滚动