* height calculation uses thumbHeight now
This commit is contained in:
parent
06043fca5f
commit
1cb0b0489d
@ -11,6 +11,7 @@ import {Thumbnail} from "../shared/thumbnail.model";
|
|||||||
const IDX_LEFT = 0;
|
const IDX_LEFT = 0;
|
||||||
const IDX_MIDDLE = 1;
|
const IDX_MIDDLE = 1;
|
||||||
const IDX_RIGHT = 2;
|
const IDX_RIGHT = 2;
|
||||||
|
const THUMB_MARGIN = 10;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-album',
|
selector: 'app-album',
|
||||||
@ -57,22 +58,22 @@ export class AlbumComponent implements OnInit {
|
|||||||
extraRight: '',
|
extraRight: '',
|
||||||
extraLeft: '',
|
extraLeft: '',
|
||||||
},
|
},
|
||||||
height: image.height,
|
height: image.thumbHeight,
|
||||||
}).map(thumbnail => {
|
}).map(thumbnail => {
|
||||||
let heights = [this.leftHeight, this.middleHeight, this.rightHeight];
|
let heights = [this.leftHeight, this.middleHeight, this.rightHeight];
|
||||||
let idx = heights.reduce((low, nxt, idx) => nxt < heights[low] ? idx : low, 0);
|
let idx = heights.reduce((low, nxt, idx) => nxt < heights[low] ? idx : low, 0);
|
||||||
switch(idx) {
|
switch(idx) {
|
||||||
case IDX_LEFT:
|
case IDX_LEFT:
|
||||||
this.thumbnailsLeft.push(thumbnail);
|
this.thumbnailsLeft.push(thumbnail);
|
||||||
this.leftHeight += (thumbnail.height + 10);
|
this.leftHeight += thumbnail.height + THUMB_MARGIN;
|
||||||
break;
|
break;
|
||||||
case IDX_MIDDLE:
|
case IDX_MIDDLE:
|
||||||
this.thumbnailsMiddle.push(thumbnail);
|
this.thumbnailsMiddle.push(thumbnail);
|
||||||
this.middleHeight += (thumbnail.height + 10);
|
this.middleHeight += thumbnail.height + THUMB_MARGIN;
|
||||||
break;
|
break;
|
||||||
case IDX_RIGHT:
|
case IDX_RIGHT:
|
||||||
this.thumbnailsRight.push(thumbnail);
|
this.thumbnailsRight.push(thumbnail);
|
||||||
this.rightHeight += (thumbnail.height + 10);
|
this.rightHeight += thumbnail.height + THUMB_MARGIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,4 +4,6 @@ export class Image {
|
|||||||
public path: string = "";
|
public path: string = "";
|
||||||
public width: number = 0;
|
public width: number = 0;
|
||||||
public height: number = 0;
|
public height: number = 0;
|
||||||
|
public thumbWidth: number = 0;
|
||||||
|
public thumbHeight: number = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user