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. 33
      src/base/collection/collection.js
  2. 35
      src/base/grid/grid.js

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

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

Loading…
Cancel
Save