1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

creating settings for caching, onscroll render and onscroll thumnail prio.

This commit is contained in:
Braun Patrik 2016-06-26 15:53:48 +02:00
parent 735a9a336f
commit f5383c51c0
2 changed files with 21 additions and 5 deletions

View File

@ -19,6 +19,9 @@ interface ClientConfig {
thumbnailSizes:Array<number>;
Search:SearchConfig;
concurrentThumbnailGenerations:number;
enableCache:boolean;
enableOnScrollRendering:boolean;
enableOnScrollThumbnailPrioritising:boolean;
}
export class ConfigClass {
@ -31,7 +34,10 @@ export class ConfigClass {
instantSearchEnabled: false,
autocompleteEnabled: false
},
concurrentThumbnailGenerations: 1
concurrentThumbnailGenerations: 1,
enableCache: false,
enableOnScrollRendering: true,
enableOnScrollThumbnailPrioritising: true
};
public setDatabaseType(type:DatabaseType) {

View File

@ -16,6 +16,7 @@ import {GridRowBuilder} from "./GridRowBuilder";
import {GalleryLightboxComponent} from "../lightbox/lightbox.gallery.component";
import {GridPhoto} from "./GridPhoto";
import {GalleryPhotoComponent} from "./photo/photo.grid.gallery.component";
import {Config} from "../../config/Config";
@Component({
selector: 'gallery-grid',
@ -159,8 +160,15 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
}
/**
* Returns true, if scroll is >= 70% to render more images.
* Or of onscroll renderin is off: return always to render all the images at once
* @param offset Add height to the client height (conent is not yet added to the dom, but calculate with it)
* @returns {boolean}
*/
private shouldRenderMore(offset:number = 0):boolean {
return document.body.scrollTop >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
return Config.Client.enableOnScrollRendering == false ||
document.body.scrollTop >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
|| (document.body.clientHeight + offset) * 0.85 < window.innerHeight;
}
@ -168,9 +176,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
@HostListener('window:scroll')
onScroll() {
this.renderPhotos();
this.gridPhotoQL.toArray().forEach((pc:GalleryPhotoComponent) => {
pc.onScroll();
});
if (Config.Client.enableOnScrollThumbnailPrioritising == true) {
this.gridPhotoQL.toArray().forEach((pc:GalleryPhotoComponent) => {
pc.onScroll();
});
}
}
private getContainerWidth():number {