Browse Source

Pull request #2178: 无JIRA任务 整理一下

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '14e76fa86124fc9de1b5751a78079bc927f35979':
  性能优化
es6
guy 3 years ago
parent
commit
47130ba0a9
  1. 25
      src/base/collection/collection.js
  2. 27
      src/base/grid/grid.js

25
src/base/collection/collection.js

@ -161,20 +161,20 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
var child;
if (index >= 0) {
if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width;
// if (datum.width !== this.renderedCells[index]._width) {
// this.renderedCells[index]._width = datum.width;
this.renderedCells[index].el.setWidth(datum.width);
}
if (datum.height !== this.renderedCells[index]._height) {
this.renderedCells[index]._height = datum.height;
// }
// if (datum.height !== this.renderedCells[index]._height) {
// this.renderedCells[index]._height = datum.height;
this.renderedCells[index].el.setHeight(datum.height);
}
if (this.renderedCells[index]._left !== datum.x) {
// }
// if (this.renderedCells[index]._left !== datum.x) {
this.renderedCells[index].el.element.css("left", datum.x / BI.pixRatio + BI.pixUnit);
}
if (this.renderedCells[index]._top !== datum.y) {
// }
// if (this.renderedCells[index]._top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit);
}
// }
renderedCells.push(child = this.renderedCells[index]);
} else {
child = BI._lazyCreateWidget(BI.extend({
@ -192,8 +192,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
top: datum.y,
_left: datum.x,
_top: datum.y,
_width: datum.width,
_height: datum.height
// _width: datum.width,
// _height: datum.height
});
}
var startTopIndex = topMap[datum.y] | 0;
@ -281,6 +281,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this.container.setWidth(this._width);
this.container.setHeight(this._height);
this._debounceRelease();
this._calculateChildrenToRender();
// 元素未挂载时不能设置scrollTop
try {

27
src/base/grid/grid.js

@ -137,20 +137,20 @@ BI.GridView = BI.inherit(BI.Widget, {
var index = this.renderedKeys[key] && this.renderedKeys[key][2];
var child;
if (index >= 0) {
if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size;
// if (columnDatum.size !== this.renderedCells[index]._width) {
// this.renderedCells[index]._width = columnDatum.size;
this.renderedCells[index].el.setWidth(columnDatum.size);
}
if (rowDatum.size !== this.renderedCells[index]._height) {
this.renderedCells[index]._height = rowDatum.size;
// }
// if (rowDatum.size !== this.renderedCells[index]._height) {
// this.renderedCells[index]._height = rowDatum.size;
this.renderedCells[index].el.setHeight(rowDatum.size);
}
if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
// }
// if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit);
}
if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
// }
// if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit);
}
// }
child = this.renderedCells[index].el;
renderedCells.push(this.renderedCells[index]);
} else {
@ -171,8 +171,8 @@ BI.GridView = BI.inherit(BI.Widget, {
top: rowDatum.offset + verticalOffsetAdjustment,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment,
_width: columnDatum.size,
_height: rowDatum.size
// _width: columnDatum.size,
// _height: rowDatum.size
});
}
minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment);
@ -224,7 +224,7 @@ BI.GridView = BI.inherit(BI.Widget, {
/**
* 获取真实的可滚动的最大宽度
* 对于grid_view如果没有全部渲染过this._columnSizeAndPositionManager.getTotalSize获取的宽度是不准确的
* 因此在调用setScrollLeft等函数时会造成没法移动到最右端(预估可移动具体太短)
* 因此在调用setScrollLeft等函数时会造成没法移动到最右端(预估可移动距离太短)
*/
_getRealMaxScrollLeft: function () {
var o = this.options;
@ -267,6 +267,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this._columnSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.columnCount, o.columnWidthGetter, o.estimatedColumnSize);
this._rowSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.rowCount, o.rowHeightGetter, o.estimatedRowSize);
this._debounceRelease();
this._calculateChildrenToRender();
// 元素未挂载时不能设置scrollTop
try {

Loading…
Cancel
Save