Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[photos][web] Avoid checkerboard flash while loading images

AswinAsokc667888e2eca
diff --git a/web/packages/gallery/components/viewer/photoswipe-core.ts b/web/packages/gallery/components/viewer/photoswipe-core.ts
index eb5dcb7cf9..7ffc2523d3 100644
--- a/web/packages/gallery/components/viewer/photoswipe-core.ts
+++ b/web/packages/gallery/components/viewer/photoswipe-core.ts
@@ -625,6 +625,19 @@ export class FileViewerPhotoSwipe<
toggleMediaChromeSettingsMenu();
};
+ pswp.on("contentAppendImage", ({ content }) => {
+ const image = content.element;
+ if (!(image instanceof HTMLImageElement)) return;
+
+ // Show the transparency grid only once pixels are ready to render.
+ void image.decode().then(
+ () => image.classList.add("ente-image-decoded"),
+ () => {
+ // Failed images retain PhotoSwipe's error handling.
+ },
+ );
+ });
+
pswp.on("contentAppend", (e) => {
// PhotoSwipe can emit this later for content it already detached.
if (!e.content.hasSlide) {
diff --git a/web/packages/gallery/styles/photoswipe.css b/web/packages/gallery/styles/photoswipe.css
index 85eb7c0375..24b911afcf 100644
--- a/web/packages/gallery/styles/photoswipe.css
+++ b/web/packages/gallery/styles/photoswipe.css
@@ -259,6 +259,9 @@
.pswp-ente .pswp__img {
cursor: auto;
+}
+
+.pswp-ente .pswp__img.ente-image-decoded {
background-image: repeating-conic-gradient(#999999 0% 25%, #777777 0% 50%);
background-size: 24px 24px;
}