]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix scroll check in infinite scroller directive
authorChocobozzz <me@florianbigard.com>
Mon, 30 Nov 2020 15:33:48 +0000 (16:33 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 30 Nov 2020 15:33:48 +0000 (16:33 +0100)
client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts

index d2cf532277c41547cf2aa30061878e8dfa28a862..dc212788ad2a2feee5c2dff7299b5c14a8c1fc83 100644 (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()
+      })
     }
   }