-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(virtual-scroll) many fixes #12194
Conversation
fixes ionic-team#9699 fixes ionic-team#11484 fixes ionic-team#11389 fixes ionic-team#11325 fixes ionic-team#11291 fixes ionic-team#10828 fixes ionic-team#11291 fixes ionic-team#10393 fixes ionic-team#10257 fixes ionic-team#9434 fixes ionic-team#8933 fixes ionic-team#7178 fixes ionic-team#7047 fixes ionic-team#10552 fixes ionic-team#10393 fixes ionic-team#10183 fixes ionic-team#10187 fixes ionic-team#10852 fixes ionic-team#11578
When `Tabs` are nested within each other, the highlight can get misaligned. This prevents that by ensuring the affected `.tab-highlight` is a direct child of the targeted `Tabs`.
…tabs * wip * wip * progress * wippy skippy * getting there * all tests passing except goBack * unit tests pass again boi * goBack tests pass * great success * the good stuff
Ionic-team please decide between if I should go for Case 2 or Case 3In const viewportElement = virtualScrollElement.parentElement;
data.viewHeight = viewportElement.offsetHeight;
data.renderHeight = (data.viewHeight * bufferRatio); So this code, get's the dimensions for virtual-scroll before it will render the new nodes. But that it's before causes issues and getting it after is to late. This causes the following behavior: Case 1, parent of virtual-scroll is ion-contentWorks because, when the parent of virtual-scroll is the ion-content it will get the solution: works anyway. Case 2, parent of virtual-scroll is div with height not setFails because, when you put virtual-scroll in a div with no height-specified. It will ever use the solution: just act as we where in case 1. I'm new to angular and I don't saw that you ever used something like let el = document.getElementsByClassName('scroll-content')[0] as HTMLElement;
data.viewHeight = el.offsetHeight; Case 3, parent of virtual-scroll is div with fixed-height and overflow:scrollThis would also be somehow cool, since it would make support for multiple virtual-scrolls. solution: attach scroll-listener to parent element and say people that virtual-scroll must be in a container with a |
Hey there! I'd like to implement these fixes in my ionic3 project, but I don't know how to do it. @mnewmedia how can I achieve it? Thanks a lot for your work! |
@HugoHeneault There is no easy way I know to implement this fixes in an existing project. |
Okay, so we just have to wait I guess :( Thanks for your reply! |
@speedtreammanga Please post this as an issue. This does not belong in the PR thread |
If anyone is willing to try this PR easily, you can remplace your ionic-angular by this folder we've built: |
Thanks for compiling this PR in a new version @HugoHeneault. If by any chance you did the same kind of package for [email protected], I'll be very interested :-) |
any news to the virtual-scroll?
|
@nilebma I don't have this. But you could clone the ionic repo, then apply the changes of this PR to the current ionic repo, then build it. :) |
Hi, I've download the folder you built and it works fine, solved the annoying flickers, but I got another problem. After |
Here is the compiled version for 3.6.0 for whoever needs it. Please give some attention to virtual scroll, it has been broken for many months now. |
This might not be the correct path to take to fix the issue. Removing RequestAnimationFrame wrapper made virtualScroll not render correctly in actual devices (probably because they are slower and thus queuing system is needed). Besides, completely disposing of nodes every time the dataset changes was always problematic and even if you can fake it, there will always be a performance impact. After extensive tests with this pull request's code and meticulous debugging of the original code I have come up with a pull request that addresses the above issues by changing the core handling of what happens when a change is identified. For more info please see #12917 |
@brandyscarney, @danbucholtz |
Yeah, another PR which apparently might be more efficient than this one was merged but not yet released. Probably soon with 3.7.2 :) |
a simple virtualscroll is not rendering correctly on iOS9, but it's working on iOS10 & IOS11 & Android. |
Hello and thank you for contributing to Ionic! We have been working on porting all of the Ionic components to web components and have recently updated |
Ionic Version: 3.x
Short description of what this resolves:
*ngIf
Conditional on VirtualScroll causes no content to be displayed in any case #9655maybe also #10971
Influences / How I worked
I went through the history of virtual-scroll.ts and took an older version where people said it was better. Then I added the changes slowly again to find out where some bugs where introduced.
I also compared stuff with angular's
ngForOf
implementation because ionic also did this in the start, but with time ionic drifted more and more off.Changes proposed in this pull request:
_differ
, create it only if it does not already exists. don't use the setter instead uses thengOnChanges
. why?ngFor
is also like this. May solves someinit
problems. Easier to reason about._changes()
. why? because if we clear the items array with setting it to null, the clearing get's never proceeded._records
isnull
.this._plt.raf(()
inrenderVirtual()
. why? because this caused the flickering while updating the list. caution I'm not sure why or whatthis._plt.raf(()
did, so may review this point a bit deeper.How the issues came and what we should care in future.
I think a lot issues came with changes to get
virtual-scroll
withInfiniteScroll
together working, but I think it's more important to getvirtual-scroll
battle tested before getting it to work with other stuff which may introduces new bugs. PS: I didn't test the changesInfiniteScroll
.Don't care about everything below, you are free to merge..
My WIP Notes - for even further improvements
ion-button
abovevs
thecalcDimensions
gets16px
too much? Would not matter so much, if the next point would be resolved.calcDimensions();
get's only executed ifneedsClean=true
, if youpush
an item theviewHeight
get's not updated and so you will not see the newly added items until another change causesneedsClean
to be true.Semantic issues
Would look better in a separate PR, so this PR, stays clean with just fixes.
rename
processRecords()
rename toaddCells()
why? Nobody know's what it's gonna process.addCell()
rename tocreateCell()
why? it doesn't add anything, it just returns acell
.readElements()
rename tocalcCellDimension()
keep consistent withcalcDimensions
. And readElements doesn't give any hint about, that it will change any data.modified by reference
processRecords()
modifies_cells
by reference and doesn't return anything, looks a bit weird.calcDimension()
modifies_data
by reference and doesn't return anything, looks a bit weird.more
renderVirtual()
remove resettingtopCell/bottomCell
, because they get overwritten anyway in the followingadjustRendering()
.writeUpdate()
you callreadUpdate()
orupdateDimensions()
which is contained inreadUpdate()
. Just put readUpdate as first line intowriteUpdate()
.adjustRendered()
you callupdateDimensions()
so putupdateDimensions()
inadjustRendered()
.updateDimensions()
would split it intocalcCellDimensions()
andupdateEstimatedDimensions()
.virtual-util.ts
contains a lotvar
replace withlet
?readElements()
here you updatecell.left
but inupdateDimensions()
it will get overwritten anyway.Overview helps me finding out what is going on when..
init/data changes
readUpdate()->calcDimension()
updatesheigth/width/top/left
ofdata
and guessesitmWidth/itmHeigth
writeUpdate()->processRecords()
records to CellswriteUpdate()->renderVirtual()->updateDimensions()
calcCellDimensionswriteUpdate()->renderVirtual()->adjustRendered()
settopCell/bottomCell
indata
finds out which cells should be rendered.writeUpdate()->renderVirtual()->populateNodeData()
assign cells to nodes.writeUpdate()->renderVirtual()->initReadNodes()
update first cell with position of first node andupdateDimensions()
again?writeUpdate()->renderVirtual()->updateNodeContext()
updates positions of the nodes?writeUpdate()->renderVirtual()->_stepChangeDetection()
detect changes in nodes?writeUpdate()->renderVirtual()->_stepDOMWrite()
set positions of nodes on the domscroll
_stepNoChanges()->processRecords()
records to Cells_stepNoChanges()->updateDimensions()
calcCellDimensions_stepNoChanges()->adjustRendered()
settopCell/bottomCell
indata
finds out which cells should be rendered._stepNoChanges()->populateNodeData()
assign cells to nodes._stepNoChanges()->updateNodeContext()
updates positions of the nodes?what's the difference of stepsNoChanges and writeUpdate?
what's the difference of writeUpdate and _stepDOMWrite