Ngx-infinite-scroll: Problem when scrolling for second time

Created on 2 Aug 2018  路  7Comments  路  Source: orizens/ngx-infinite-scroll

Hi ,

I am using ngx- infinite-scroll in a project , and I am having some problems . It works when I scroll down , or/and scroll up , for the first time . But when I scroll down or up , again , for a second time , the event does not get triggered anymore .

Can you kindly help me to solve this problem ?

Thank you

needs more INFO

Most helpful comment

I found a temporary solution that worked for my situation:

  1. Get a reference to the viewchild:
    @ViewChild(InfiniteScrollDirective) infiniteScroll: InfiniteScrollDirective;
  2. Sometime before the 2nd scroll-to-bottom, call this:
    this.infiniteScroll.ngOnDestroy();
    this.infiniteScroll.setup();

All 7 comments

please repost using the issue template

I found a temporary solution that worked for my situation:

  1. Get a reference to the viewchild:
    @ViewChild(InfiniteScrollDirective) infiniteScroll: InfiniteScrollDirective;
  2. Sometime before the 2nd scroll-to-bottom, call this:
    this.infiniteScroll.ngOnDestroy();
    this.infiniteScroll.setup();

Thanks @Josh-TX for the solution, I am just elaborating more here for Angular 6 and Typescript users

  1. Import directive in the file
    import { InfiniteScrollDirective } from 'ngx-infinite-scroll';
  2. Get a reference to it
    @ViewChild(InfiniteScrollDirective)
    set appScroll(directive: InfiniteScrollDirective) {
    this.infiniteScroll = directive;
    }

Then on onScroll function call two methods

  1. this.infiniteScroll.ngOnDestroy();
  2. this.infiniteScroll.setup();

@AmitJain628 after i apply the solution, the event will trigger when i scrolled up. That's weird.

@McSam94 I am also facing the same issue, even it is triggering for scrolling up, which is not weird

use alwaysCallback=true

@AmitJain628 after i apply the solution, the event will trigger when i scrolled up. That's weird.

Hi @McSam94 , I am facing the same issue. Event is getting triggered even when I am scrolling up. have you got any work-around for it ?

Was this page helpful?
0 / 5 - 0 ratings