Browse Source

Merge pull request #1003 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '76534263f9d687d87b340bd17f2016487d3a1130':
  BI-47755 fix: virtual_list先滚动在populate报错
es6
guy 5 years ago
parent
commit
2e6ded7a12
  1. 3
      src/base/grid/grid.js
  2. 5
      src/base/list/virtuallist.js
  3. 5
      src/core/utils/prefixIntervalTree.js

3
src/base/grid/grid.js

@ -208,7 +208,8 @@ BI.GridView = BI.inherit(BI.Widget, {
BI.each(addSet, function (index, key) {
addedItems.push(renderedCells[key[2]]);
});
this.container.addItems(addedItems);
// 与listview一样, 给上下文
this.container.addItems(addedItems, this);
// 拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);

5
src/base/list/virtuallist.js

@ -151,7 +151,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
_clearChildren: function () {
BI.each(this.container._children, function (i, cell) {
cell && cell.el._destroy();
cell && cell._destroy();
});
this.container._children = {};
this.container.attr("items", []);
@ -162,6 +162,9 @@ BI.VirtualList = BI.inherit(BI.Widget, {
this._clearChildren();
this.cache = {};
this.options.scrollTop = 0;
// 依赖于cache的占位元素也要初始化
this.topBlank.setHeight(0);
this.bottomBlank.setHeight(0);
},
populate: function (items) {

5
src/core/utils/prefixIntervalTree.js

@ -23,13 +23,15 @@
BI.PrefixIntervalTree = function (xs) {
this._size = xs.length;
this._half = ceilLog2(this._size);
// _heap是一个_size两倍以上的堆
this._heap = new Int32Array(2 * this._half);
var i;
// 初始化 >= _size 的堆空间, 即叶子节点
for (i = 0; i < this._size; ++i) {
this._heap[this._half + i] = xs[i];
}
// 初始化 < _size 的堆空间, 即非叶子节点,根节点包含整个区间
for (i = this._half - 1; i > 0; --i) {
this._heap[i] = this._heap[2 * i] + this._heap[2 * i + 1];
}
@ -37,6 +39,7 @@
BI.PrefixIntervalTree.prototype = {
constructor: BI.PrefixIntervalTree,
// 往_half之后的空间set值,需要更新其所有祖先节点的值
set: function (index, value) {
var node = this._half + index;
this._heap[node] = value;

Loading…
Cancel
Save