1
0
Fork 0

Fix scroll check in infinite scroller directive

This commit is contained in:
Chocobozzz 2020-11-30 16:33:48 +01:00
parent 6cddd97d1d
commit 617f4f5cb2
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 7 additions and 6 deletions

View File

@ -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()
})
}
}