From 9ff2623bc07992f390d48e635e4f88efc7d1babc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Tue, 15 Aug 2017 00:30:35 +0200 Subject: [PATCH] * gallery view has album view image sorting implemented * album export implemented --- src/app/gallery/album/album.component.html | 2 +- src/app/gallery/album/album.component.ts | 8 ++- src/app/gallery/gallery/gallery.component.ts | 65 ++++++++++---------- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/app/gallery/album/album.component.html b/src/app/gallery/album/album.component.html index fbd9c04..a4b80bc 100644 --- a/src/app/gallery/album/album.component.html +++ b/src/app/gallery/album/album.component.html @@ -1,5 +1,5 @@
-

{{album.name}}back to album list

+

{{album.name}}Export * Back to album list

= []; - private thumbnails: Array; + + private leftHeight: number = 0; + private middleHeight: number = 0; + private rightHeight: number = 0; + + public thumbnailsLeft: Array = []; + public thumbnailsMiddle: Array = []; + public thumbnailsRight: Array = []; constructor(private titleService: Title, private route: ActivatedRoute) { @@ -24,12 +36,12 @@ export class GalleryComponent implements OnInit { this.titleService.setTitle('Albums - photos.yvan.hu'); this.route.data.subscribe((data: { albums: Array }) => { this.albums = data.albums.filter(album => album.isPublic).reverse(); - this.thumbnails = this.initThumbnails(); + this.initThumbnails(); }); } - private initThumbnails(): Array { - return this.albums.map(album => { + private initThumbnails() { + this.albums.map(album => { slug: album.slug, image: this.imageUrl(album), label: { @@ -37,36 +49,27 @@ export class GalleryComponent implements OnInit { extraRight: album.images.length + ' images', extraLeft: album.date, }, + height: album.coverImage.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 + THUMB_MARGIN; + break; + case IDX_MIDDLE: + this.thumbnailsMiddle.push(thumbnail); + this.middleHeight += thumbnail.height + THUMB_MARGIN; + break; + case IDX_RIGHT: + this.thumbnailsRight.push(thumbnail); + this.rightHeight += thumbnail.height + THUMB_MARGIN; + break; + } }); } - get thumbnailsLeft(): Array { - let thumbs = []; - for (let i=0;i { - let thumbs = []; - for (let i=1;i { - let thumbs = []; - for (let i=2;i