|
|
@ -73,11 +73,6 @@ BI.VirtualList = BI.inherit(BI.Widget, { |
|
|
|
var items = o.items.slice(index, index + o.blockSize); |
|
|
|
var items = o.items.slice(index, index + o.blockSize); |
|
|
|
this.container.addItems(items, this); |
|
|
|
this.container.addItems(items, this); |
|
|
|
var addedHeight = getElementHeight() - lastHeight; |
|
|
|
var addedHeight = getElementHeight() - lastHeight; |
|
|
|
this.cache[cnt] = { |
|
|
|
|
|
|
|
index: index, |
|
|
|
|
|
|
|
scrollTop: lastHeight, |
|
|
|
|
|
|
|
height: addedHeight |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.tree.set(cnt, addedHeight); |
|
|
|
this.tree.set(cnt, addedHeight); |
|
|
|
this.renderedIndex = cnt; |
|
|
|
this.renderedIndex = cnt; |
|
|
|
cnt++; |
|
|
|
cnt++; |
|
|
@ -95,7 +90,10 @@ BI.VirtualList = BI.inherit(BI.Widget, { |
|
|
|
var end = this.tree.leastUpperBound(minContentHeightTo); |
|
|
|
var end = this.tree.leastUpperBound(minContentHeightTo); |
|
|
|
var needDestroyed = [], needMount = []; |
|
|
|
var needDestroyed = [], needMount = []; |
|
|
|
for (var i = 0; i < start; i++) { |
|
|
|
for (var i = 0; i < start; i++) { |
|
|
|
var index = this.cache[i].index; |
|
|
|
var index = i * o.blockSize; |
|
|
|
|
|
|
|
if (!this.cache[i]) { |
|
|
|
|
|
|
|
this.cache[i] = {}; |
|
|
|
|
|
|
|
} |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) { |
|
|
|
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) { |
|
|
|
needDestroyed.push(this.container._children[j]); |
|
|
|
needDestroyed.push(this.container._children[j]); |
|
|
@ -105,7 +103,10 @@ BI.VirtualList = BI.inherit(BI.Widget, { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (var i = end + 1; i <= this.renderedIndex; i++) { |
|
|
|
for (var i = end + 1; i <= this.renderedIndex; i++) { |
|
|
|
var index = this.cache[i].index; |
|
|
|
var index = i * o.blockSize; |
|
|
|
|
|
|
|
if (!this.cache[i]) { |
|
|
|
|
|
|
|
this.cache[i] = {}; |
|
|
|
|
|
|
|
} |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) { |
|
|
|
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) { |
|
|
|
needDestroyed.push(this.container._children[j]); |
|
|
|
needDestroyed.push(this.container._children[j]); |
|
|
@ -118,7 +119,10 @@ BI.VirtualList = BI.inherit(BI.Widget, { |
|
|
|
lastFragment = BI.Widget._renderEngine.createFragment(); |
|
|
|
lastFragment = BI.Widget._renderEngine.createFragment(); |
|
|
|
var currentFragment = firstFragment; |
|
|
|
var currentFragment = firstFragment; |
|
|
|
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) { |
|
|
|
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) { |
|
|
|
var index = this.cache[i].index; |
|
|
|
var index = i * o.blockSize; |
|
|
|
|
|
|
|
if (!this.cache[i]) { |
|
|
|
|
|
|
|
this.cache[i] = {}; |
|
|
|
|
|
|
|
} |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
if (!this.cache[i].destroyed) { |
|
|
|
currentFragment = lastFragment; |
|
|
|
currentFragment = lastFragment; |
|
|
|
} |
|
|
|
} |
|
|
@ -149,6 +153,7 @@ BI.VirtualList = BI.inherit(BI.Widget, { |
|
|
|
this.options.items = items; |
|
|
|
this.options.items = items; |
|
|
|
} |
|
|
|
} |
|
|
|
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize)); |
|
|
|
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize)); |
|
|
|
|
|
|
|
|
|
|
|
this._calculateBlocksToRender(); |
|
|
|
this._calculateBlocksToRender(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.element.scrollTop(o.scrollTop); |
|
|
|
this.element.scrollTop(o.scrollTop); |
|
|
|