@@ -23,6 +23,7 @@ import {TileCoordinator} from './tile-coordinator';
2323import { TileStyler , FitTileStyler , RatioTileStyler , FixedTileStyler } from './tile-styler' ;
2424import { Directionality } from '@angular/cdk/bidi' ;
2525import { coerceNumberProperty } from '@angular/cdk/coercion' ;
26+ import { MAT_GRID_LIST , MatGridListBase } from './grid-list-base' ;
2627
2728
2829// TODO(kara): Conditional (responsive) column count / row size.
@@ -40,10 +41,14 @@ const MAT_FIT_MODE = 'fit';
4041 host : {
4142 'class' : 'mat-grid-list' ,
4243 } ,
44+ providers : [ {
45+ provide : MAT_GRID_LIST ,
46+ useExisting : MatGridList
47+ } ] ,
4348 changeDetection : ChangeDetectionStrategy . OnPush ,
4449 encapsulation : ViewEncapsulation . None ,
4550} )
46- export class MatGridList implements OnInit , AfterContentChecked {
51+ export class MatGridList implements MatGridListBase , OnInit , AfterContentChecked {
4752 /** Number of columns being rendered. */
4853 private _cols : number ;
4954
@@ -139,16 +144,18 @@ export class MatGridList implements OnInit, AfterContentChecked {
139144 /** Computes and applies the size and position for all children grid tiles. */
140145 private _layoutTiles ( ) : void {
141146 if ( ! this . _tileCoordinator ) {
142- this . _tileCoordinator = new TileCoordinator ( this . _tiles ) ;
147+ this . _tileCoordinator = new TileCoordinator ( ) ;
143148 }
144149
150+
145151 const tracker = this . _tileCoordinator ;
152+ const tiles = this . _tiles . filter ( tile => ! tile . _gridList || tile . _gridList === this ) ;
146153 const direction = this . _dir ? this . _dir . value : 'ltr' ;
147154
148- this . _tileCoordinator . update ( this . cols ) ;
155+ this . _tileCoordinator . update ( this . cols , tiles ) ;
149156 this . _tileStyler . init ( this . gutterSize , tracker , this . cols , direction ) ;
150157
151- this . _tiles . forEach ( ( tile , index ) => {
158+ tiles . forEach ( ( tile , index ) => {
152159 const pos = tracker . positions [ index ] ;
153160 this . _tileStyler . setStyle ( tile , pos . row , pos . col ) ;
154161 } ) ;
0 commit comments