New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Virtual scroll flickering when we update it with new data #17540
Comments
Same problem here |
Same here, despite I could verify that the trackBy function is getting called. |
@manucorporat - Any help on this? |
Can confirm that the trackBy function is called. |
I see this issue too, if it’s the same thing for what I am seeing it looks like the cards are all being generating and their height expanded/stretched out within milliseconds. It happens so fast it just looks like a flicker of all the cards being rendered real fast, but overall this gives the app a poor look and experience. I have two virtual scroll lists that show/hide based on an ngIf, and each time I toggle I see this flicker. Tried to use trackBy, tried to use hidden, but with no luck. Using hidden with virtual scroll is another issue... |
Same problem here. As a solution I have set the In my particular case it was easy since all my items have the same height:
TS:
Now only the headers are flickering... |
Is there any workaround this flickering issue? Unfortunately I am stuck with items of varying heights in the virtual scroll. ---edit---- I have found a solution for my situation!
Hinted from reading the documentation closely! Happy coding! |
Are you using headers/footers? Are they flickering if you do not recreate the array? |
Just tried. For me, headers are still flickering even if you do not recreate the source array. |
Looking at the source, i'd assume that:
|
@gartorware using the It probably doesn't flicker with Setting |
Hello! I've just opened a PR adding 2 more functions for header and footer, that work like the |
Thanks! This issue has been resolved and will be available in the Ionic 4.7.0 release. If anyone encounters new issues with virtual-scroll, please open a new issue. |
@liamdebeasi a related issue was resolved, but not this one. Sure, the
The broken |
Thanks! I reopened the issue and we will investigate. |
Thank you for reopening the issue! i wouldn't bet money on it, but otherwise i'm somewhat sure, that that is the cause (at least one of the causes) why the trackBy has no effect |
I just found a work around for the flickering header. |
ionic 4.11.4 and the flicker still happens even if approxItemHeight is added. Man, this needs to be a priority. |
Inspired by @9i0xin9 It seems I figured it out by putting
the flicker does not happen anymore (Ionic 4.11.5) but this not a very elegant solution ... |
As mentioned by @9i0xin9, to fix the Header flicker, I used Now the Header would not flicker, BUT the would start flickering again, despite adding the following function to the
As of now, I don't see a way to fix both Virtual Item flicker and Header flicker at the same time. If anyone knows of any solution for this, please share. Thank you. |
Seeing the same thing with ionic 5 in chrome, with a very basic virtual scroll, even with just 3 items in the array. I do use the approxItemHeight. Ionic info
|
Setting the right heights and approx heights did do the trick for me. HTML TS File
|
Same problem here using the ionic version 5, apparently it's related to trackBy, without it it works.. |
Same problem with 5.26.0 |
I have same idea as #17540 (comment) trackByFn don't effect to rendering. We expand this line will effect to nodeRender method: Expected behavior: https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts#L229-L246 Related code: |
I see... This may ionic/core issue: |
for any new item i get my virtual screll ion list items rebuild, itemHeight fix the problem |
[INFO] I created support ion-virtual-scroll service sample in angular instead of trackBy: OR you can use virtual-scroll of Angular CDK: |
For items added to the top none of the work arounds is fixing it for me, I tried I also tried not changing the reference to Are there any other solutions? Version: 5.4.3 |
Regarding the issue I brought up with adding items to the top the virtual scroll is working just fine it was an issue on my side of removing items from the DOM (user error). The only issue I see now is the broken trackBy which as been mentioned previously. Hopefully there is a fix for that at some point. |
adding "opacity: 1" seems to have fixed the problem, but it's only a visual fix, the list is still re-rendering, and ItemHeigh is not an option for me, because i have dynamic item heights, a fix for trackBy would be highly appreciated, thanks. |
I'm having the same issue as BendrissM, my content is based on the width of the screen and therefore can have differentiating heights. And the list seems to be re-rendering every now and then. This did not happen when I was using ionic version 4.7.1. After updating to the latest version this bug started to exist. Please make a fix for trackBy. |
@Simbaclaws i have just switched to @angular/cdk and used their version of virtual scroll, that worked well for me. |
@BendrissM can I just import @angular/cdk and then use their |
@Simbaclaws first you import it in your page's module like this :
you should specify |
Hmmm odd, with the same data as with the ion-virtual-scroll it only generates 2 of my components instead of all of them inside the cdk-virtual-scroll-viewport, and I can not see the components at all... Could I perhaps contact you somehow? I'm having a really hard time building a good solution. I do not know how big my list will be so setting a height of some sort is not something I can do :/ EDIT: After your edit I got it working 👍 !! Thank you so much! Is there also a way to scroll the ion-content instead of the viewport within? It seems like some parts of my content get cut off when I scroll inside the viewport. Instead of extending the ion-content... I don't know how long my list will be so I don't know how high I should set it.... |
happy it worked, i actually still have this problem, and couldn't bother to fix it tbh , since if you just scroll again you'll see the other content, but i think it should be fixed if you set the viewport height to the height of the screen the it should be working, since i guess in my example, 760px is maybe bigger than the the height of the ion-content, that's why your content get's cut off in the end |
I decided to go without virtual scrolling (just put everything in a div), see what the actual performance hit will be. Since most of the solutions don't seem to work well for me. It's not a lot of content that is generated I suppose. EDIT: I found a solution, I can just put the virtual scroll viewport around the entire page. This solved the issue I was having with a scoll area within the page, rather then scrolling the entire page. |
oh good idea, i will try it as soon as i can, thank you. 👍 |
The only issue I'm still having is that I can't get the scroll position back to a previous state when moving from and to the view. I think I need to use a customRouteReuseStrategy in order to keep my pages cached to the correct scroll position inside CdkVirtualScrollViewport. Where we are not allowed to use our own route reuse strategy... Calling This issue also happens without virtual scroll view, apparently I just can't get back to the same scroll position in a situation where I have: main view -> detail view -> main view I'm using router navigation with a custom router history service in order to navigate to the previous page.
I'm getting more and more frustrated by the ionic framework because I can't seem to do basic things an app should have. EDIT: I was able to fix my issue by creating a low interval that keeps setting the virtual scroll view position until after ionViewDidEnter with a timeout. This causes the page to get scrolled to the correct position when I pass them around using router parameters with NavigationExtras. |
thanks, you save my day. |
Thanks for the issue! With the release of Ionic 6, we made the decision to deprecate Moving forward, We have prepared migration guides for each of the 3 JavaScript frameworks we support, so developers can get started migrating right away. Migration for Angular Some Ionic components that rely on scrolling inside of We believe this change will lead to a healthier Ionic ecosystem as it frees up resources for the Ionic team to dedicate to other areas of this project while still giving developers options for performant virtual scroll solutions. Thank you! |
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. |
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
Other information:
We've tried the same in Chrome browser, iOS simulator and real iPhone 7 device.
Ionic info:
The text was updated successfully, but these errors were encountered: