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.
@paramoffset
[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.
@returns
void
getScrollPosition
[number, number]Retrieves the current scroll position.
@returns
[number, number]
scrollToPosition
voidScrolls to a specified position.
@paramposition
[number, number]A position in screen coordinates (a tuple with x and y values).
@paramoptions
ScrollOptions | undefined
@returns
void
scrollToAnchor
voidScrolls to an anchor element.
@paramanchor
stringThe ID of the anchor element.
@paramoptions
ScrollOptions | undefined
@returns
void
setHistoryScrollRestoration
voidDisables automatic scroll restoration provided by the browser. See also window.history.scrollRestoration info.
@paramscrollRestoration
"auto" | "manual"
@returns
void