大屏某区域滚动效果循环

// 数据自动滚动事件BEGIN

var botTimer = null;  // 定时器对象

$('.tbody').hover(function () {
clearInterval(botTimer); // hover
}, function () {
scrollCore('tbodyScroll', 'tbody'); //out
}); //
function scrollCore(outerId, innerId) {
var winHei = $("#" + outerId).height();
var listHei = $("#" + innerId).height();
var top = document.getElementById(innerId).style.marginTop.replace('px', '') ? document.getElementById(innerId).style.marginTop.replace('px', '') : 0;
botTimer = setInterval(function () {
if (Math.abs(top) >= (listHei - winHei)) {
//请求最新数据
//listHei = loadNewData(innerId);
if (Math.abs(top) >= (listHei - winHei)) {
// 如果没有再多数据,就清空定时器
clearInterval(botTimer);
document.getElementById(innerId).style.marginTop = 0;
// 再次调函数
scrollCore(outerId, innerId);
} else {
top -= 1; 
document.getElementById(innerId).style.marginTop = top + 'px';//px
}
} else {
top -= 1;
document.getElementById(innerId).style.marginTop = top + 'px';//px
}
}, 200);
}
// END

猜你喜欢

转载自www.cnblogs.com/auto123-num/p/11446939.html