Skip to content

Commit

Permalink
perf: 优化未开启多行文本时的布局性能 close #2693 (#2728)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 authored May 17, 2024
1 parent ca7583d commit 439162d
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/s2-core/src/facet/base-facet.ts
Original file line number Diff line number Diff line change
@@ -341,7 +341,14 @@ export abstract class BaseFacet {
return height;
}

const isEnableHeightAdaptive =
colCellStyle?.maxLines! > 1 && colCellStyle?.wordWrap;
const defaultHeight = this.getDefaultColNodeHeight(colNode, colsHierarchy);

if (!isEnableHeightAdaptive) {
return defaultHeight;
}

const CellInstance = this.spreadsheet.isTableMode()
? TableColCell
: ColCell;
7 changes: 6 additions & 1 deletion packages/s2-core/src/facet/pivot-facet.ts
Original file line number Diff line number Diff line change
@@ -412,9 +412,14 @@ export class PivotFacet extends FrozenFacet {
return 0;
}

const { rowCell: rowCellStyle } = this.spreadsheet.options.style!;
const defaultHeight = this.getRowCellHeight(rowNode);

if (this.isCustomRowCellHeight(rowNode)) {
// 文本超过 1 行时再自适应单元格高度, 不然会频繁触发 GC, 导致性能降低: https://github.com/antvis/S2/issues/2693
const isEnableHeightAdaptive =
rowCellStyle?.maxLines! > 1 && rowCellStyle?.wordWrap;

if (this.isCustomRowCellHeight(rowNode) || !isEnableHeightAdaptive) {
return defaultHeight || 0;
}

0 comments on commit 439162d

Please sign in to comment.