填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

ViewportScroller

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 ngInjectableDef: ɵɵdefineInjectable({ providedIn: 'root', factory: () => new BrowserViewportScroller(ɵɵinject(DOCUMENT), window, ɵɵinject(ErrorHandler)) })

方法

Configures the top offset used when scrolling to an anchor.

abstract setOffset(offset: [number, number] | (() => [number, number])): void
      
      abstract setOffset(offset: [number, number] | (() => [number, number])): void
    
参数
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.

返回值

void

Retrieves the current scroll position.

abstract getScrollPosition(): [number, number]
      
      abstract getScrollPosition(): [number, number]
    
参数

没有参数。

返回值

[number, number]: A position in screen coordinates (a tuple with x and y values).

Scrolls to a specified position.

abstract scrollToPosition(position: [number, number]): void
      
      abstract scrollToPosition(position: [number, number]): void
    
参数
position [number, number]

A position in screen coordinates (a tuple with x and y values).

返回值

void

Scrolls to an anchor element.

abstract scrollToAnchor(anchor: string): void
      
      abstract scrollToAnchor(anchor: string): void
    
参数
anchor string

The ID of the anchor element.

返回值

void

Disables automatic scroll restoration provided by the browser. See also window.history.scrollRestoration info.

abstract setHistoryScrollRestoration(scrollRestoration: "auto" | "manual"): void
      
      abstract setHistoryScrollRestoration(scrollRestoration: "auto" | "manual"): void
    
参数
scrollRestoration "auto" | "manual"
返回值

void