Skip to content

The Scrolled event fires when it shouldn't #459

@Maxmyd

Description

@Maxmyd

Hello,
Here's my template part

<div
  class="post-list"
  infiniteScroll
  [infiniteScrollDistance]="2"
  [infiniteScrollUpDistance]="1.5"
  [infiniteScrollThrottle]="50"
  (scrolled)="onScrollDown()"
  (scrolledUp)="onScrollUp()">
ngOnInit(): void {
    this.querySub = this.route.queryParams.subscribe(params => {
      this.isSearchPage = this.router.url.startsWith('/search');
     const tagName = params['tag'];
      if (this.isSearchPage) {
        if (typeof tagName === 'string') {
          this.updateFilters = PostListArgs.empty();
          this.updateFilters.tag = tagName;
          this.tagName.set(tagName);
        } 
        this.posts.set([]);
        this.pager = undefined;
        this.loadPosts();
      } else {
        this.buildFilters();
        this.loadPosts();
      }
    });
  }

  onScrollDown() {
    this.loadPosts();
  }

 loadPosts() {
    this.updateFilters = {
      ...this.updateFilters,
      page: this.pager ? this.pager.page + 1 : 1,
      pageSize: this.pager ? this.pager.count : 10,
    };
 // loading posts 
}

When api returns a single record, the "scrolled" event fires, and loadPosts() is called again. As a result, I see the list containing 2 similar posts. Is that a bug or is it something in options I didn't know?
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions