mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
bugfixing grid sorting
This commit is contained in:
parent
8e14c613ea
commit
a7a8e42490
@ -18,6 +18,11 @@ export class GalleryCacheService {
|
||||
if (value != null) {
|
||||
let directory:Directory = JSON.parse(value);
|
||||
|
||||
|
||||
directory.photos.forEach((photo:Photo) => {
|
||||
photo.metadata.creationDate = new Date(<any>photo.metadata.creationDate);
|
||||
});
|
||||
|
||||
directory.photos.forEach((photo:Photo) => {
|
||||
photo.directory = directory;
|
||||
});
|
||||
|
@ -39,6 +39,11 @@ export class GalleryService {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
message.result.directory.photos.forEach((photo:Photo) => {
|
||||
photo.metadata.creationDate = new Date(<any>photo.metadata.creationDate);
|
||||
});
|
||||
|
||||
message.result.directory.photos.forEach((photo:Photo) => {
|
||||
photo.directory = message.result.directory;
|
||||
});
|
||||
|
@ -76,6 +76,7 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
|
||||
|
||||
this.updateContainerWidth();
|
||||
this.sortPhotos();
|
||||
this.clearRenderedPhotos();
|
||||
setImmediate(() => {
|
||||
this.renderPhotos();
|
||||
@ -87,14 +88,7 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
private sortPhotos() {
|
||||
//sort pohots by date
|
||||
this.photos.sort((a:Photo, b:Photo) => {
|
||||
if (a.metadata.creationDate > b.metadata.creationDate) {
|
||||
return 1;
|
||||
}
|
||||
if (a.metadata.creationDate < b.metadata.creationDate) {
|
||||
return -1;
|
||||
}
|
||||
// a must be equal to b
|
||||
return 0;
|
||||
return a.metadata.creationDate.getTime() - b.metadata.creationDate.getTime();
|
||||
});
|
||||
|
||||
}
|
||||
@ -171,7 +165,10 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
}
|
||||
|
||||
public renderARow():number {
|
||||
|
||||
if (this.renderedPhotoIndex + 1 >= this.photos.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let maxRowHeight = window.innerHeight / this.MIN_ROW_COUNT;
|
||||
let minRowHeight = window.innerHeight / this.MAX_ROW_COUNT;
|
||||
|
||||
@ -188,7 +185,6 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
});
|
||||
|
||||
this.renderedPhotoIndex += photoRowBuilder.getPhotoRow().length;
|
||||
console.log(this.photosToRender.length);
|
||||
return rowHeight;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<span *ngIf="!searchEnabled">{{getPositionText()}}</span>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
{{gridPhoto.photo.metadata.creationDate | date:"yy-MM-dd HH:mm:ss"}}
|
||||
|
||||
<div class="photo-keywords">
|
||||
<template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last">
|
||||
|
Loading…
Reference in New Issue
Block a user