Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
calculateTableContentWidth(prevProps: Props) {
const table = this.table;
const row = table.querySelector(`.${this.addPrefix('row')}:not(.virtualized)`);
const contentWidth = row ? getWidth(row) : 0;
this.setState({ contentWidth });
// 这里 -SCROLLBAR_WIDTH 是为了让滚动条不挡住内容部分
this.minScrollX = -(contentWidth - this.state.width) - SCROLLBAR_WIDTH;
/**
* 1.判断 Table 列数是否发生变化
* 2.判断 Table 内容区域是否宽度有变化
*
*
* 满足 1 和 2 则更新横向滚动条位置
*/
if (
_.flatten(this.props.children).length !== _.flatten(prevProps.children).length &&
this.state.contentWidth !== contentWidth
getWidth() {
if (this.barRef.current) {
return getWidth(this.barRef.current);
}
return 0;
}
setTooltipPosition() {
const { tooltip } = this.props;
if (tooltip) {
const handle = this.handleRef.current;
const tip = handle.querySelector(`.${this.addPrefix('tooltip')}`);
const width = getWidth(tip);
addStyle(tip, 'left', `-${width / 2}px`);
}
}
calculateTableWidth = () => {
const table = this.table;
const { width } = this.state;
if (table) {
const nextWidth = getWidth(table);
if (width !== nextWidth) {
this.scrollX = 0;
this.scrollbarX && this.scrollbarX.resetScrollBarPosition();
}
this._cacheCells = null;
this.setState({
width: nextWidth
});
}
this.setAffixHeaderOffset();
};
getWidth() {
if (this.barRef.current) {
return getWidth(this.barRef.current);
}
return 0;
}
updateMenuStyle() {
const { getToggleInstance } = this.props;
if (this.menuElement && getToggleInstance) {
const instance = getToggleInstance();
if (instance && instance.toggle) {
const width = getWidth(findDOMNode(instance.toggle));
addStyle(this.menuElement, 'min-width', `${width}px`);
}
}
}
handleResize = () => {