Skip to content

Commit 4dcf657

Browse files
committed
fix: component layout bottom
1 parent 6d2ba99 commit 4dcf657

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

packages/vtable/src/ListTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class ListTable extends BaseTable implements ListTableAPI {
187187
return;
188188
}
189189
// // 首次布局同样通过 BaseTable.resize() 完成,遵循 componentLayoutOrder 中的 title/legend 优先级
190-
// this.resize();
190+
// this.resize(); 注释掉这里为解决有组件的情况下 异步导致的布局抖动问题,所以把resize提到了setTimeout之前。但是原先在setTimeout中可能是为了scrollBar布局,但提到前面测试了下好像没有什么问题!后续看观察scrollBar
191191
this.fireListeners(TABLE_EVENT_TYPE.INITIALIZED, null);
192192
}, 0);
193193
}

packages/vtable/src/PivotChart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export class PivotChart extends BaseTable implements PivotChartAPI {
291291
return;
292292
}
293293
// // 首次布局同样通过 BaseTable.resize() 完成,遵循 componentLayoutOrder 中的 title/legend 优先级
294-
// this.resize();
294+
// this.resize(); 注释掉这里为解决有组件的情况下 异步导致的布局抖动问题,所以把resize提到了setTimeout之前。但是原先在setTimeout中可能是为了scrollBar布局,但提到前面测试了下好像没有什么问题!后续看观察scrollBar
295295
this.fireListeners(TABLE_EVENT_TYPE.INITIALIZED, null);
296296
}, 0);
297297
}

packages/vtable/src/PivotTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export class PivotTable extends BaseTable implements PivotTableAPI {
262262
return;
263263
}
264264
// // 首次布局同样通过 BaseTable.resize() 完成,遵循 componentLayoutOrder 中的 title/legend 优先级
265-
// this.resize();
265+
// this.resize(); 注释掉这里为解决有组件的情况下 异步导致的布局抖动问题,所以把resize提到了setTimeout之前。但是原先在setTimeout中可能是为了scrollBar布局,但提到前面测试了下好像没有什么问题!后续看观察scrollBar
266266
this.fireListeners(TABLE_EVENT_TYPE.INITIALIZED, null);
267267
}, 0);
268268
}

packages/vtable/src/core/BaseTable.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,38 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
686686
this._updateSize();
687687
// 组件布局优先级仅影响 title/legend 的布局与可用绘制区域缩减顺序
688688
const layoutOrder = this.options.componentLayoutOrder ?? ['legend', 'title'];
689+
//先布局orient为bottom或right的组件
689690
layoutOrder.forEach(component => {
690691
if (component === 'legend') {
691692
this.internalProps.legends?.forEach(legend => {
692-
legend?.resize();
693+
if (legend.orient === 'bottom' || legend.orient === 'right') {
694+
legend?.resize();
695+
}
693696
});
694697
} else if (component === 'title') {
695-
this.internalProps.title?.resize();
698+
if (
699+
this.internalProps.title?._titleOption.orient === 'bottom' ||
700+
this.internalProps.title?._titleOption.orient === 'right'
701+
) {
702+
this.internalProps.title?.resize();
703+
}
704+
}
705+
});
706+
//后布局orient为top或left的组件
707+
layoutOrder.forEach(component => {
708+
if (component === 'legend') {
709+
this.internalProps.legends?.forEach(legend => {
710+
if (legend.orient === 'top' || legend.orient === 'left') {
711+
legend?.resize();
712+
}
713+
});
714+
} else if (component === 'title') {
715+
if (
716+
this.internalProps.title?._titleOption.orient === 'top' ||
717+
this.internalProps.title?._titleOption.orient === 'left'
718+
) {
719+
this.internalProps.title?.resize();
720+
}
696721
}
697722
});
698723
if (this.internalProps.emptyTip) {

0 commit comments

Comments
 (0)