Skip to content

Commit 6800ac9

Browse files
authored
Merge pull request #611 from AllenInstitute/bugfix/inconsistent-zarr-resolution
Add a target zarr resolution to gallery view
2 parents 87bfab7 + ba26253 commit 6800ac9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/components/FileList/LazilyRenderedThumbnail.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ export default function LazilyRenderedThumbnail(props: LazilyRenderedThumbnailPr
6565
const [thumbnailPath, setThumbnailPath] = React.useState<string | undefined>();
6666
const [isLoading, setIsLoading] = React.useState(true);
6767

68+
// Rough estimate of pixels to render for generating zarr thumbnails
69+
// Use a semi consistent value to avoid excessive network calls
70+
// (e.g., should not re-render for every window resize)
71+
const targetZarrSize = 500 / fileGridColCount; // 100px for large thumbnails, and 50px for small thumbnails
6872
React.useEffect(() => {
6973
if (file) {
70-
file.getPathToThumbnail(undefined).then((path) => {
74+
file.getPathToThumbnail(targetZarrSize).then((path) => {
7175
setThumbnailPath(path);
7276
setIsLoading(false);
7377
});
7478
}
75-
}, [file]);
79+
}, [file, targetZarrSize]);
7680

7781
const onClick = (evt: React.MouseEvent) => {
7882
evt.preventDefault();

0 commit comments

Comments
 (0)