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

fixing firefox scroll error

This commit is contained in:
Braun Patrik 2016-07-05 12:34:11 +02:00
parent d82c9eec93
commit a3a5e91145
3 changed files with 27 additions and 16 deletions

View File

@ -40,6 +40,8 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
private MIN_ROW_COUNT = 2;
private MAX_ROW_COUNT = 5;
onScrollFired = false;
constructor() {
}
@ -134,8 +136,11 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
let renderedContentHeight = 0;
while (this.renderedPhotoIndex < this.photos.length && this.shouldRenderMore(renderedContentHeight) === true) {
renderedContentHeight += this.renderARow();
let ret = this.renderARow();
if (ret === null) {
throw new Error("Gridphotos rendering failed");
}
renderedContentHeight += ret;
}
}
@ -148,13 +153,16 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
*/
private shouldRenderMore(offset:number = 0):boolean {
return Config.Client.enableOnScrollRendering === false ||
document.body.scrollTop >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
window.scrollY >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
|| (document.body.clientHeight + offset) * 0.85 < window.innerHeight;
}
@HostListener('window:scroll')
onScroll() {
if (!this.onScrollFired) {
window.requestAnimationFrame(() => {
this.renderPhotos();
if (Config.Client.enableOnScrollThumbnailPrioritising === true) {
@ -162,11 +170,15 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit {
pc.onScroll();
});
}
this.onScrollFired = false;
});
this.onScrollFired = true;
}
}
public renderARow():number {
if (this.renderedPhotoIndex + 1 >= this.photos.length) {
return 0;
if (this.renderedPhotoIndex >= this.photos.length) {
return null;
}
let maxRowHeight = window.innerHeight / this.MIN_ROW_COUNT;

View File

@ -19,7 +19,6 @@
<span *ngIf="!searchEnabled">{{getPositionText()}}</span>
</template>
</div>
{{gridPhoto.photo.metadata.creationDate | date:"yy-MM-dd HH:mm:ss"}}
<div class="photo-keywords">
<template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last">

View File

@ -107,12 +107,12 @@ export class GalleryLightboxComponent {
}
private getBodyScrollTop() {
return this.dom.getProperty(this.dom.query('body'), 'scrollTop');
private getBodyScrollTop():number {
return window.scrollY;
}
private setBodyScrollTop(value) {
return this.dom.setProperty(this.dom.query('body'), 'scrollTop', value);
private setBodyScrollTop(value:number) {
window.scrollTo(window.scrollX, value);
}
private getScreenWidth() {