From 1cb0b0489d4dc1520b17a192fd72cccb8aa43bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Mon, 14 Aug 2017 23:14:44 +0200 Subject: [PATCH] * height calculation uses thumbHeight now --- src/app/gallery/album/album.component.ts | 9 +++++---- src/app/gallery/shared/image.model.ts | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/gallery/album/album.component.ts b/src/app/gallery/album/album.component.ts index 9e6a88e..96c2129 100644 --- a/src/app/gallery/album/album.component.ts +++ b/src/app/gallery/album/album.component.ts @@ -11,6 +11,7 @@ import {Thumbnail} from "../shared/thumbnail.model"; const IDX_LEFT = 0; const IDX_MIDDLE = 1; const IDX_RIGHT = 2; +const THUMB_MARGIN = 10; @Component({ selector: 'app-album', @@ -57,22 +58,22 @@ export class AlbumComponent implements OnInit { extraRight: '', extraLeft: '', }, - height: image.height, + height: image.thumbHeight, }).map(thumbnail => { let heights = [this.leftHeight, this.middleHeight, this.rightHeight]; let idx = heights.reduce((low, nxt, idx) => nxt < heights[low] ? idx : low, 0); switch(idx) { case IDX_LEFT: this.thumbnailsLeft.push(thumbnail); - this.leftHeight += (thumbnail.height + 10); + this.leftHeight += thumbnail.height + THUMB_MARGIN; break; case IDX_MIDDLE: this.thumbnailsMiddle.push(thumbnail); - this.middleHeight += (thumbnail.height + 10); + this.middleHeight += thumbnail.height + THUMB_MARGIN; break; case IDX_RIGHT: this.thumbnailsRight.push(thumbnail); - this.rightHeight += (thumbnail.height + 10); + this.rightHeight += thumbnail.height + THUMB_MARGIN; break; } }); diff --git a/src/app/gallery/shared/image.model.ts b/src/app/gallery/shared/image.model.ts index 123ed67..b7eaafb 100644 --- a/src/app/gallery/shared/image.model.ts +++ b/src/app/gallery/shared/image.model.ts @@ -4,4 +4,6 @@ export class Image { public path: string = ""; public width: number = 0; public height: number = 0; + public thumbWidth: number = 0; + public thumbHeight: number = 0; }