8000 appendOnly=true Behavior in AutoSizeVirtualScrollStrategy Causes viewRange.start to Always Be 0 · Issue #1865 · rx-angular/rx-angular · GitHub
[go: up one dir, main page]

Skip to content

appendOnly=true Behavior in AutoSizeVirtualScrollStrategy Causes viewRange.start to Always Be 0 #1865

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

Open
friendlyAce opened this issue Mar 27, 2025 · 0 comments

Comments

@friendlyAce
Copy link
Contributor

Description

When using the AutoSizeVirtualScrollStrategy with the appendOnly input set to true, the viewRange event emitter output (of type ListRange with the start and end properties) always has its start value set to 0, regardless of the current scroll position in the list.

This behavior appears to be caused by the following snippet in the calcRenderedRange method of autosize-virtual-scroll-stategy.ts:

if (this.appendOnly) {
  range.start = Math.min(this._renderedRange.start, range.start);
  range.end = Math.max(this._renderedRange.end, range.end);
}

This logic ensures that the start value in the viewRange output does not increase beyond the initial value when appendOnly is true.

If _renderedRange.start is 0, range.start will always remain 0

Expected Behavior

When appendOnly is true, the viewRange.start should reflect the actual visible range of items in the viewport not the whole runway.
Or there should be a way to configure this behavior.
Or alternatively, there could be two outputs:

  1. One for the rendered range (current behavior).
  2. Another for the visible range (reflecting the range of items that are currently visible in the viewport).

Actual Behavior

Image

When appendOnly is true, viewRange.start always remains 0, regardless of the current scroll position.

Steps to Reproduce the Issue

Use the AutoSizeVirtualScrollStrategy with the appendOnly input set to true.
Bind to the viewRange output and observe its start value while scrolling through the list.
Notice that viewRange.start remains 0, even when scrolling to the bottom of the list.

Environment

  • RxAngular versions: "@rx-angular/cdk": "^17.1.0", "@rx-angular/template": "^17.3.1",
  • Angular Version: 17
  • Browser: Chromium
  • Operating System: win32 x64

Related to Other Issues

#1765

This issue is particularly problematic for applications that rely on lazy data loading, as it can lead to:

  • Delayed Data Loading: Since viewRange.start is always 0, it becomes difficult to determine the actual range of visible items. This can lead to unnecessary data requests for items that are no longer visible, causing delays in loading the last data chunk when scrolling to a specific index or even to the bottom.
  • Inefficient Data Management: Developers cannot efficiently manage data requests based on the actual visible range of items

Questions

  • Is This Behavior Intended?

    • Is it intentional that viewRange.start remains 0 when appendOnly is true? If so, could you clarify the reasoning behind this design decision?
  • Can This Be Made Configurable?

    • Would it be possible to introduce a configuration option to allow viewRange.start to reflect the actual visible range of items, even when appendOnly is true?
  • Can Two Outputs Be Provided?

    • Could you consider providing two separate outputs:
      • One for the rendered range (current viewRange behavior).
      • Another for the visible range (reflecting the items currently visible in the viewport)?
  • This would allow developers to handle lazy data requesting/loading more effectively while still benefiting from the appendOnly behavior for things like drag & drop etc.

BR,
Vincent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0