mirror of
https://github.com/jeffvli/feishin.git
synced 2026-08-08 13:23:16 +02:00
add additional height calculation for album group
This commit is contained in:
@@ -414,6 +414,38 @@ export function getAlbumGroupRowCount(
|
||||
return end - start + 1;
|
||||
}
|
||||
|
||||
export function getAlbumGroupSpanHeight(
|
||||
groupRowCount: number,
|
||||
baseHeight: number,
|
||||
albumGroupImageSize: number,
|
||||
contentHeight = 0,
|
||||
): number {
|
||||
const rowSpanHeight = groupRowCount * baseHeight;
|
||||
const imageSpanHeight =
|
||||
albumGroupImageSize > 0 ? Math.max(albumGroupImageSize, rowSpanHeight) : rowSpanHeight;
|
||||
|
||||
return Math.max(imageSpanHeight, contentHeight);
|
||||
}
|
||||
|
||||
export function getAlbumGroupStartRowIndex(
|
||||
rowIndex: number,
|
||||
getRowItem: ((index: number) => unknown) | undefined,
|
||||
enableHeader: boolean | undefined,
|
||||
): number {
|
||||
const item = getRowItem?.(rowIndex) as null | undefined | { album?: string };
|
||||
if (!item?.album) return rowIndex;
|
||||
|
||||
const firstDataRow = enableHeader ? 1 : 0;
|
||||
let start = rowIndex;
|
||||
while (start > firstDataRow) {
|
||||
const prevItem = getRowItem?.(start - 1) as null | undefined | { album?: string };
|
||||
if (!prevItem || prevItem.album !== item.album) break;
|
||||
start--;
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
export function isAlbumGroupingActive(columns: { id: string; isEnabled?: boolean }[]): boolean {
|
||||
return columns.some((col) => col.id === TableColumn.ALBUM_GROUP && col.isEnabled);
|
||||
}
|
||||
@@ -513,9 +545,21 @@ function getAlbumGroupClampHeight(props: ItemTableListInnerColumn): null | numbe
|
||||
props.enableHeader,
|
||||
props.data.length,
|
||||
);
|
||||
const groupStartRowIndex = getAlbumGroupStartRowIndex(
|
||||
props.rowIndex,
|
||||
props.getRowItem,
|
||||
props.enableHeader,
|
||||
);
|
||||
const contentHeight = props.albumGroupContentHeights?.get(groupStartRowIndex) ?? 0;
|
||||
const totalGroupHeight = getAlbumGroupSpanHeight(
|
||||
groupRowCount,
|
||||
baseHeight,
|
||||
albumImageSize,
|
||||
contentHeight,
|
||||
);
|
||||
|
||||
// Only clamp when the row was actually grown to fit the image.
|
||||
if (albumImageSize <= groupRowCount * baseHeight) return null;
|
||||
// Only clamp when the row was actually grown to fit the image or wrapped text.
|
||||
if (totalGroupHeight <= groupRowCount * baseHeight) return null;
|
||||
|
||||
return baseHeight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user