大屏某区域滚动效果循环

// 数据自动滚动事件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

posted @ 2019-09-02 15:36  海底流  阅读(766)  评论(0编辑  收藏  举报