WebRoot/static/base/lib/iscroll-master/src/infinite/infinite.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
_initInfinite: function () {
var el = this.options.infiniteElements;
this.infiniteElements = typeof el == 'string' ? document.querySelectorAll(el) : el;
this.infiniteLength = this.infiniteElements.length;
this.infiniteMaster = this.infiniteElements[0];
this.infiniteElementHeight = this.infiniteMaster.offsetHeight;
this.infiniteHeight = this.infiniteLength * this.infiniteElementHeight;
this.options.cacheSize = this.options.cacheSize || 1000;
this.infiniteCacheBuffer = Math.round(this.options.cacheSize / 4);
//this.infiniteCache = {};
this.options.dataset.call(this, 0, this.options.cacheSize);
this.on('refresh', function () {
var elementsPerPage = Math.ceil(this.wrapperHeight / this.infiniteElementHeight);
this.infiniteUpperBufferSize = Math.floor((this.infiniteLength - elementsPerPage) / 2);
this.reorderInfinite();
});
this.on('scroll', this.reorderInfinite);
},
// TO-DO: clean up the mess
reorderInfinite: function () {
var center = -this.y + this.wrapperHeight / 2;
var minorPhase = Math.max(Math.floor(-this.y / this.infiniteElementHeight) - this.infiniteUpperBufferSize, 0),
majorPhase = Math.floor(minorPhase / this.infiniteLength),
phase = minorPhase - majorPhase * this.infiniteLength;
var top = 0;
var i = 0;
var update = [];
//var cachePhase = Math.floor((minorPhase + this.infiniteLength / 2) / this.infiniteCacheBuffer);
var cachePhase = Math.floor(minorPhase / this.infiniteCacheBuffer);
while ( i < this.infiniteLength ) {
top = i * this.infiniteElementHeight + majorPhase * this.infiniteHeight;
if ( phase > i ) {
top += this.infiniteElementHeight * this.infiniteLength;
}
if ( this.infiniteElements[i]._top !== top ) {
this.infiniteElements[i]._phase = top / this.infiniteElementHeight;
if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
this.infiniteElements[i]._top = top;
if ( this.options.infiniteUseTransform ) {
this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ;
} else {
this.infiniteElements[i].style.top = top + 'px';
}
update.push(this.infiniteElements[i]);
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
