From f5383c51c06d96fdff54b0853c03a9c04ee160f0 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Sun, 26 Jun 2016 15:53:48 +0200 Subject: [PATCH] creating settings for caching, onscroll render and onscroll thumnail prio. --- common/config/Config.ts | 8 +++++++- .../app/gallery/grid/grid.gallery.component.ts | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/common/config/Config.ts b/common/config/Config.ts index bc376754..0e01852e 100644 --- a/common/config/Config.ts +++ b/common/config/Config.ts @@ -19,6 +19,9 @@ interface ClientConfig { thumbnailSizes:Array; 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) { diff --git a/frontend/app/gallery/grid/grid.gallery.component.ts b/frontend/app/gallery/grid/grid.gallery.component.ts index d42976d1..9d8f6dad 100644 --- a/frontend/app/gallery/grid/grid.gallery.component.ts +++ b/frontend/app/gallery/grid/grid.gallery.component.ts @@ -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 {