question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Inifinite scroll with position="top" does not work as expected in Ionic 5

See original GitHub issue

Bug Report

Ionic version:

[x] 5.x

Current behavior:

When scrolled to top of the page or even before getting to the top, the ionInfinite event should be called. But when reaching to the top, it does not call the ionInfinite event. Problem I’m facing is, the scroll does not work after i reach to top of page. I’m expecting the data to be added whenever I’m reaching the top of the screen. However, it works when I scroll down a little bit and then slightly scroll up, the data is being called and gets added to array.

Expected behavior:

I expect ionInfinite event to be called whenever I reach top of the page with postion="top" on ion-infinite-scroll like how it works flawlessly with postion="bottom"

Steps to reproduce:

  1. Add ion-infinite-scroll element with postion="top" attribute to your ion-content
  2. Try to scroll to the top, it won’t scroll once it reaches top, though I have data incremented to the array.
  3. You will need to scroll down a little bit in order for infinite scroll to work and then the data loads.

Related code:

Here’s the repository for full code

HTML

<ion-content [scrollEvents]="true" (ionScroll)="logScrolling($event)">

  <ion-list>
     <ion-item *ngFor="let item of items">
         <ion-label>{{item.name}}</ion-label>
     </ion-item>
  </ion-list>

  <ion-infinite-scroll threshold="10%" postion="top" (ionInfinite)="loadData($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
  </ion-infinite-scroll>
</ion-content>

TS

  @ViewChild(IonInfiniteScroll, { static: false })
  infiniteScroll: IonInfiniteScroll;
  @ViewChild(IonContent, { static: false }) content: IonContent;

  ...

  loadData(event) {
    setTimeout(() => {
      this.getNewData();
      event.target.complete();
    }, 500);
  }

Other information:

Ionic info:

Ionic:

   Ionic CLI                     : 6.4.0 (/Users/pavanchilukuri/.nvm/versions/node/v10.18.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.7
   @angular-devkit/build-angular : 0.803.24
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 1.3.0
   @capacitor/core : 1.3.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v10.18.1 (/Users/pavanchilukuri/.nvm/versions/node/v10.18.1/bin/node)
   npm    : 6.13.4
   OS     : macOS Catalina
   Xcode  : Xcode 11.4.1 Build version 11E503a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, May 11, 2020

Thanks! Looks like this is a duplicate of https://github.com/ionic-team/ionic/issues/19540, so I am going to close this in favor of the older issue.

0reactions
ionitron-bot[bot]commented, Jun 10, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

On iOS devices, why does Ionic 4 Infinite Scroll jump to the top ...
Expected behavior: The screen scroll should not be affected by adding items to a list.
Read more >
ion-content - Ionic Framework
Content provides methods that can be called to scroll the content to the bottom, top, or to a specific point. They can be...
Read more >
ion-refresher causing fixed elements to scroll - You.com
The ion-refresher is a really special component. No matter where you place it, it will be put at the top of the nearest...
Read more >
The 9 Most Common Mistakes That Ionic Developers Make
The problem with Cordova CLI is that the platforms and plugins you install are installed on your machine only. When working on a...
Read more >
Troubleshooting React Virtuoso
Technically, this could have been a warning, but it is usually a sign of something not working as expected, so throwing an error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found