grid bugfix
This commit is contained in:
parent
ef47ddbaae
commit
735a9a336f
@ -45,7 +45,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
if (this.isAfterViewInit == false) {
|
if (this.isAfterViewInit == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.onPhotosChanged();
|
this.sortPhotos();
|
||||||
|
this.mergeNewPhotos();
|
||||||
|
setImmediate(() => {
|
||||||
|
this.renderPhotos();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:resize')
|
@HostListener('window:resize')
|
||||||
@ -53,7 +57,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
if (this.isAfterViewInit == false) {
|
if (this.isAfterViewInit == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.onPhotosChanged();
|
this.sortPhotos();
|
||||||
|
this.clearRenderedPhotos();
|
||||||
|
setImmediate(() => {
|
||||||
|
this.renderPhotos();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isAfterViewInit:boolean = false;
|
isAfterViewInit:boolean = false;
|
||||||
@ -64,13 +72,16 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
//TODO: implement scroll detection
|
//TODO: implement scroll detection
|
||||||
|
|
||||||
|
|
||||||
this.onPhotosChanged();
|
this.sortPhotos();
|
||||||
|
this.clearRenderedPhotos();
|
||||||
|
setImmediate(() => {
|
||||||
|
this.renderPhotos();
|
||||||
|
});
|
||||||
this.isAfterViewInit = true;
|
this.isAfterViewInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private onPhotosChanged() {
|
private sortPhotos() {
|
||||||
|
|
||||||
//sort pohots by date
|
//sort pohots by date
|
||||||
this.photos.sort((a:Photo, b:Photo) => {
|
this.photos.sort((a:Photo, b:Photo) => {
|
||||||
if (a.metadata.creationDate > b.metadata.creationDate) {
|
if (a.metadata.creationDate > b.metadata.creationDate) {
|
||||||
@ -83,6 +94,14 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private clearRenderedPhotos() {
|
||||||
|
this.photosToRender = [];
|
||||||
|
this.renderedPhotoIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private mergeNewPhotos() {
|
||||||
//merge new data with old one
|
//merge new data with old one
|
||||||
let lastSameIndex = 0;
|
let lastSameIndex = 0;
|
||||||
let lastRowId = null;
|
let lastRowId = null;
|
||||||
@ -102,14 +121,10 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
this.photosToRender.splice(lastSameIndex, this.photosToRender.length - lastSameIndex);
|
this.photosToRender.splice(lastSameIndex, this.photosToRender.length - lastSameIndex);
|
||||||
this.renderedPhotoIndex = lastSameIndex;
|
this.renderedPhotoIndex = lastSameIndex;
|
||||||
} else {
|
} else {
|
||||||
this.photosToRender = [];
|
this.clearRenderedPhotos();
|
||||||
this.renderedPhotoIndex = 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setImmediate(() => {
|
|
||||||
this.renderPhotos();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private renderedPhotoIndex:number = 0;
|
private renderedPhotoIndex:number = 0;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
///<reference path="../../../../browser.d.ts"/>
|
///<reference path="../../../../browser.d.ts"/>
|
||||||
|
|
||||||
import {Component, Input, ElementRef, ViewChild, OnInit, AfterViewInit, OnDestroy, Renderer} from "@angular/core";
|
import {Component, Input, ElementRef, ViewChild, OnInit, AfterViewInit, OnDestroy} from "@angular/core";
|
||||||
import {IRenderable, Dimension} from "../../../model/IRenderable";
|
import {IRenderable, Dimension} from "../../../model/IRenderable";
|
||||||
import {GridPhoto} from "../GridPhoto";
|
import {GridPhoto} from "../GridPhoto";
|
||||||
import {SearchTypes} from "../../../../../common/entities/AutoCompleteItem";
|
import {SearchTypes} from "../../../../../common/entities/AutoCompleteItem";
|
||||||
@ -49,7 +49,7 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, AfterViewInit
|
|||||||
|
|
||||||
wasInView:boolean = null;
|
wasInView:boolean = null;
|
||||||
|
|
||||||
constructor(private thumbnailService:ThumbnailLoaderService, private renderer:Renderer) {
|
constructor(private thumbnailService:ThumbnailLoaderService) {
|
||||||
this.SearchTypes = SearchTypes;
|
this.SearchTypes = SearchTypes;
|
||||||
this.searchEnabled = Config.Client.Search.searchEnabled;
|
this.searchEnabled = Config.Client.Search.searchEnabled;
|
||||||
|
|
||||||
@ -92,13 +92,11 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, AfterViewInit
|
|||||||
onError: (error)=> {//onError
|
onError: (error)=> {//onError
|
||||||
this.thumbnailTask = null;
|
this.thumbnailTask = null;
|
||||||
//TODO: handle error
|
//TODO: handle error
|
||||||
|
//TODO: not an error if its from cache
|
||||||
console.error("something bad happened");
|
console.error("something bad happened");
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* this.scrollListener = this.renderer.listenGlobal('window', 'scroll', () => {
|
|
||||||
this.onScroll();
|
|
||||||
});*/
|
|
||||||
if (this.gridPhoto.isReplacementThumbnailAvailable()) {
|
if (this.gridPhoto.isReplacementThumbnailAvailable()) {
|
||||||
this.thumbnailTask = this.thumbnailService.loadImage(this.gridPhoto, ThumbnailLoadingPriority.medium, listener);
|
this.thumbnailTask = this.thumbnailService.loadImage(this.gridPhoto, ThumbnailLoadingPriority.medium, listener);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user