JS

以下这段代码谁能帮我注释一下,谢谢:
function(){
var _this = this
var theItemT,i=0,totle=133,step = totle/10;
var T = setInterval(function(){
if(_this.index<_this.length-1){
_this.index++
theItemT = setInterval(function(){
i+= step
var top = _this.content.scrollTop()
if(i<=totle){
if(i==133) _this.content.scrollTop(133*_this.index)
else _this.content.scrollTop(top+step)
}
else{
clearInterval(theItemT)
i = 0
}

},20) }
else{
_this.content.scrollTop(0)
_this.index = -1
}

},this.Runspeed)
}

解决方案 »

  1.   

    你的代码够繁琐的,函数作为参数,参数里又有函数,搞得头晕,我给你整理了一下,等高人来解释吧!<script language="javascript">
    function ABC()
    {
    var _this = this;
    var theItemT,i=0,totle=133,step = totle/10;
    var T = setInterval
    (
    function()
    {
    if(_this.index<_this.length-1)
    {
    _this.index++;
    theItemT = setInterval(
    function()
    {
    i+= step;
    var top = _this.content.scrollTop();
    if(i<=totle)
    {
    if(i==133)
     _this.content.scrollTop(133*_this.index);
    else
     _this.content.scrollTop(top+step);
    }
    else
    {
    clearInterval(theItemT);
    i = 0;
    }
    },
    20);
    }
    else
    {
    _this.content.scrollTop(0);
    _this.index = -1;
    }
    }
    );
    }
    </script>