@angular/cdk
Version:
Angular Material Component Development Kit
58 lines (55 loc) • 2.03 kB
TypeScript
import * as i0 from '@angular/core';
import { OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
/** Time in ms to throttle the resize events by default. */
declare const DEFAULT_RESIZE_TIME = 20;
/** Object that holds the scroll position of the viewport in each direction. */
interface ViewportScrollPosition {
top: number;
left: number;
}
/**
* Simple utility for getting the bounds of the browser viewport.
* @docs-private
*/
declare class ViewportRuler implements OnDestroy {
private _platform;
private _listeners;
/** Cached viewport dimensions. */
private _viewportSize;
/** Stream of viewport change events. */
private readonly _change;
/** Used to reference correct document/window */
protected _document: Document;
constructor(...args: unknown[]);
ngOnDestroy(): void;
/** Returns the viewport's width and height. */
getViewportSize(): Readonly<{
width: number;
height: number;
}>;
/** Gets a DOMRect for the viewport's bounds. */
getViewportRect(): {
top: number;
left: number;
bottom: number;
right: number;
height: number;
width: number;
};
/** Gets the (top, left) scroll position of the viewport. */
getViewportScrollPosition(): ViewportScrollPosition;
/**
* Returns a stream that emits whenever the size of the viewport changes.
* This stream emits outside of the Angular zone.
* @param throttleTime Time in milliseconds to throttle the stream.
*/
change(throttleTime?: number): Observable<Event>;
/** Use defaultView of injected document if available or fallback to global window reference */
private _getWindow;
/** Updates the cached viewport size. */
private _updateViewportSize;
static ɵfac: i0.ɵɵFactoryDeclaration<ViewportRuler, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ViewportRuler>;
}
export { DEFAULT_RESIZE_TIME as D, ViewportRuler as V, type ViewportScrollPosition as a };