diprokon / ng-table-virtual-scroll

Virtual Scroll for Angular Material Table
https://diprokon.github.io/ng-table-virtual-scroll
MIT License
134 stars 42 forks source link

ScrollingFix: Changing scroll detection algorithm to use relative scroll distances #66

Closed AlexanderPruss closed 3 years ago

AlexanderPruss commented 3 years ago

This is still a slight work in progress due to figuring out a test adjustment + taking care of one more special case. See my WIP note below.

This should address the following issues, I think - https://github.com/diprokon/ng-table-virtual-scroll/issues/42 https://github.com/diprokon/ng-table-virtual-scroll/issues/58 https://github.com/diprokon/ng-table-virtual-scroll/issues/60

It looks like the algorithm for adjusting the rendered content could get confused when a row moved in or out of view. I couldn't figure out a way to fix this algorithm using absolute scrollOffsets and renderedOffsets, because the scrollOffset would jump at the same time as the renderedOffset, which would cause all sorts of problems at the point of the jump.

Instead, I used the observation that we really only need to scroll when the scrollOffset moves more than one row of distance. This means that moving the table can be determined by the relative distance between scrollOffset and renderedOffset instead of the absolute distance.

WIP NOTE

I finished up the last of the WIP tasks. There's a slight change to the tests because I handle the top of the table slightly differently.

AlexanderPruss commented 3 years ago

Should be ready for a review now

KanAlexey commented 3 years ago

@diprokon It will be great to have this changes live)

@AlexanderPruss Great work!

f0obar commented 3 years ago

Thanks, this fixed me a lot of headaches 👍 👍 👍

alexanderzulechner commented 3 years ago

nice work! any news about when we can expect it to be merged and published @diprokon ?

diprokon commented 3 years ago

I'm very sorry for so long delay. Version 1.3.7 with this changes is available now

@AlexanderPruss thank you very much for such amazing job! I was struggling with those issues for a long time, and your new approach is looking much better!

alexanderzulechner commented 3 years ago

@diprokon we use this library in production, and therefore forked @AlexanderPruss fix, because we encountered a few small things which needed to be improved: https://github.com/AlexanderPruss/ng-table-virtual-scroll/pull/1

would u mind to check it there? or should I fork your repo and re-create the PR for that? just let me know :)

diprokon commented 3 years ago

@alexanderzulechner can you, please, check your issue with the latest version, I cannot reproduce it. If it is still there, please open new issue (with code example) or PR in this repository, as I have access only to this one