无缝滚动

//无缝滚动
var oCase = document.getElementById('tattoo_case_bottom');
var oCul  = oCase.getElementsByTagName('ul')[0];
var oCleft = oCase.getElementsByClassName('caseleft')[0];
var oCright = oCase.getElementsByClassName('caseright')[0];
var oCtimer = setInterval(mov,10);
var oCspeed = 1;
oCul.innerHTML += oCul.innerHTML;
oCul.style.width = oCul.offsetWidth*2 + 'px';
function mov(){
    if(oCul.offsetLeft > 0){
        oCul.style.left = -oCul.offsetWidth/2 + 'px';
    }
    if (oCul.offsetLeft < -oCul.offsetWidth/2){
        oCul.style.left = 0;
    }
    oCul.style.left = oCul.offsetLeft + oCspeed + 'px';
}
oCul.onmouseover = function(){
    clearInterval(oCtimer);
}
oCul.onmouseout  = function () {
    oCtimer = setInterval(mov,10);
}
oCleft.onclick = function(){
    oCspeed = -1;
}
oCright.onclick = function() {
    oCspeed = 1;
}

posted @ 2018-08-21 17:03  Header!  阅读(71)  评论(0)    收藏  举报