Skip to content

virtual-scroll: Fixes scroll gap with autosize #11195

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
private _updateTotalContentSize(renderedContentSize: number) {
const viewport = this._viewport!;
const renderedRange = viewport.getRenderedRange();

// once we hit the bottom, we need to resample our range
// based on the items in view so we don't create a gap
if (renderedRange.end === viewport.getDataLength()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know that this fixes it, probably will want to find a way to do it that doesn't lose our size info though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, I suspected this was more of a starting point rather than the actual fix.

this._averager.reset();
this._averager.addSample(renderedRange, viewport.getDataLength());
}

const totalSize = renderedContentSize +
(viewport.getDataLength() - (renderedRange.end - renderedRange.start)) *
this._averager.getAverageItemSize();
Expand Down