Skip to content

Commit

Permalink
Merge pull request #837 from VisActor/836-refactor-listtable-use-bott…
Browse files Browse the repository at this point in the history
…omfrozenstyle

836 refactor listtable use bottomfrozenstyle
  • Loading branch information
fangsmile authored Jan 3, 2024
2 parents eb0e650 + fa05312 commit e9b8476
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "refactor: list table bottom row can not use bottomFrozenStyle #836\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
1 change: 1 addition & 0 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class ListTable extends BaseTable implements ListTableAPI {
this.scenegraph.clearCells();
this.headerStyleCache = new Map();
this.bodyStyleCache = new Map();
this.bodyBottomStyleCache = new Map();
this.scenegraph.createSceneGraph();
this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row);
this.renderAsync();
Expand Down
22 changes: 19 additions & 3 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {

headerStyleCache: any;
bodyStyleCache: any;
bodyBottomStyleCache: any;
container: HTMLElement;
isReleased: boolean = false;

Expand Down Expand Up @@ -359,6 +360,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {

this.headerStyleCache = new Map();
this.bodyStyleCache = new Map();
this.bodyBottomStyleCache = new Map();

internalProps.stick = { changedCells: [] };

Expand Down Expand Up @@ -2937,7 +2939,12 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
} else {
cacheKey = row;
}
let cacheStyle = this.bodyStyleCache.get(cacheKey);
let cacheStyle;
if (layoutMap.isBottomFrozenRow(row)) {
cacheStyle = this.bodyBottomStyleCache.get(cacheKey);
} else {
cacheStyle = this.bodyStyleCache.get(cacheKey);
}
if (cacheStyle) {
return cacheStyle;
}
Expand All @@ -2947,7 +2954,11 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
const style = column?.style;
cacheStyle = <FullExtendStyle>columnStyleContents.of(
style,
this.theme.bodyStyle,
layoutMap.isBottomFrozenRow(row) && this.theme.bottomFrozenStyle
? this.theme.bottomFrozenStyle
: layoutMap.isRightFrozenColumn(col) && this.theme.rightFrozenStyle
? this.theme.rightFrozenStyle
: this.theme.bodyStyle,
{
col,
row,
Expand All @@ -2960,13 +2971,18 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
this.options.autoWrapText
);
if (!isFunction(style)) {
this.bodyStyleCache.set(cacheKey, cacheStyle);
if (layoutMap.isBottomFrozenRow(row)) {
this.bodyBottomStyleCache.set(cacheKey, cacheStyle);
} else {
this.bodyStyleCache.set(cacheKey, cacheStyle);
}
}
return cacheStyle;
}
clearCellStyleCache() {
this.headerStyleCache.clear();
this.bodyStyleCache.clear();
this.bodyBottomStyleCache.clear();
}
/**
* 清除行高度缓存对象
Expand Down

0 comments on commit e9b8476

Please sign in to comment.