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.

Ionic 2 beta 11 virtual scroll and infinite scroll autoscrolls up after update

See original GitHub issue

Trying to build contact list with about 10k nodes, my assumption was to combine virtualScroll and infinite-scroll controller, so my page is like below:

<ion-content>
      <ion-list [virtualScroll]="contacts">
        <ion-item *virtualItem="let contact">
....
        </ion-item>
      </ion-list>

      <ion-infinite-scroll (ionInfinite)="doInfiniteInvitation($event)">
        <ion-infinite-scroll-content></ion-infinite-scroll-content>
      </ion-infinite-scroll>
</ion-content>

and .ts controller

  doInfiniteInvitation(infiniteScroll) {
    console.log('doInfiniteInvitation');
    this.contactsService.contact_invitations()
    .then(contacts => {
      for (var i = 0; i < contacts.length; i++) {
        this.contacts.push(contacts[i]);
      }

      infiniteScroll.complete();
      console.log('doInfiniteInvitation done');
    });
  }

so after every doInfiniteInvitation call it resets to the top position, is it possible somehow avoid this “feature”? may be [virtualTrackBy]=“virtualTrack” can help with that?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lujakobcommented, Nov 30, 2016

Hey guys, I set up a repository with a simple implementation of my solution. (The solution itself is not that simple, but the demo 😉 ) It’s a custom variation of the original infinite scroll component. Scrolling back and forth with a replacement of the content to prevent DOM stuffing. As well the fetched content will scroll to the correct position after loading. The original loading spinner is replaced by a Loading component, because having the spinner on top of the list won’t work that easy. https://github.com/lujakob/ionic-infinite-scroll-example

1reaction
gfviegascommented, Nov 3, 2016

Hey, lots of questions about this on forums and articles about virtual scroll. Any update on that? This is a must-have in many applications. Wonder how would be an Ionic’s Twitter without infinite scrolling, loading tons of useless data, or without virtualscroll leaving tons of useless data behind as you scroll…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ion-virtual-scroll - Ionic Framework
Virtual Scroll displays a virtual, "infinite" list. An array of records is passed to the virtual scroll containing the data to create templates...
Read more >
VirtualScroll + InfiniteScroll scrolls top when reaching list bottom
When the bottom of virtual list is reached, infinite scroll is triggered, items are loaded and displayed all ok, but after that the...
Read more >
An example of virtualScroll and Infinite Scroll in Ionic 2
In this post, Andrew describes how you can use the Ionic CLI to generate both an application and a boilerplate HTTP service, or...
Read more >
Increase Ionic Scroll Performance with Virtual Scroll & Infinite ...
In this tutorial we increase our list performance with big data using Ionic Virtual Scroll & Infinite Scroll ! Learn to build mobile...
Read more >
How to use Angular Virtual Scroll with Ionic - YouTube
The Ionic virtual scroll component was deprecated with Ionic 6, but we can easily transition to the Angular virtual scroll implementation to ...
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