Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lib/grid-list/grid-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ describe('MdGridList', () => {
let footer = fixture.debugElement.query(By.directive(MdGridTileText));
expect(footer.nativeElement.classList.contains('mat-2-line')).toBe(true);
});

it('should not use calc() that evaluates to 0', () => {
const fixture = TestBed.createComponent(GirdListWithRowHeightRatio);

fixture.componentInstance.heightRatio = '4:1';
fixture.detectChanges();

const firstTile = fixture.debugElement.query(By.directive(MdGridTile)).nativeElement;

expect(firstTile.style.marginTop).toBe('0px');
expect(firstTile.style.left).toBe('0px');
});
});


Expand Down
4 changes: 2 additions & 2 deletions src/lib/grid-list/tile-styler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export abstract class TileStyler {
// edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter
// size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the
// edge evenly among the cells).
return `(${sizePercent}% - ( ${this._gutterSize} * ${gutterFraction} ))`;
return `(${sizePercent}% - (${this._gutterSize} * ${gutterFraction}))`;
}


Expand All @@ -64,7 +64,7 @@ export abstract class TileStyler {
getTilePosition(baseSize: string, offset: number): string {
// The position comes the size of a 1x1 tile plus gutter for each previous tile in the
// row/column (offset).
return calc(`(${baseSize} + ${this._gutterSize}) * ${offset}`);
return offset === 0 ? '0' : calc(`(${baseSize} + ${this._gutterSize}) * ${offset}`);
}


Expand Down