mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-14 23:44:01 +02:00
Set max width on grid
This commit is contained in:
@@ -18,6 +18,14 @@ interface VirtualGridProps extends Omit<FixedSizeListProps, 'children' | 'itemSi
|
|||||||
route?: CardRoute;
|
route?: CardRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const constrainWidth = (width: number) => {
|
||||||
|
if (width < 1920) {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1920;
|
||||||
|
};
|
||||||
|
|
||||||
export const VirtualInfiniteGrid = ({
|
export const VirtualInfiniteGrid = ({
|
||||||
itemCount,
|
itemCount,
|
||||||
itemGap,
|
itemGap,
|
||||||
@@ -39,7 +47,9 @@ export const VirtualInfiniteGrid = ({
|
|||||||
const loader = useRef<InfiniteLoader>(null);
|
const loader = useRef<InfiniteLoader>(null);
|
||||||
|
|
||||||
const { itemHeight, rowCount, columnCount } = useMemo(() => {
|
const { itemHeight, rowCount, columnCount } = useMemo(() => {
|
||||||
const itemsPerRow = Math.floor((Number(width) - itemGap + 3) / (itemSize! + itemGap + 2));
|
const itemsPerRow = Math.floor(
|
||||||
|
(constrainWidth(Number(width)) - itemGap + 3) / (itemSize! + itemGap + 2),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columnCount: itemsPerRow,
|
columnCount: itemsPerRow,
|
||||||
|
|||||||
Reference in New Issue
Block a user