📄 listscrolleffect.js
字号:
this.tr = this.tabObj.rows[0];
this.originstr = this.tr.cells[0].innerHTML;
//得到滚动的表格
this.realTable = GetRealTable(this.tr);
if (this.direction == "up" || this.direction == "down")
{
//计算可见区域高度
this.viewHeight = getViewHeight(this.m_nVisibleRowsNum,this.realTable);
//计算复制表格次数
this.copyNum = copyNum(this.realTable,this.m_nEveryScrollRowOrColNum,this.m_nDelayTime,this.m_nScrollSpeed,this.viewHeight,this.tableHeight,true);
if ((is_scroll.ns || is_scroll.ff) && (this.copyNum > 2))
this.copyNum = 2;
//向数组赋值
this.distanceArray = getArray(this.copyNum,this.realTable,true);
//设置滚动的层
var spaceTab = "<table width=" + this.tableWidth + " height=" + this.viewHeight + " border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td></td></tr></table>";
var oldHtml = this.spanObj.innerHTML;
var newHtml = "";
for (var i = 0;i < this.copyNum; i++)
{
newHtml += oldHtml;
}
newHtml = spaceTab + newHtml + spaceTab;
var nht = "<div id=\"" + this.spanId + "\" style=\"position:relative; overflow: hidden; Height:" + this.viewHeight + "px ;width:" + this.tableWidth + ";\">" +
" <div id=\"" + this.rand_id+ "\" name=\"" + this.rand_id + "\" style=\"position:relative; visibility: hidden;\">" + newHtml + "</div></div>";
if (this.spanObj.parentNode)
this.spanObj.parentNode.innerHTML = nht;
else if (this.spanObj.parentElement)
this.spanObj.parentElement.innerHTML = nht;
this.newSpan = document.getElementById(this.rand_id);
this.mozillaHeight = this.viewHeight * 2 + this.copyNum * this.tableHeight;
if (this.direction == "up")
{
this.newSpan.style.top = -this.viewHeight;
this.m_nScrollDistance = this.viewHeight;
this.step = 0;
this.newSpan.style.visibility = 'visible';
}
else if (this.direction == "down")
{
this.newSpan.style.top = -(this.mozillaHeight - this.viewHeight * 2) ;
this.step = this.distanceArray.length - this.m_nEveryScrollRowOrColNum;
this.m_nScrollDistance = this.mozillaHeight - this.viewHeight * 2;
this.newSpan.style.visibility = 'visible';
}
}
else if (this.direction == "left" || this.direction == "right")
{
var cellsWidth = parseInt(this.tableWidth / this.realTable.rows[0].cells.length);
this.offsetValue = cellsWidth - (this.myclipw % cellsWidth);
if(this.direction == "left")
addSpaceHori(this.tr,(this.myclipw+this.offsetValue),false);
else
addSpaceHori(this.tr,this.myclipw,false);
//计算复制表格次数
this.copyNum = copyNum(this.realTable,this.m_nEveryScrollRowOrColNum,this.m_nDelayTime,this.m_nScrollSpeed,this.viewHeight,this.tableHeight,false);
if (is_scroll.ns || is_scroll.ff || is_scroll.op)
this.copyNum = 1;
//向数组赋值
this.distanceArray = getArray(this.copyNum,this.realTable,false);
//拷贝table
copyTable(this.tabObj,this.originstr,this.tr,this.copyNum,false);
//添加下方空白
if(this.direction == "right")
addSpaceHori(this.tr,this.myclipw + this.offsetValue,true);
else
addSpaceHori(this.tr,this.myclipw,true);
var nht = "";
nht = "<div id=\"" + this.spanId + "\" style=\"position:relative; overflow: hidden; Height:" + this.tableHeight + "px ;width:" + this.myclipw + "px;\">" +
" <div id=\"" + this.rand_id+ "\" name=\"" + this.rand_id + "\" style=\"position:relative; visibility: hidden;\">" + this.spanObj.innerHTML + "</div></div>";
if (this.spanObj.parentNode)
this.spanObj.parentNode.innerHTML = nht;
else if (this.spanObj.parentElement)
this.spanObj.parentElement.innerHTML = nht;
this.newSpan = document.getElementById(this.rand_id);
this.mozillawidth = this.myclipw * 2 + (this.copyNum+1) * this.tableWidth +this.offsetValue;
if (this.direction == "left")
{
this.newSpan.style.left = -this.myclipw -this.offsetValue;
this.m_nScrollDistance = this.myclipw+this.offsetValue;
this.step = 0;
this.newSpan.style.visibility = 'visible';
}
else if (this.direction == "right")
{
this.newSpan.style.left = -(this.mozillawidth - this.myclipw * 2 -this.offsetValue);
this.step = this.distanceArray.length-this.m_nEveryScrollRowOrColNum;
this.m_nScrollDistance = this.mozillawidth - this.myclipw * 2 -this.offsetValue ;
this.newSpan.style.visibility = 'visible';
}
}
this.m_nScrollInterval = 1000 / (this.m_nScrollSpeed / this.c_scroll_unit);
this.m_nDelayTime = this.m_nDelayTime * 1000;
this.m_nScrollInterval = parseInt(this.m_nScrollInterval);
this.clearScrollTimer = function ()
{
if (this.scrollTimerId)
clearTimeout(this.scrollTimerId);
this.scrollTimerId = null;
}
this.start = function()
{
this.clearScrollTimer();
if (this.m_nCurrState != 0) return;
var offset = 0;
if (this.direction == "up")
{
offset = this.getTopNumAbs();
this.m_nCurrScrollDistance = offset;
//spanObj已经到最后一行
var tmp = this.mozillaHeight - offset;
if (tmp <= this.viewHeight)
{
this.newSpan.style.top = 0;
this.m_nScrollDistance = 0;
this.step = 0;
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
else if (this.m_nCurrScrollDistance >= this.m_nScrollDistance)
{
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nDelayTime);
}
else
{
offset = this.getTopNumAbs();
this.newSpan.style.top = -(this.c_scroll_unit + offset);
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
}
else if (this.direction == "left")
{
offset = this.getLeftNumAbs();
this.m_nCurrScrollDistance = offset;
//spanObj已经到最后一行
var tmp = this.mozillawidth - offset;
if (tmp <= this.myclipw)
{
this.newSpan.style.left = 0 + "px";
this.m_nScrollDistance = 0;
this.step = 0;
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
else if (this.m_nCurrScrollDistance >= this.m_nScrollDistance)
{
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nDelayTime);
}
else
{
offset = this.getLeftNumAbs();
this.newSpan.style.left = -(this.c_scroll_unit + offset)+ "px";
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
}
else if (this.direction == "down")
{
offset = this.getTopNumAbs();
this.m_nCurrScrollDistance = offset;
if (offset == 0)
{
this.newSpan.style.top = -(this.mozillaHeight - this.viewHeight);
this.m_nScrollDistance = this.mozillaHeight - this.viewHeight;
this.step = this.distanceArray.length - this.m_nEveryScrollRowOrColNum;
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
else if (this.m_nCurrScrollDistance <= this.m_nScrollDistance)
{
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nDelayTime);
}
else
{
offset = this.getTopNumAbs();
this.newSpan.style.top = -(offset - this.c_scroll_unit );
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
}
else if (this.direction == "right")
{
offset = this.getLeftNumAbs();
this.m_nCurrScrollDistance = offset;
if (offset == 0)
{
this.newSpan.style.left = -(this.mozillawidth - this.myclipw) + "px";
this.m_nScrollDistance = this.mozillawidth - this.myclipw;
this.step = this.distanceArray.length - this.m_nEveryScrollRowOrColNum;
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
else if (this.m_nCurrScrollDistance <= this.m_nScrollDistance)
{
this.endscroll();
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nDelayTime);
}
else
{
offset = this.getLeftNumAbs();
this.newSpan.style.left = -(offset - this.c_scroll_unit )+ "px";
this.scrollTimerId = setTimeout(this.name + '.start()', this.m_nScrollInterval);
}
}
}
this.endscroll = function ()
{
this.m_nCurrDelayCounter = 0;
//重新设置m_nScrollDistance
if (this.direction == "up")
{
if (this.step >= this.distanceArray.length)
{
this.step = 0;
}
else
{
this.m_nScrollDistance = getNscrollDistance(this.m_nEveryScrollRowOrColNum,this.step,this.distanceArray,this.m_nScrollDistance,this.direction);
this.step += this.m_nEveryScrollRowOrColNum;
}
}
else if (this.direction == "left")
{
if (this.step >= this.distanceArray.length)
{
this.step = 0;
}
else
{
this.m_nScrollDistance = getNscrollDistance(this.m_nEveryScrollRowOrColNum,this.step,this.distanceArray,this.m_nScrollDistance,this.direction);
this.step += this.m_nEveryScrollRowOrColNum;
}
}
else if(this.direction == "down")
{
if (this.step <= 0)
{
this.step = this.distanceArray.length - this.m_nEveryScrollRowOrColNum;
}
else
{
this.m_nScrollDistance = getNscrollDistance(this.m_nEveryScrollRowOrColNum,this.step,this.distanceArray,this.m_nScrollDistance,this.direction);
this.step -= this.m_nEveryScrollRowOrColNum;
}
}
else if(this.direction == "right")
{
if (this.step <= 0)
{
this.step = this.distanceArray.length - this.m_nEveryScrollRowOrColNum;
}
else
{
this.m_nScrollDistance = getNscrollDistance(this.m_nEveryScrollRowOrColNum,this.step,this.distanceArray,this.m_nScrollDistance,this.direction);
this.step -= this.m_nEveryScrollRowOrColNum;
}
}
}
this.getTopNumAbs = function()
{
return Math.abs(parseInt(this.newSpan.style.top));
}
this.getLeftNumAbs = function()
{
return Math.abs(parseInt(this.newSpan.style.left));
}
window[this.name] = this;
}
siteem_initScroll._name = -1;
function getTable(obj)
{
var tabObj = null;
for (var count = 0; count < obj.childNodes.length; count++)
{
if (obj.childNodes[count].nodeName == "TABLE")
{
tabObj = obj.childNodes[count]
break;
}
}
return tabObj;
}
function GetRealTable(tr)
{
var tabObj = null;
for (var count1 = 0; count1 < tr.cells[0].childNodes.length; count1++)
{
if (tr.cells[0].childNodes[count1].nodeName == "TABLE")
{
tabObj = tr.cells[0].childNodes[count1]
break;
}
}
return tabObj;
}
function getViewHeight(viewTr,realTable)
{
var tmp = 0;
for (var count = 0; count < viewTr; count ++)
tmp += realTable.rows[count].offsetHeight;
return tmp;
}
function addSpaceVert(tr,obj,viewHeight,flag)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -