ViewportScroller
Defines a scroll position manager. Implemented by BrowserViewportScroller.
API
abstract class ViewportScroller {
abstract setOffset(offset: [number, number] | (() => [number, number])): void;
abstract getScrollPosition(): [number, number];
abstract scrollToPosition(position: [number, number], options?: ScrollOptions | undefined): void;
abstract scrollToAnchor(anchor: string, options?: ScrollOptions | undefined): void;
abstract setHistoryScrollRestoration(scrollRestoration: "auto" | "manual"): void;
}
setOffset
voidConfigures the top offset used when scrolling to an anchor.
[number, number] | (() => [number, number])A position in screen coordinates (a tuple with x and y values) or a function that returns the top offset position.
void
getScrollPosition
[number, number]Retrieves the current scroll position.
[number, number]A position in screen coordinates (a tuple with x and y values).
scrollToPosition
voidScrolls to a specified position.
[number, number]A position in screen coordinates (a tuple with x and y values).
ScrollOptions | undefined
void
scrollToAnchor
voidScrolls to an anchor element.
stringThe ID of the anchor element.
ScrollOptions | undefinedScroll options
void
setHistoryScrollRestoration
voidDisables automatic scroll restoration provided by the browser. See also window.history.scrollRestoration info.
"auto" | "manual"
void
Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/common/ViewportScroller