* height calculation uses thumbHeight now

This commit is contained in:
Danyi Dávid 2017-08-14 23:14:44 +02:00
parent 06043fca5f
commit 1cb0b0489d
2 changed files with 7 additions and 4 deletions

View File

@ -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;
}
});

View File

@ -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;
}