Skip to content

Commit

Permalink
Added a color for every image that matches the most prominant color i…
Browse files Browse the repository at this point in the history
…n the image.

Now rendering this behind each actual photo to minimized the pop when photos load while scrolling the gallery.
  • Loading branch information
ashleydavis committed Jan 20, 2025
1 parent 9933985 commit b683bad
Show file tree
Hide file tree
Showing 8 changed files with 412 additions and 16 deletions.
17 changes: 16 additions & 1 deletion frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,24 @@ i {

/* Gallery */

@keyframes fadeInColorAnimation {
from {
opacity: 0.2;
}

to {
opacity: 1;
}
}

.fade-in-color {
opacity: 0.2;
animation: fadeInColorAnimation 0.1s ease-in forwards;
}

.fade-in {
opacity: 0;
animation: fadeInAnimation 0.25s ease-in forwards;
animation: fadeInAnimation 0.1s ease-in forwards;
}

@keyframes fadeInAnimation {
Expand Down
6 changes: 6 additions & 0 deletions packages/defs/src/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ export interface IAsset {
// Data URL containing the micro thumbnail for the asset.
//
microDataUrl: string;

//
// The color of the asset, if known.
// Helps hide the pop when thumbnails are loaded.
//
color?: [number, number, number];
}
1 change: 1 addition & 0 deletions packages/user-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"axios": "^0.27.2",
"blob-util": "^2.0.2",
"classnames": "^2.5.1",
"colorthief": "^2.6.0",
"dayjs": "^1.11.7",
"defs": "workspace:*",
"jszip": "^3.10.1",
Expand Down
16 changes: 16 additions & 0 deletions packages/user-interface/src/components/gallery-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ export function GalleryImage({ item, onClick, x, y, width, height }: IGalleryIma
}}
/>

{item.color
&& <div
className="gallery-thumb-container fade-in-color"
style={{
position: "absolute",
left: `${x}px`,
top: `${y}px`,
width: `${width}px`,
height: `${height}px`,
overflow: "hidden",
backgroundColor: `rgb(${item.color[0]}, ${item.color[1]}, ${item.color[2]})`,
}}
>
</div>
}

{microDataURL
&& <div
className="gallery-thumb-container"
Expand Down
6 changes: 6 additions & 0 deletions packages/user-interface/src/lib/gallery-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export interface IGalleryItem {
// Data URL containing the micro thumbnail for the asset.
//
microDataUrl: string;

//
// The color of the asset, if known.
// Helps hide the pop when thumbnails are loaded.
//
color?: [number, number, number];
}

//
Expand Down
Loading

0 comments on commit b683bad

Please sign in to comment.