1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-02 09:12:07 +02:00

Improving lazy rendering. Making it based on row height instead of 70% of the scroll.

This commit is contained in:
Patrik J. Braun 2021-05-01 00:05:03 +02:00
parent 42744e3180
commit c10f4f6380

View File

@ -163,7 +163,7 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
return null;
}
let maxRowHeight = this.screenHeight / this.MIN_ROW_COUNT;
let maxRowHeight = this.getMaxRowHeight();
const minRowHeight = this.screenHeight / this.MAX_ROW_COUNT;
const photoRowBuilder = new GridRowBuilder(this.media,
@ -212,6 +212,10 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
}
}
private getMaxRowHeight(): number {
return this.screenHeight / this.MIN_ROW_COUNT;
}
/**
* Makes sure that the photo with the given mediaString is visible on the screen
* @param mediaStringId
@ -315,8 +319,9 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
* @returns boolean
*/
private shouldRenderMore(offset: number = 0): boolean {
const bottomOffset = this.getMaxRowHeight() * 2;
return Config.Client.Other.enableOnScrollRendering === false ||
PageHelper.ScrollY >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
PageHelper.ScrollY >= (document.body.clientHeight + offset - window.innerHeight) - bottomOffset
|| (document.body.clientHeight + offset) * 0.85 < window.innerHeight;
}