ViewportScroller
Manages the scroll position.
abstract class ViewportScroller {
static ngInjectableDef: defineInjectable({ providedIn: 'root', factory: () => new BrowserViewportScroller(inject(DOCUMENT), window) })
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 ngInjectableDef: defineInjectable({ providedIn: 'root', factory: () => new BrowserViewportScroller(inject(DOCUMENT), window) }) |
方法
Configures the top offset used when scrolling to an anchor. | |||
参数
返回值
| |||
When given a tuple with two number, the service will always use the numbers. When given a function, the service will invoke the function every time it restores scroll position. |
Returns the current scroll position. |
参数没有参数。 返回值
|
Sets the scroll position. |
Scrolls to the provided anchor. |
Disables automatic scroll restoration provided by the browser. |