From 617f4f5cb2ac44df481851ff4165a79820b6b146 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Nov 2020 16:33:48 +0100 Subject: Fix scroll check in infinite scroller directive --- .../shared-main/angular/infinite-scroller.directive.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts index d2cf53227..dc212788a 100644 --- a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts +++ b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts @@ -1,11 +1,11 @@ import { fromEvent, Observable, Subscription } from 'rxjs' import { distinctUntilChanged, filter, map, share, startWith, throttleTime } from 'rxjs/operators' -import { AfterContentChecked, Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core' +import { AfterViewChecked, Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core' @Directive({ selector: '[myInfiniteScroller]' }) -export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterContentChecked { +export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterViewChecked { @Input() percentLimit = 70 @Input() autoInit = false @Input() onItself = false @@ -24,13 +24,14 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterConten this.decimalLimit = this.percentLimit / 100 } - ngAfterContentChecked () { + ngAfterViewChecked () { if (this.checkScroll) { this.checkScroll = false - console.log('Checking if the initial state has a scroll.') - - if (this.hasScroll() === false) this.nearOfBottom.emit() + // Wait HTML update + setTimeout(() => { + if (this.hasScroll() === false) this.nearOfBottom.emit() + }) } } -- cgit v1.2.3