mirror of
https://github.com/bakhirev/assayo.git
synced 2024-11-16 08:11:40 +00:00
update
This commit is contained in:
parent
1c2012bc94
commit
2e29d4ede2
|
@ -1,3 +0,0 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke="#84858D" d="M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"></path>
|
||||
</svg>
|
Before Width: | Height: | Size: 198 B |
|
@ -1,3 +0,0 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke="#84858D" d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path>
|
||||
</svg>
|
Before Width: | Height: | Size: 188 B |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,23 +6,30 @@ export default function getAdaptiveColumnWidth(
|
|||
): number {
|
||||
if (!offsetWidth) return 150;
|
||||
|
||||
// количество колонок и фиксированная ширина
|
||||
const visibleColumns = columns.filter(({ isShow }: IColumn) => isShow);
|
||||
const columnsWidth = visibleColumns.map((column: IColumn) => (
|
||||
column.userWidth || column.defaultWidth || 0
|
||||
));
|
||||
const fixedWidth = columnsWidth.reduce((sum: number, width: number) => sum + width, 0);
|
||||
const adaptiveColumnsCount = columnsWidth.filter((width: number) => !width).length;
|
||||
let adaptiveColumnsCount = columnsWidth.filter((width: number) => !width).length;
|
||||
if (!adaptiveColumnsCount) return 40;
|
||||
|
||||
const tableWidth = offsetWidth - fixedWidth;
|
||||
// делаем предварительный расчёт
|
||||
let adaptiveTableWidth = offsetWidth - fixedWidth;
|
||||
let adaptiveColumnsWidth = Math.floor(adaptiveTableWidth / adaptiveColumnsCount);
|
||||
|
||||
// если адаптив < минималки, то адаптив делает перерасчет
|
||||
let adaptiveTableWidth = tableWidth;
|
||||
let adaptiveColumnsWidth = adaptiveTableWidth / adaptiveColumnsCount;
|
||||
visibleColumns.forEach((column: IColumn) => {
|
||||
if (!column.minWidth
|
||||
|| column.minWidth < adaptiveColumnsWidth) return;
|
||||
if (
|
||||
(column.userWidth || column.defaultWidth) // если ширина известна
|
||||
|| !column.minWidth // если минималки нет
|
||||
|| column.minWidth < adaptiveColumnsWidth // если минималки меньше адаптива
|
||||
|| !adaptiveColumnsCount // если столбиков уже нет
|
||||
) return;
|
||||
|
||||
adaptiveTableWidth -= column.minWidth;
|
||||
adaptiveColumnsCount -= 1;
|
||||
adaptiveColumnsWidth = adaptiveTableWidth / adaptiveColumnsCount;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue