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.

Virtual scroll flickering when we update it with new data

See original GitHub issue

Bug Report

Ionic version:

[x] 4.0.0

Current behavior: We’ve a scenario in our app. We load the cached data from the local store and when we receive the latest data from server, we will update the list.

So when we’re doing this, the page is flickering when update happens. I understand that when we set the data it may flicker, but trackBy option should solve this, which is not happening.

Expected behavior: It should not flicker when we update the list with the latest data.

Steps to reproduce: Add a viritual-scroll to a page and initialize with some items and update the list with new set of data.

Related code:

https://github.com/roopeshreddy/virtual-scroll-issue

<ion-virtual-scroll [items]="items" [trackBy]="trackByFn">
    <ion-item *virtualItem="let item">
      <ion-icon [name]="item.icon" slot="start"></ion-icon>
      {{ item.title }}
      <div class="item-note" slot="end">
        {{ item.note }}
      </div>
    </ion-item>
  </ion-virtual-scroll>

Other information:

We’ve tried the same in Chrome browser, iOS simulator and real iPhone 7 device.

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.10.3 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.1
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

System:

   NodeJS : v10.15.0 (/usr/local/bin/node)
   npm    : 6.5.0
   OS     : macOS Mojave

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:43 (7 by maintainers)

github_iconTop GitHub Comments

16reactions
gartorwarecommented, Apr 19, 2019

Same problem here. As a solution I have set the itemHeight function, so the virtual scroll is not flickering any more.

In my particular case it was easy since all my items have the same height: HTML:

<ion-virtual-scroll [items]="items" [trackBy]="trackByFn
approxItemHeight="52px" [itemHeight]="itemHeightFn">
   ...
</ion-virtual-scroll>

TS:

...

itemHeightFn(item, index) {
    return 52;
}

Now only the headers are flickering…

9reactions
9i0xin9commented, Sep 15, 2019

I just found a work around for the flickering header. I was checking the css and during the loading part a class .virtual-loading is assign to ion-item-divider element. Forcing the class with a state of opacity: 1 did the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ion-virtual-scroll flickers when content gets updated
I am facing an issue with ion-virtual-scroll . When the content updated the list gets flickered. Html. <ion-virtual-scroll ...
Read more >
Developers - Virtual scroll flickering when we update it with new data -
Current behavior: We've a scenario in our app. We load the cached data from the local store and when we receive the latest...
Read more >
Virtual Scroll Cdk Table Test (forked) - StackBlitz
cdk-virtual-scroll, sticky headers working, no flickering.
Read more >
ion-virtual-scroll - Ionic Framework
ion-virtual-scroll. Virtual Scroll displays a virtual, "infinite" list. An array of records is passed to the virtual scroll containing the data to create ......
Read more >
Telerik Web Forms Virtual Scrolling - RadGrid - Documentation
For really huge data sets, RadGrid allows virtual scrolling. If you need endless scrolling in your grid, we recommend that you use the...
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