Skip to content

Expose programmatic scroll completion in ViewportScroller #69979

Description

@SkyZeroZx

Which @angular/* package(s) are relevant/related to the feature request?

router, common

Description

Chrome 150 introduced Promise-returning programmatic scroll APIs. These Promises indicate when scrolling has finished and whether it was interrupted.

Angular currently exposes:

scrollToPosition(position: [number, number], options?: ScrollOptions): void;
scrollToAnchor(anchor: string, options?: ScrollOptions): void;

BrowserViewportScroller calls window.scrollTo(), but its return value is discarded.

Proposed solution

Could ViewportScroller expose this completion signal through an additive API, for example:

scrollToPositionAsync(
  position: [number, number],
  options?: ScrollOptions,
): Promise<ScrollResult>;

scrollToAnchorAsync(
  anchor: string,
  options?: ScrollOptions,
): Promise<ScrollResult>;

This would allow applications, and potentially the Router in a follow-up, to wait for smooth scrolling to finish and detect interrupted scroll operations.

The existing synchronous methods could remain unchanged for backwards compatibility.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonIssues related to APIs in the @angular/common package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions