@appnest/masonry-layout
Version:
An efficient and fast web component that gives you a beautiful masonry layout
36 lines (35 loc) • 1.23 kB
TypeScript
export declare const DEFAULT_MAX_COL_WIDTH = 500;
export declare const DEFAULT_COLS = "auto";
export declare const DEFAULT_DEBOUNCE_MS = 300;
export declare const DEFAULT_GAP_PX = 24;
export declare const COL_COUNT_CSS_VAR_NAME = "--_masonry-layout-col-count";
export declare const GAP_CSS_VAR_NAME = "--_masonry-layout-gap";
export declare const ELEMENT_NODE_TYPE = 1;
export type ColHeightMap = number[];
export type MasonryCols = number | "auto";
/**
* Returns a number attribute from an element.
* @param $elem
* @param name
* @param defaultValue
*/
export declare function getNumberAttribute<T>($elem: HTMLElement, name: string, defaultValue: T): number | T;
/**
* Returns the amount of cols that the masonry grid should have.
* @param totalWidth
* @param cols
* @param maxColWidth
*/
export declare function getColCount(totalWidth: number, cols: MasonryCols, maxColWidth: number): number;
/**
* Debounces a function.
* @param cb
* @param ms
* @param id
*/
export declare function debounce(cb: (() => void), ms: number, id: string): void;
/**
* Returns the index of the column with the smallest height.
* @param colHeights
*/
export declare function findSmallestColIndex(colHeights: ColHeightMap): number;