ViewportScroller
class
Defines a scroll position manager. Implemented by BrowserViewportScroller
.
abstract class ViewportScroller { static ngInjectableDef: defineInjectable({...}) abstract setOffset(offset: [number, number] | (() => [number, number])): void abstract getScrollPosition(): [number, number] abstract scrollToPosition(position: [number, number]): void abstract scrollToAnchor(anchor: string): void abstract setHistoryScrollRestoration(scrollRestoration: "auto" | "manual"): void }
Static properties
Property | Description |
---|---|
static ngInjectableDef: defineInjectable({
providedIn: 'root',
factory: () => new BrowserViewportScroller(inject(DOCUMENT), window, inject(ErrorHandler))
}) |
Methods
setOffset() | |||
---|---|---|---|
Configures the top offset used when scrolling to an anchor. | |||
|
offset | [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() |
---|
Retrieves the current scroll position. |
|
scrollToPosition() | |||
---|---|---|---|
Scrolls to a specified position. | |||
|
position | [number, number] | A position in screen coordinates (a tuple with x and y values). |
Returns
void
scrollToAnchor() | |||
---|---|---|---|
Scrolls to an anchor element. | |||
|
anchor | string | The ID of the anchor element. |
Returns
void
setHistoryScrollRestoration() | |||
---|---|---|---|
Disables automatic scroll restoration provided by the browser. See also window.history.scrollRestoration info. | |||
|
scrollRestoration | "auto" | "manual" |
Returns
void
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v7.angular.io/api/common/ViewportScroller