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:
parent
735a9a336f
commit
f5383c51c0
@ -19,6 +19,9 @@ interface ClientConfig {
|
|||||||
thumbnailSizes:Array<number>;
|
thumbnailSizes:Array<number>;
|
||||||
Search:SearchConfig;
|
Search:SearchConfig;
|
||||||
concurrentThumbnailGenerations:number;
|
concurrentThumbnailGenerations:number;
|
||||||
|
enableCache:boolean;
|
||||||
|
enableOnScrollRendering:boolean;
|
||||||
|
enableOnScrollThumbnailPrioritising:boolean;
|
||||||
}
|
}
|
||||||
export class ConfigClass {
|
export class ConfigClass {
|
||||||
|
|
||||||
@ -31,7 +34,10 @@ export class ConfigClass {
|
|||||||
instantSearchEnabled: false,
|
instantSearchEnabled: false,
|
||||||
autocompleteEnabled: false
|
autocompleteEnabled: false
|
||||||
},
|
},
|
||||||
concurrentThumbnailGenerations: 1
|
concurrentThumbnailGenerations: 1,
|
||||||
|
enableCache: false,
|
||||||
|
enableOnScrollRendering: true,
|
||||||
|
enableOnScrollThumbnailPrioritising: true
|
||||||
};
|
};
|
||||||
|
|
||||||
public setDatabaseType(type:DatabaseType) {
|
public setDatabaseType(type:DatabaseType) {
|
||||||
|
@ -16,6 +16,7 @@ import {GridRowBuilder} from "./GridRowBuilder";
|
|||||||
import {GalleryLightboxComponent} from "../lightbox/lightbox.gallery.component";
|
import {GalleryLightboxComponent} from "../lightbox/lightbox.gallery.component";
|
||||||
import {GridPhoto} from "./GridPhoto";
|
import {GridPhoto} from "./GridPhoto";
|
||||||
import {GalleryPhotoComponent} from "./photo/photo.grid.gallery.component";
|
import {GalleryPhotoComponent} from "./photo/photo.grid.gallery.component";
|
||||||
|
import {Config} from "../../config/Config";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gallery-grid',
|
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 {
|
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;
|
|| (document.body.clientHeight + offset) * 0.85 < window.innerHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -168,9 +176,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
|
|||||||
@HostListener('window:scroll')
|
@HostListener('window:scroll')
|
||||||
onScroll() {
|
onScroll() {
|
||||||
this.renderPhotos();
|
this.renderPhotos();
|
||||||
this.gridPhotoQL.toArray().forEach((pc:GalleryPhotoComponent) => {
|
if (Config.Client.enableOnScrollThumbnailPrioritising == true) {
|
||||||
pc.onScroll();
|
this.gridPhotoQL.toArray().forEach((pc:GalleryPhotoComponent) => {
|
||||||
});
|
pc.onScroll();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getContainerWidth():number {
|
private getContainerWidth():number {
|
||||||
|
Loading…
Reference in New Issue
Block a user