列表标题滚动漂浮
作者:chrispy
//列表标题滚动漂浮
var pre_scrollTop = '0px';
function listScoll(){
var listBoxId = document.getElementById('listBox');
var pre_scrollTop = listBoxId.scrollTop;;//滚动条事件之前文档滚动高度
var pre_scrollLeft = listBoxId.scrollLeft;;//滚动条事件之前文档滚动宽度
var obj_th = document.getElementsByClassName("list-title-box")[0];
$('#caseList').css({'padding-top':'40px','position':'relative'});
$('.list-title-box').css({'position':'absolute','left':'0','top':pre_scrollTop});
listBoxId.onscroll = function(){
if(pre_scrollTop != listBoxId.scrollTop){
//滚动了竖直滚动条
pre_scrollTop = listBoxId.scrollTop;
if(obj_th){
obj_th.style.top = listBoxId.scrollTop + "px";
}
}else if(pre_scrollLeft != listBoxId.scrollLeft){
//滚动了水平滚动条
pre_scrollLeft = listBoxId.scrollLeft;
}
};
}