mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
fix(web): single grid row spacing (#30277)
This commit is contained in:
parent
e3385ce183
commit
bc6bf388c0
1 changed files with 3 additions and 8 deletions
|
|
@ -10,16 +10,11 @@
|
||||||
let container: HTMLElement | undefined = $state();
|
let container: HTMLElement | undefined = $state();
|
||||||
let contentRect: DOMRectReadOnly | undefined = $state();
|
let contentRect: DOMRectReadOnly | undefined = $state();
|
||||||
|
|
||||||
const getGridGap = (element: Element) => {
|
const getColumnGap = (element: Element) => {
|
||||||
const style = getComputedStyle(element);
|
const style = getComputedStyle(element);
|
||||||
|
return Number.parseInt(style.columnGap) || 0;
|
||||||
return {
|
|
||||||
columnGap: parsePixels(style.columnGap),
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const parsePixels = (style: string) => Math.trunc(Number(style)) || 0;
|
|
||||||
|
|
||||||
const getItemCount = (container: HTMLElement, containerWidth: number) => {
|
const getItemCount = (container: HTMLElement, containerWidth: number) => {
|
||||||
if (!container.firstElementChild) {
|
if (!container.firstElementChild) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -27,7 +22,7 @@
|
||||||
|
|
||||||
const childContentRect = container.firstElementChild.getBoundingClientRect();
|
const childContentRect = container.firstElementChild.getBoundingClientRect();
|
||||||
const childWidth = Math.floor(childContentRect.width || Infinity);
|
const childWidth = Math.floor(childContentRect.width || Infinity);
|
||||||
const { columnGap } = getGridGap(container);
|
const columnGap = getColumnGap(container);
|
||||||
|
|
||||||
return Math.floor((containerWidth + columnGap) / (childWidth + columnGap)) || 1;
|
return Math.floor((containerWidth + columnGap) / (childWidth + columnGap)) || 1;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue