http://www.fssccqchl.top/(这个是地址,轮播图下面那部分就是出bug的动画,下面是源码,鼠标移出太快移入到另一张动画的时候就会卡住,所以要在移入前清楚所有动画,但是我用好几种办法还是不行,求大神解答) var odiv = document.getElementsByClassName("list-msg"); for(var i=0;i<odiv.length;i++) { odiv[i].index = i; odiv[i].onmouseover = startMove; odiv[i].onmouseout = startMove1; } var timer = null; function startMove(iTarget) { clearInterval(timer); var odiv = document.getElementsByClassName("list-msg"); var atext = document.getElementsByClassName("list-msg")[this.index].getElementsByTagName("a")[0]; timer = setInterval(function () { var speed = (iTarget - atext.offsetTop) / 10; speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed); console.log(atext.offsetTop); if (atext.offsetTop == iTarget) { clearInterval(timer); } else { atext.style.top = atext.offsetTop + speed + 'px'; } }, 30) } function startMove1() { iTarget = 190; clearInterval(timer); var odiv = document.getElementsByClassName("list-msg"); var atext = document.getElementsByClassName("list-msg")[this.index].getElementsByTagName("a")[0]; timer = setInterval(function () { var speed = (iTarget - atext.offsetTop) / 10; speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed); console.log(atext.offsetTop); if (atext.offsetTop == iTarget) { clearInterval(timer); } else { atext.style.top = atext.offsetTop + speed + 'px'; } }, 30) }
相关分类