2023-07-02 17:46:20 -05:00
|
|
|
/**
|
|
|
|
* Calculate thumbnail size based on number of assets and viewport width
|
|
|
|
* @param assetCount Number of assets in the view
|
|
|
|
* @param viewWidth viewport width
|
|
|
|
* @returns thumbnail size
|
|
|
|
*/
|
|
|
|
export function getThumbnailSize(assetCount: number, viewWidth: number): number {
|
|
|
|
if (assetCount < 6) {
|
|
|
|
return Math.min(320, Math.floor(viewWidth / assetCount - assetCount));
|
2023-11-28 15:16:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (viewWidth > 600) {
|
|
|
|
return viewWidth / 7 - 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewWidth > 400) {
|
|
|
|
return viewWidth / 4 - 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewWidth > 300) {
|
|
|
|
return viewWidth / 2 - 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewWidth > 200) {
|
|
|
|
return viewWidth / 2 - 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewWidth > 100) {
|
|
|
|
return viewWidth / 1 - 6;
|
2023-07-02 17:46:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 300;
|
|
|
|
}
|