mirror of
https://github.com/immich-app/immich.git
synced 2026-07-28 14:47:30 -07:00
fix(web): single grid row spacing (#30277)
This commit is contained in:
@@ -10,16 +10,11 @@
|
||||
let container: HTMLElement | undefined = $state();
|
||||
let contentRect: DOMRectReadOnly | undefined = $state();
|
||||
|
||||
const getGridGap = (element: Element) => {
|
||||
const getColumnGap = (element: Element) => {
|
||||
const style = getComputedStyle(element);
|
||||
|
||||
return {
|
||||
columnGap: parsePixels(style.columnGap),
|
||||
};
|
||||
return Number.parseInt(style.columnGap) || 0;
|
||||
};
|
||||
|
||||
const parsePixels = (style: string) => Math.trunc(Number(style)) || 0;
|
||||
|
||||
const getItemCount = (container: HTMLElement, containerWidth: number) => {
|
||||
if (!container.firstElementChild) {
|
||||
return 1;
|
||||
@@ -27,7 +22,7 @@
|
||||
|
||||
const childContentRect = container.firstElementChild.getBoundingClientRect();
|
||||
const childWidth = Math.floor(childContentRect.width || Infinity);
|
||||
const { columnGap } = getGridGap(container);
|
||||
const columnGap = getColumnGap(container);
|
||||
|
||||
return Math.floor((containerWidth + columnGap) / (childWidth + columnGap)) || 1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user