Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grid-list): account for gutter in total list height #545

Merged
merged 1 commit into from
May 27, 2016
Merged
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
30 changes: 23 additions & 7 deletions src/components/grid-list/tile-styler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,30 @@ export class TileStyler {
tile.setStyle('width', calc(this.getTileSize(baseTileWidth, tile.colspan)));
}

/** Sets the vertical placement of the tile in the list.
* This method will be implemented by each type of TileStyler.
/** Calculates the total size taken up by gutters across one axis of a list.
* @internal
*/
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, gutterWidth: number) {}
getGutterSpan(): string {
return `${this._gutterSize} * (${this._rowspan} - 1)`;
}

/** Calculates the computed height and returns the correct style property to set.
* This method will be implemented by each type of TileStyler.
/** Calculates the total size taken up by tiles across one axis of a list.
* @internal
*/
getTileSpan(tileHeight: string): string {
return `${this._rowspan} * ${this.getTileSize(tileHeight, 1)}`;
}

/** Sets the vertical placement of the tile in the list.
* This method will be implemented by each type of TileStyler.
* @internal
*/
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, gutterWidth: number) {}

/** Calculates the computed height and returns the correct style property to set.
* This method will be implemented by each type of TileStyler.
* @internal
*/
getComputedHeight(): [string, string] { return null; }
}

Expand All @@ -132,7 +146,9 @@ export class FixedTileStyler extends TileStyler {

/** @internal */
getComputedHeight(): [string, string] {
return ['height', calc(`${this._rowspan} * ${this.getTileSize(this.fixedRowHeight, 1)}`)];
return [
'height', calc(`${this.getTileSpan(this.fixedRowHeight)} + ${this.getGutterSpan()}`)
];
}
}

Expand Down Expand Up @@ -165,7 +181,7 @@ export class RatioTileStyler extends TileStyler {
/** @internal */
getComputedHeight(): [string, string] {
return [
'paddingBottom', calc(`${this._rowspan} * ${this.getTileSize(this.baseTileHeight, 1)}`)
'paddingBottom', calc(`${this.getTileSpan(this.baseTileHeight)} + ${this.getGutterSpan()}`)
];
}

Expand Down