|
|
@ -2539,6 +2539,7 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
var self = this, o = this.options; |
|
|
|
var self = this, o = this.options; |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
|
|
|
|
this.renderRange = {}; |
|
|
|
this._scrollLock = false; |
|
|
|
this._scrollLock = false; |
|
|
|
this._debounceRelease = BI.debounce(function () { |
|
|
|
this._debounceRelease = BI.debounce(function () { |
|
|
|
self._scrollLock = false; |
|
|
|
self._scrollLock = false; |
|
|
@ -2588,12 +2589,10 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
for (var index = 0, len = o.items.length; index < len; index++) { |
|
|
|
for (var index = 0, len = o.items.length; index < len; index++) { |
|
|
|
var cellMetadatum = o.cellSizeAndPositionGetter(index); |
|
|
|
var cellMetadatum = o.cellSizeAndPositionGetter(index); |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || |
|
|
|
cellMetadatum.height == null || isNaN(cellMetadatum.height) || |
|
|
|
|
|
|
|
cellMetadatum.width == null || isNaN(cellMetadatum.width) || |
|
|
|
cellMetadatum.width == null || isNaN(cellMetadatum.width) || |
|
|
|
cellMetadatum.x == null || isNaN(cellMetadatum.x) || |
|
|
|
cellMetadatum.x == null || isNaN(cellMetadatum.x) || |
|
|
|
cellMetadatum.y == null || isNaN(cellMetadatum.y) |
|
|
|
cellMetadatum.y == null || isNaN(cellMetadatum.y)) { |
|
|
|
) { |
|
|
|
|
|
|
|
throw Error(); |
|
|
|
throw Error(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2634,8 +2633,38 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
var top = Math.max(0, scrollTop - o.verticalOverscanSize); |
|
|
|
var top = Math.max(0, scrollTop - o.verticalOverscanSize); |
|
|
|
var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); |
|
|
|
var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); |
|
|
|
var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); |
|
|
|
var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); |
|
|
|
|
|
|
|
if (right > 0 && bottom > 0) { |
|
|
|
|
|
|
|
//如果滚动的区间并没有超出渲染的范围
|
|
|
|
|
|
|
|
if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); |
|
|
|
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); |
|
|
|
var renderedCells = [], renderedKeys = []; |
|
|
|
var renderedCells = [], renderedKeys = []; |
|
|
|
|
|
|
|
//存储所有的left和top
|
|
|
|
|
|
|
|
var lefts = {}, tops = {}; |
|
|
|
|
|
|
|
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { |
|
|
|
|
|
|
|
var datum = childrenToDisplay[i]; |
|
|
|
|
|
|
|
lefts[datum.x] = datum.x; |
|
|
|
|
|
|
|
lefts[datum.x + datum.width] = datum.x + datum.width; |
|
|
|
|
|
|
|
tops[datum.y] = datum.y; |
|
|
|
|
|
|
|
tops[datum.y + datum.height] = datum.y + datum.height; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lefts = BI.toArray(lefts); |
|
|
|
|
|
|
|
tops = BI.toArray(tops); |
|
|
|
|
|
|
|
var leftMap = BI.invert(lefts); |
|
|
|
|
|
|
|
var topMap = BI.invert(tops); |
|
|
|
|
|
|
|
//存储上下左右四个边界
|
|
|
|
|
|
|
|
var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {}; |
|
|
|
|
|
|
|
var assertMinBorder = function (border, offset) { |
|
|
|
|
|
|
|
if (border[offset] == null) { |
|
|
|
|
|
|
|
border[offset] = Number.MAX_VALUE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var assertMaxBorder = function (border, offset) { |
|
|
|
|
|
|
|
if (border[offset] == null) { |
|
|
|
|
|
|
|
border[offset] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { |
|
|
|
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { |
|
|
|
var datum = childrenToDisplay[i]; |
|
|
|
var datum = childrenToDisplay[i]; |
|
|
|
var index = BI.deepIndexOf(this.renderedKeys, datum.index); |
|
|
|
var index = BI.deepIndexOf(this.renderedKeys, datum.index); |
|
|
@ -2673,6 +2702,25 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
_height: datum.height |
|
|
|
_height: datum.height |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var startTopIndex = topMap[datum.y] | 0; |
|
|
|
|
|
|
|
var endTopIndex = topMap[datum.y + datum.height] | 0; |
|
|
|
|
|
|
|
for (var k = startTopIndex; k <= endTopIndex; k++) { |
|
|
|
|
|
|
|
var t = tops[k]; |
|
|
|
|
|
|
|
assertMinBorder(leftBorder, t); |
|
|
|
|
|
|
|
assertMaxBorder(rightBorder, t); |
|
|
|
|
|
|
|
leftBorder[t] = Math.min(leftBorder[t], datum.x); |
|
|
|
|
|
|
|
rightBorder[t] = Math.max(rightBorder[t], datum.x + datum.width); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var startLeftIndex = leftMap[datum.x] | 0; |
|
|
|
|
|
|
|
var endLeftIndex = leftMap[datum.x + datum.width] | 0; |
|
|
|
|
|
|
|
for (var k = startLeftIndex; k <= endLeftIndex; k++) { |
|
|
|
|
|
|
|
var l = lefts[k]; |
|
|
|
|
|
|
|
assertMinBorder(topBorder, l); |
|
|
|
|
|
|
|
assertMaxBorder(bottomBorder, l); |
|
|
|
|
|
|
|
topBorder[l] = Math.min(topBorder[l], datum.y); |
|
|
|
|
|
|
|
bottomBorder[l] = Math.max(bottomBorder[l], datum.y + datum.height); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderedKeys.push(datum.index); |
|
|
|
renderedKeys.push(datum.index); |
|
|
|
} |
|
|
|
} |
|
|
|
//已存在的, 需要添加的和需要删除的
|
|
|
|
//已存在的, 需要添加的和需要删除的
|
|
|
@ -2703,6 +2751,16 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
this.container.addItems(addedItems); |
|
|
|
this.container.addItems(addedItems); |
|
|
|
this.renderedCells = renderedCells; |
|
|
|
this.renderedCells = renderedCells; |
|
|
|
this.renderedKeys = renderedKeys; |
|
|
|
this.renderedKeys = renderedKeys; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Todo 左右比较特殊
|
|
|
|
|
|
|
|
var minX = BI.min(leftBorder); |
|
|
|
|
|
|
|
var maxX = BI.max(rightBorder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var minY = BI.max(topBorder); |
|
|
|
|
|
|
|
var maxY = BI.min(bottomBorder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_getMaxScrollLeft: function () { |
|
|
|
_getMaxScrollLeft: function () { |
|
|
@ -2789,6 +2847,7 @@ BI.Collection = BI.inherit(BI.Widget, { |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
|
|
|
|
this.renderRange = {}; |
|
|
|
this._scrollLock = false; |
|
|
|
this._scrollLock = false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -14613,6 +14672,7 @@ BI.Grid = BI.inherit(BI.Widget, { |
|
|
|
var self = this, o = this.options; |
|
|
|
var self = this, o = this.options; |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedCells = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
this.renderedKeys = []; |
|
|
|
|
|
|
|
this.renderRange = {}; |
|
|
|
this._scrollLock = false; |
|
|
|
this._scrollLock = false; |
|
|
|
this._debounceRelease = BI.debounce(function () { |
|
|
|
this._debounceRelease = BI.debounce(function () { |
|
|
|
self._scrollLock = false; |
|
|
|
self._scrollLock = false; |
|
|
@ -14661,13 +14721,17 @@ BI.Grid = BI.inherit(BI.Widget, { |
|
|
|
_calculateChildrenToRender: function () { |
|
|
|
_calculateChildrenToRender: function () { |
|
|
|
var self = this, o = this.options; |
|
|
|
var self = this, o = this.options; |
|
|
|
|
|
|
|
|
|
|
|
var width = o.width, height = o.height, scrollLeft = BI.clamp(o.scrollLeft, 0, this._getMaxScrollLeft()), scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop()), |
|
|
|
var width = o.width, height = o.height, scrollLeft = BI.clamp(o.scrollLeft, 0, this._getMaxScrollLeft()), |
|
|
|
|
|
|
|
scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop()), |
|
|
|
overscanColumnCount = o.overscanColumnCount, overscanRowCount = o.overscanRowCount; |
|
|
|
overscanColumnCount = o.overscanColumnCount, overscanRowCount = o.overscanRowCount; |
|
|
|
|
|
|
|
|
|
|
|
if (height > 0 && width > 0) { |
|
|
|
if (height > 0 && width > 0) { |
|
|
|
var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft); |
|
|
|
var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft); |
|
|
|
var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop); |
|
|
|
var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (BI.isEmpty(visibleColumnIndices) || BI.isEmpty(visibleRowIndices)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); |
|
|
|
var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); |
|
|
|
var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); |
|
|
|
var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); |
|
|
|
|
|
|
|
|
|
|
@ -14685,8 +14749,22 @@ BI.Grid = BI.inherit(BI.Widget, { |
|
|
|
var rowStartIndex = overscanRowIndices.overscanStartIndex; |
|
|
|
var rowStartIndex = overscanRowIndices.overscanStartIndex; |
|
|
|
var rowStopIndex = overscanRowIndices.overscanStopIndex; |
|
|
|
var rowStopIndex = overscanRowIndices.overscanStopIndex; |
|
|
|
|
|
|
|
|
|
|
|
var renderedCells = [], renderedKeys = []; |
|
|
|
//算区间size
|
|
|
|
|
|
|
|
var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex); |
|
|
|
|
|
|
|
var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex); |
|
|
|
|
|
|
|
var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex); |
|
|
|
|
|
|
|
var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex); |
|
|
|
|
|
|
|
var top = minRowDatum.offset + verticalOffsetAdjustment; |
|
|
|
|
|
|
|
var left = minColumnDatum.offset + horizontalOffsetAdjustment; |
|
|
|
|
|
|
|
var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size; |
|
|
|
|
|
|
|
var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size; |
|
|
|
|
|
|
|
//如果滚动的区间并没有超出渲染的范围
|
|
|
|
|
|
|
|
if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renderedCells = [], renderedKeys = []; |
|
|
|
|
|
|
|
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; |
|
|
|
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { |
|
|
|
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { |
|
|
|
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); |
|
|
|
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); |
|
|
|
|
|
|
|
|
|
|
@ -14731,6 +14809,10 @@ BI.Grid = BI.inherit(BI.Widget, { |
|
|
|
_height: rowDatum.size |
|
|
|
_height: rowDatum.size |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment); |
|
|
|
|
|
|
|
maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size); |
|
|
|
|
|
|
|
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); |
|
|
|
|
|
|
|
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); |
|
|
|
renderedKeys.push(key); |
|
|
|
renderedKeys.push(key); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -14762,6 +14844,7 @@ BI.Grid = BI.inherit(BI.Widget, { |
|
|
|
this.container.addItems(addedItems); |
|
|
|
this.container.addItems(addedItems); |
|
|
|
this.renderedCells = renderedCells; |
|
|
|
this.renderedCells = renderedCells; |
|
|
|
this.renderedKeys = renderedKeys; |
|
|
|
this.renderedKeys = renderedKeys; |
|
|
|
|
|
|
|
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|