Skip to content

bug(cdk/scrolling): Append only mode together with FixedSizeVirtualScrollStrategy results in a jumping view #23577

Closed
@philippspindler

Description

@philippspindler

Reproduction

See the example in the official material documentation
https://material.angular.io/cdk/scrolling/overview#cdk-virtual-scroll-append-only

  1. Scroll down
  2. Scrolling is delayed and the correct position is only set after a delay
Screen.Recording.2021-09-13.at.15.43.49.mov

Note: This effect becomes even more apparent when the rendering of an item is more expensive!

Expected Behavior

Virtual scrolling with appendOnly sets the correct position without jumping to the top.

Actual Behavior

The virtual scroll using appendOnly jumps for a certain time to the top of the scrolling container. After this period of time, the correct scroll position is set.

A possible solution

I was able to solve this issue by implementing a CustomScrollingStrategy that copy-pastes FixedSizeScrollingStrategy and adapts line 171.

- this._viewport.setRenderedContentOffset(this._itemSize * newRange.start);
+ this._viewport.setRenderedContentOffset(0, 'to-start');

I am missing the insights to be able to open a pull request fixing this issue respecting all different use cases of virtual scrolling with and without appendOnly. So I am open to any kind of help to fix this issue.

Environment

  • Angular: 12.2.5
  • CDK/Material: 12.2.5
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/scrolling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions