Skip to content

Commit

Permalink
Simplifed thumbnail loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleydavis committed Jan 25, 2025
1 parent 0aa3223 commit e7b39fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ i {
}

.fade-in-micro {
animation: fadeInMicro 0.2s cubic-bezier(1,0,.95,.82);
animation: fadeInMicro 0.3s cubic-bezier(1,0,.95,.82);
}

@keyframes fadeInThumb {
Expand Down
36 changes: 15 additions & 21 deletions packages/user-interface/src/components/gallery-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,24 @@ export function GalleryImage({ item, onClick, x, y, width, height }: IGalleryIma

setMicroDataURL(`data:image/jpeg;base64,${item.micro}`);

//
// A moment later load the the full thumb.
//
const thumbTimeout = setTimeout(() => {
loadAsset(item._id, "thumb")
.then(assetLoaded => {
if (assetLoaded) {
setThumbObjectURL(assetLoaded.objectUrl);
setTimeout(() => {
setMicroDataURL(undefined);
}, 1200);
}
})
.catch(err => {
console.error(`Failed to load asset: thumb:${item._id}`);
console.error(err);
});
}, 300);
loadAsset(item._id, "thumb")
.then(assetLoaded => {
if (assetLoaded) {
setThumbObjectURL(assetLoaded.objectUrl);
setTimeout(() => {
setMicroDataURL(undefined);
}, 1200);
}
})
.catch(err => {
console.error(`Failed to load asset: thumb:${item._id}`);
console.error(err);
});

return () => {
clearTimeout(thumbTimeout);
unloadAsset(item._id, "thumb");
};
}, [item]);
}, []);

const isSelected = selectedItems.has(item._id);

Expand Down Expand Up @@ -193,7 +187,7 @@ export function GalleryImage({ item, onClick, x, y, width, height }: IGalleryIma
scale: "1.05", // A small tweak to make the image cover the space without gaps.
transformOrigin: "center",
}}
/>
/>
</div>
}

Expand Down

0 comments on commit e7b39fc

Please sign in to comment.