Skip to content

Commit 7075c5b

Browse files
authored
feat(web): make asset grid row height responsive (#16970)
* feat(web): max grid row height responsive * also gallery-viewer * lint
1 parent 9398b0d commit 7075c5b

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

web/src/lib/components/shared-components/gallery-viewer/gallery-viewer.svelte

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@
5959
const _assets = assets;
6060
updateSlidingWindow();
6161
62+
const rowWidth = Math.floor(viewport.width);
63+
const rowHeight = rowWidth < 850 ? 100 : 235;
64+
6265
geometry = getJustifiedLayoutFromAssets(_assets, {
6366
spacing: 2,
6467
heightTolerance: 0.15,
65-
rowHeight: 235,
66-
rowWidth: Math.floor(viewport.width),
68+
rowHeight,
69+
rowWidth,
6770
});
6871
});
6972

web/src/lib/stores/assets-store.svelte.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export type AssetStoreOptions = Omit<AssetApiGetTimeBucketsRequest, 'size'> & {
3232
timelineAlbumId?: string;
3333
deferInit?: boolean;
3434
};
35-
35+
export type AssetStoreLayoutOptions = {
36+
rowHeight: number;
37+
};
3638
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3739
function updateObject(target: any, source: any): boolean {
3840
if (!target) {
@@ -559,6 +561,7 @@ export class AssetStore {
559561

560562
// --- private
561563
static #INIT_OPTIONS = {};
564+
#rowHeight = 235;
562565
#viewportHeight = $state(0);
563566
#viewportWidth = $state(0);
564567
#scrollTop = $state(0);
@@ -601,6 +604,7 @@ export class AssetStore {
601604
const changed = value !== this.#viewportWidth;
602605
this.#viewportWidth = value;
603606
this.suspendTransitions = true;
607+
this.#rowHeight = value < 850 ? 100 : 235;
604608
// side-effect - its ok!
605609
void this.#updateViewportGeometry(changed);
606610
}
@@ -776,6 +780,11 @@ export class AssetStore {
776780
this.#updateViewportGeometry(false);
777781
}
778782

783+
updateLayoutOptions(options: AssetStoreLayoutOptions) {
784+
this.#rowHeight = options.rowHeight;
785+
this.refreshLayout();
786+
}
787+
779788
async #init(options: AssetStoreOptions) {
780789
// doing the following outside of the task reduces flickr
781790
this.isInitialized = false;
@@ -845,10 +854,11 @@ export class AssetStore {
845854

846855
createLayoutOptions() {
847856
const viewportWidth = this.viewportWidth;
857+
848858
return {
849859
spacing: 2,
850860
heightTolerance: 0.15,
851-
rowHeight: 235,
861+
rowHeight: this.#rowHeight,
852862
rowWidth: Math.floor(viewportWidth),
853863
};
854864
}

0 commit comments

Comments
 (0)