mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
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) {
|
||||
return;
|
||||
}
|
||||
this.onPhotosChanged();
|
||||
this.sortPhotos();
|
||||
this.mergeNewPhotos();
|
||||
setImmediate(() => {
|
||||
this.renderPhotos();
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('window:resize')
|
||||
@ -53,7 +57,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
if (this.isAfterViewInit == false) {
|
||||
return;
|
||||
}
|
||||
this.onPhotosChanged();
|
||||
this.sortPhotos();
|
||||
this.clearRenderedPhotos();
|
||||
setImmediate(() => {
|
||||
this.renderPhotos();
|
||||
});
|
||||
}
|
||||
|
||||
isAfterViewInit:boolean = false;
|
||||
@ -64,13 +72,16 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
//TODO: implement scroll detection
|
||||
|
||||
|
||||
this.onPhotosChanged();
|
||||
this.sortPhotos();
|
||||
this.clearRenderedPhotos();
|
||||
setImmediate(() => {
|
||||
this.renderPhotos();
|
||||
});
|
||||
this.isAfterViewInit = true;
|
||||
}
|
||||
|
||||
|
||||
private onPhotosChanged() {
|
||||
|
||||
private sortPhotos() {
|
||||
//sort pohots by date
|
||||
this.photos.sort((a:Photo, b:Photo) => {
|
||||
if (a.metadata.creationDate > b.metadata.creationDate) {
|
||||
@ -83,6 +94,14 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
return 0;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private clearRenderedPhotos() {
|
||||
this.photosToRender = [];
|
||||
this.renderedPhotoIndex = 0;
|
||||
}
|
||||
|
||||
private mergeNewPhotos() {
|
||||
//merge new data with old one
|
||||
let lastSameIndex = 0;
|
||||
let lastRowId = null;
|
||||
@ -102,15 +121,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
||||
this.photosToRender.splice(lastSameIndex, this.photosToRender.length - lastSameIndex);
|
||||
this.renderedPhotoIndex = lastSameIndex;
|
||||
} else {
|
||||
this.photosToRender = [];
|
||||
this.renderedPhotoIndex = 0;
|
||||
this.clearRenderedPhotos();
|
||||
}
|
||||
|
||||
setImmediate(() => {
|
||||
this.renderPhotos();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private renderedPhotoIndex:number = 0;
|
||||
|
||||
private renderPhotos() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
///<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 {GridPhoto} from "../GridPhoto";
|
||||
import {SearchTypes} from "../../../../../common/entities/AutoCompleteItem";
|
||||
@ -49,7 +49,7 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, AfterViewInit
|
||||
|
||||
wasInView:boolean = null;
|
||||
|
||||
constructor(private thumbnailService:ThumbnailLoaderService, private renderer:Renderer) {
|
||||
constructor(private thumbnailService:ThumbnailLoaderService) {
|
||||
this.SearchTypes = SearchTypes;
|
||||
this.searchEnabled = Config.Client.Search.searchEnabled;
|
||||
|
||||
@ -92,13 +92,11 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, AfterViewInit
|
||||
onError: (error)=> {//onError
|
||||
this.thumbnailTask = null;
|
||||
//TODO: handle error
|
||||
//TODO: not an error if its from cache
|
||||
console.error("something bad happened");
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
/* this.scrollListener = this.renderer.listenGlobal('window', 'scroll', () => {
|
||||
this.onScroll();
|
||||
});*/
|
||||
if (this.gridPhoto.isReplacementThumbnailAvailable()) {
|
||||
this.thumbnailTask = this.thumbnailService.loadImage(this.gridPhoto, ThumbnailLoadingPriority.medium, listener);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user