MCPcopy Create free account
hub / github.com/angular/components / MatGridList

Class MatGridList

src/material/grid-list/grid-list.ts:58–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 encapsulation: ViewEncapsulation.None,
57})
58export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked, TileStyleTarget {
59 private _element = inject<ElementRef<HTMLElement>>(ElementRef);
60 private _dir = inject(Directionality, {optional: true});
61
62 /** Number of columns being rendered. */
63 private _cols!: number;
64
65 /** Used for determining the position of each tile in the grid. */
66 private _tileCoordinator!: TileCoordinator;
67
68 /**
69 * Row height value passed in by user. This can be one of three types:
70 * - Number value (ex: "100px"): sets a fixed row height to that value
71 * - Ratio value (ex: "4:3"): sets the row height based on width:height ratio
72 * - "Fit" mode (ex: "fit"): sets the row height to total height divided by number of rows
73 */
74 private _rowHeight!: string;
75
76 /** The amount of space between tiles. This will be something like '5px' or '2em'. */
77 private _gutter: string = '1px';
78
79 /** Sets position and size styles for a tile */
80 private _tileStyler!: TileStyler;
81
82 /** Query list of tiles that are being rendered. */
83 @ContentChildren(MatGridTile, {descendants: true}) _tiles!: QueryList<MatGridTile>;
84
85 /** Amount of columns in the grid list. */
86 @Input()
87 get cols(): number {
88 return this._cols;
89 }
90 set cols(value: NumberInput) {
91 this._cols = Math.max(1, Math.round(coerceNumberProperty(value)));
92 }
93
94 /** Size of the grid list's gutter in pixels. */
95 @Input()
96 get gutterSize(): string {
97 return this._gutter;
98 }
99 set gutterSize(value: string) {
100 this._gutter = `${value == null ? '' : value}`;
101 }
102
103 /** Set internal representation of row height from the user-provided value. */
104 @Input()
105 get rowHeight(): string | number {
106 return this._rowHeight;
107 }
108 set rowHeight(value: string | number) {
109 const newValue = `${value == null ? '' : value}`;
110
111 if (newValue !== this._rowHeight) {
112 this._rowHeight = newValue;
113 this._setTileStyler(this._rowHeight);
114 }
115 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected