index.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. import { BooleanInput } from '@angular/cdk/coercion';
  2. import { ChangeDetectorRef } from '@angular/core';
  3. import { CollectionViewer } from '@angular/cdk/collections';
  4. import { DataSource } from '@angular/cdk/collections';
  5. import { Directionality } from '@angular/cdk/bidi';
  6. import { DoCheck } from '@angular/core';
  7. import { ElementRef } from '@angular/core';
  8. import * as i0 from '@angular/core';
  9. import * as i2 from '@angular/cdk/bidi';
  10. import { InjectionToken } from '@angular/core';
  11. import { IterableDiffers } from '@angular/core';
  12. import { ListRange } from '@angular/cdk/collections';
  13. import { NgIterable } from '@angular/core';
  14. import { NgZone } from '@angular/core';
  15. import { NumberInput } from '@angular/cdk/coercion';
  16. import { Observable } from 'rxjs';
  17. import { OnChanges } from '@angular/core';
  18. import { OnDestroy } from '@angular/core';
  19. import { OnInit } from '@angular/core';
  20. import { Platform } from '@angular/cdk/platform';
  21. import { _RecycleViewRepeaterStrategy } from '@angular/cdk/collections';
  22. import { Subject } from 'rxjs';
  23. import { Subscription } from 'rxjs';
  24. import { TemplateRef } from '@angular/core';
  25. import { TrackByFunction } from '@angular/core';
  26. import { ViewContainerRef } from '@angular/core';
  27. export declare type _Bottom = {
  28. bottom?: number;
  29. };
  30. /** A virtual scroll strategy that supports fixed-size items. */
  31. export declare class CdkFixedSizeVirtualScroll implements OnChanges {
  32. /** The size of the items in the list (in pixels). */
  33. get itemSize(): number;
  34. set itemSize(value: NumberInput);
  35. _itemSize: number;
  36. /**
  37. * The minimum amount of buffer rendered beyond the viewport (in pixels).
  38. * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
  39. */
  40. get minBufferPx(): number;
  41. set minBufferPx(value: NumberInput);
  42. _minBufferPx: number;
  43. /**
  44. * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
  45. */
  46. get maxBufferPx(): number;
  47. set maxBufferPx(value: NumberInput);
  48. _maxBufferPx: number;
  49. /** The scroll strategy used by this directive. */
  50. _scrollStrategy: FixedSizeVirtualScrollStrategy;
  51. ngOnChanges(): void;
  52. static ɵfac: i0.ɵɵFactoryDeclaration<CdkFixedSizeVirtualScroll, never>;
  53. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkFixedSizeVirtualScroll, "cdk-virtual-scroll-viewport[itemSize]", never, { "itemSize": { "alias": "itemSize"; "required": false; }; "minBufferPx": { "alias": "minBufferPx"; "required": false; }; "maxBufferPx": { "alias": "maxBufferPx"; "required": false; }; }, {}, never, never, true, never>;
  54. }
  55. /**
  56. * Sends an event when the directive's element is scrolled. Registers itself with the
  57. * ScrollDispatcher service to include itself as part of its collection of scrolling events that it
  58. * can be listened to through the service.
  59. */
  60. export declare class CdkScrollable implements OnInit, OnDestroy {
  61. protected elementRef: ElementRef<HTMLElement>;
  62. protected scrollDispatcher: ScrollDispatcher;
  63. protected ngZone: NgZone;
  64. protected dir?: Directionality | undefined;
  65. protected readonly _destroyed: Subject<void>;
  66. protected _elementScrolled: Observable<Event>;
  67. constructor(elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, ngZone: NgZone, dir?: Directionality | undefined);
  68. ngOnInit(): void;
  69. ngOnDestroy(): void;
  70. /** Returns observable that emits when a scroll event is fired on the host element. */
  71. elementScrolled(): Observable<Event>;
  72. /** Gets the ElementRef for the viewport. */
  73. getElementRef(): ElementRef<HTMLElement>;
  74. /**
  75. * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo
  76. * method, since browsers are not consistent about what scrollLeft means in RTL. For this method
  77. * left and right always refer to the left and right side of the scrolling container irrespective
  78. * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
  79. * in an RTL context.
  80. * @param options specified the offsets to scroll to.
  81. */
  82. scrollTo(options: ExtendedScrollToOptions): void;
  83. private _applyScrollToOptions;
  84. /**
  85. * Measures the scroll offset relative to the specified edge of the viewport. This method can be
  86. * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent
  87. * about what scrollLeft means in RTL. The values returned by this method are normalized such that
  88. * left and right always refer to the left and right side of the scrolling container irrespective
  89. * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
  90. * in an RTL context.
  91. * @param from The edge to measure from.
  92. */
  93. measureScrollOffset(from: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
  94. static ɵfac: i0.ɵɵFactoryDeclaration<CdkScrollable, [null, null, null, { optional: true; }]>;
  95. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkScrollable, "[cdk-scrollable], [cdkScrollable]", never, {}, {}, never, never, true, never>;
  96. }
  97. export declare class CdkScrollableModule {
  98. static ɵfac: i0.ɵɵFactoryDeclaration<CdkScrollableModule, never>;
  99. static ɵmod: i0.ɵɵNgModuleDeclaration<CdkScrollableModule, never, [typeof i1.CdkScrollable], [typeof i1.CdkScrollable]>;
  100. static ɵinj: i0.ɵɵInjectorDeclaration<CdkScrollableModule>;
  101. }
  102. /**
  103. * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling
  104. * container.
  105. */
  106. export declare class CdkVirtualForOf<T> implements CdkVirtualScrollRepeater<T>, CollectionViewer, DoCheck, OnDestroy {
  107. /** The view container to add items to. */
  108. private _viewContainerRef;
  109. /** The template to use when stamping out new items. */
  110. private _template;
  111. /** The set of available differs. */
  112. private _differs;
  113. /** The strategy used to render items in the virtual scroll viewport. */
  114. private _viewRepeater;
  115. /** The virtual scrolling viewport that these items are being rendered in. */
  116. private _viewport;
  117. /** Emits when the rendered view of the data changes. */
  118. readonly viewChange: Subject<ListRange>;
  119. /** Subject that emits when a new DataSource instance is given. */
  120. private readonly _dataSourceChanges;
  121. /** The DataSource to display. */
  122. get cdkVirtualForOf(): DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined;
  123. set cdkVirtualForOf(value: DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined);
  124. _cdkVirtualForOf: DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined;
  125. /**
  126. * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and
  127. * the item and produces a value to be used as the item's identity when tracking changes.
  128. */
  129. get cdkVirtualForTrackBy(): TrackByFunction<T> | undefined;
  130. set cdkVirtualForTrackBy(fn: TrackByFunction<T> | undefined);
  131. private _cdkVirtualForTrackBy;
  132. /** The template used to stamp out new elements. */
  133. set cdkVirtualForTemplate(value: TemplateRef<CdkVirtualForOfContext<T>>);
  134. /**
  135. * The size of the cache used to store templates that are not being used for re-use later.
  136. * Setting the cache size to `0` will disable caching. Defaults to 20 templates.
  137. */
  138. get cdkVirtualForTemplateCacheSize(): number;
  139. set cdkVirtualForTemplateCacheSize(size: NumberInput);
  140. /** Emits whenever the data in the current DataSource changes. */
  141. readonly dataStream: Observable<readonly T[]>;
  142. /** The differ used to calculate changes to the data. */
  143. private _differ;
  144. /** The most recent data emitted from the DataSource. */
  145. private _data;
  146. /** The currently rendered items. */
  147. private _renderedItems;
  148. /** The currently rendered range of indices. */
  149. private _renderedRange;
  150. /** Whether the rendered data should be updated during the next ngDoCheck cycle. */
  151. private _needsUpdate;
  152. private readonly _destroyed;
  153. constructor(
  154. /** The view container to add items to. */
  155. _viewContainerRef: ViewContainerRef,
  156. /** The template to use when stamping out new items. */
  157. _template: TemplateRef<CdkVirtualForOfContext<T>>,
  158. /** The set of available differs. */
  159. _differs: IterableDiffers,
  160. /** The strategy used to render items in the virtual scroll viewport. */
  161. _viewRepeater: _RecycleViewRepeaterStrategy<T, T, CdkVirtualForOfContext<T>>,
  162. /** The virtual scrolling viewport that these items are being rendered in. */
  163. _viewport: CdkVirtualScrollViewport, ngZone: NgZone);
  164. /**
  165. * Measures the combined size (width for horizontal orientation, height for vertical) of all items
  166. * in the specified range. Throws an error if the range includes items that are not currently
  167. * rendered.
  168. */
  169. measureRangeSize(range: ListRange, orientation: 'horizontal' | 'vertical'): number;
  170. ngDoCheck(): void;
  171. ngOnDestroy(): void;
  172. /** React to scroll state changes in the viewport. */
  173. private _onRenderedDataChange;
  174. /** Swap out one `DataSource` for another. */
  175. private _changeDataSource;
  176. /** Update the `CdkVirtualForOfContext` for all views. */
  177. private _updateContext;
  178. /** Apply changes to the DOM. */
  179. private _applyChanges;
  180. /** Update the computed properties on the `CdkVirtualForOfContext`. */
  181. private _updateComputedContextProperties;
  182. private _getEmbeddedViewArgs;
  183. static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualForOf<any>, [null, null, null, null, { skipSelf: true; }, null]>;
  184. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualForOf<any>, "[cdkVirtualFor][cdkVirtualForOf]", never, { "cdkVirtualForOf": { "alias": "cdkVirtualForOf"; "required": false; }; "cdkVirtualForTrackBy": { "alias": "cdkVirtualForTrackBy"; "required": false; }; "cdkVirtualForTemplate": { "alias": "cdkVirtualForTemplate"; "required": false; }; "cdkVirtualForTemplateCacheSize": { "alias": "cdkVirtualForTemplateCacheSize"; "required": false; }; }, {}, never, never, true, never>;
  185. }
  186. /** The context for an item rendered by `CdkVirtualForOf` */
  187. export declare type CdkVirtualForOfContext<T> = {
  188. /** The item value. */
  189. $implicit: T;
  190. /** The DataSource, Observable, or NgIterable that was passed to *cdkVirtualFor. */
  191. cdkVirtualForOf: DataSource<T> | Observable<T[]> | NgIterable<T>;
  192. /** The index of the item in the DataSource. */
  193. index: number;
  194. /** The number of items in the DataSource. */
  195. count: number;
  196. /** Whether this is the first item in the DataSource. */
  197. first: boolean;
  198. /** Whether this is the last item in the DataSource. */
  199. last: boolean;
  200. /** Whether the index is even. */
  201. even: boolean;
  202. /** Whether the index is odd. */
  203. odd: boolean;
  204. };
  205. /**
  206. * Extending the {@link CdkScrollable} to be used as scrolling container for virtual scrolling.
  207. */
  208. export declare abstract class CdkVirtualScrollable extends CdkScrollable {
  209. constructor(elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, ngZone: NgZone, dir?: Directionality);
  210. /**
  211. * Measure the viewport size for the provided orientation.
  212. *
  213. * @param orientation The orientation to measure the size from.
  214. */
  215. measureViewportSize(orientation: 'horizontal' | 'vertical'): number;
  216. /**
  217. * Measure the bounding ClientRect size including the scroll offset.
  218. *
  219. * @param from The edge to measure from.
  220. */
  221. abstract measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
  222. static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollable, [null, null, null, { optional: true; }]>;
  223. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollable, never, never, {}, {}, never, never, false, never>;
  224. }
  225. /**
  226. * Provides a virtual scrollable for the element it is attached to.
  227. */
  228. export declare class CdkVirtualScrollableElement extends CdkVirtualScrollable {
  229. constructor(elementRef: ElementRef, scrollDispatcher: ScrollDispatcher, ngZone: NgZone, dir: Directionality);
  230. measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
  231. static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollableElement, [null, null, null, { optional: true; }]>;
  232. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableElement, "[cdkVirtualScrollingElement]", never, {}, {}, never, never, true, never>;
  233. }
  234. /**
  235. * Provides as virtual scrollable for the global / window scrollbar.
  236. */
  237. export declare class CdkVirtualScrollableWindow extends CdkVirtualScrollable {
  238. protected _elementScrolled: Observable<Event>;
  239. constructor(scrollDispatcher: ScrollDispatcher, ngZone: NgZone, dir: Directionality);
  240. measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
  241. static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollableWindow, [null, null, { optional: true; }]>;
  242. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableWindow, "cdk-virtual-scroll-viewport[scrollWindow]", never, {}, {}, never, never, true, never>;
  243. }
  244. /**
  245. * An item to be repeated by the VirtualScrollViewport
  246. */
  247. export declare interface CdkVirtualScrollRepeater<T> {
  248. readonly dataStream: Observable<readonly T[]>;
  249. measureRangeSize(range: ListRange, orientation: 'horizontal' | 'vertical'): number;
  250. }
  251. /** A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`. */
  252. export declare class CdkVirtualScrollViewport extends CdkVirtualScrollable implements OnInit, OnDestroy {
  253. elementRef: ElementRef<HTMLElement>;
  254. private _changeDetectorRef;
  255. private _scrollStrategy;
  256. scrollable: CdkVirtualScrollable;
  257. private _platform;
  258. /** Emits when the viewport is detached from a CdkVirtualForOf. */
  259. private readonly _detachedSubject;
  260. /** Emits when the rendered range changes. */
  261. private readonly _renderedRangeSubject;
  262. /** The direction the viewport scrolls. */
  263. get orientation(): 'horizontal' | 'vertical';
  264. set orientation(orientation: 'horizontal' | 'vertical');
  265. private _orientation;
  266. /**
  267. * Whether rendered items should persist in the DOM after scrolling out of view. By default, items
  268. * will be removed.
  269. */
  270. get appendOnly(): boolean;
  271. set appendOnly(value: BooleanInput);
  272. private _appendOnly;
  273. /** Emits when the index of the first element visible in the viewport changes. */
  274. readonly scrolledIndexChange: Observable<number>;
  275. /** The element that wraps the rendered content. */
  276. _contentWrapper: ElementRef<HTMLElement>;
  277. /** A stream that emits whenever the rendered range changes. */
  278. readonly renderedRangeStream: Observable<ListRange>;
  279. /**
  280. * The total size of all content (in pixels), including content that is not currently rendered.
  281. */
  282. private _totalContentSize;
  283. /** A string representing the `style.width` property value to be used for the spacer element. */
  284. _totalContentWidth: string;
  285. /** A string representing the `style.height` property value to be used for the spacer element. */
  286. _totalContentHeight: string;
  287. /**
  288. * The CSS transform applied to the rendered subset of items so that they appear within the bounds
  289. * of the visible viewport.
  290. */
  291. private _renderedContentTransform;
  292. /** The currently rendered range of indices. */
  293. private _renderedRange;
  294. /** The length of the data bound to this viewport (in number of items). */
  295. private _dataLength;
  296. /** The size of the viewport (in pixels). */
  297. private _viewportSize;
  298. /** the currently attached CdkVirtualScrollRepeater. */
  299. private _forOf;
  300. /** The last rendered content offset that was set. */
  301. private _renderedContentOffset;
  302. /**
  303. * Whether the last rendered content offset was to the end of the content (and therefore needs to
  304. * be rewritten as an offset to the start of the content).
  305. */
  306. private _renderedContentOffsetNeedsRewrite;
  307. /** Whether there is a pending change detection cycle. */
  308. private _isChangeDetectionPending;
  309. /** A list of functions to run after the next change detection cycle. */
  310. private _runAfterChangeDetection;
  311. /** Subscription to changes in the viewport size. */
  312. private _viewportChanges;
  313. constructor(elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, _scrollStrategy: VirtualScrollStrategy, dir: Directionality, scrollDispatcher: ScrollDispatcher, viewportRuler: ViewportRuler, scrollable: CdkVirtualScrollable);
  314. ngOnInit(): void;
  315. ngOnDestroy(): void;
  316. /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
  317. attach(forOf: CdkVirtualScrollRepeater<any>): void;
  318. /** Detaches the current `CdkVirtualForOf`. */
  319. detach(): void;
  320. /** Gets the length of the data bound to this viewport (in number of items). */
  321. getDataLength(): number;
  322. /** Gets the size of the viewport (in pixels). */
  323. getViewportSize(): number;
  324. /** Get the current rendered range of items. */
  325. getRenderedRange(): ListRange;
  326. measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
  327. /**
  328. * Sets the total size of all content (in pixels), including content that is not currently
  329. * rendered.
  330. */
  331. setTotalContentSize(size: number): void;
  332. /** Sets the currently rendered range of indices. */
  333. setRenderedRange(range: ListRange): void;
  334. /**
  335. * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
  336. */
  337. getOffsetToRenderedContentStart(): number | null;
  338. /**
  339. * Sets the offset from the start of the viewport to either the start or end of the rendered data
  340. * (in pixels).
  341. */
  342. setRenderedContentOffset(offset: number, to?: 'to-start' | 'to-end'): void;
  343. /**
  344. * Scrolls to the given offset from the start of the viewport. Please note that this is not always
  345. * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
  346. * direction, this would be the equivalent of setting a fictional `scrollRight` property.
  347. * @param offset The offset to scroll to.
  348. * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
  349. */
  350. scrollToOffset(offset: number, behavior?: ScrollBehavior): void;
  351. /**
  352. * Scrolls to the offset for the given index.
  353. * @param index The index of the element to scroll to.
  354. * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
  355. */
  356. scrollToIndex(index: number, behavior?: ScrollBehavior): void;
  357. /**
  358. * Gets the current scroll offset from the start of the scrollable (in pixels).
  359. * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
  360. * in horizontal mode.
  361. */
  362. measureScrollOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
  363. /**
  364. * Measures the offset of the viewport from the scrolling container
  365. * @param from The edge to measure from.
  366. */
  367. measureViewportOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
  368. /** Measure the combined size of all of the rendered items. */
  369. measureRenderedContentSize(): number;
  370. /**
  371. * Measure the total combined size of the given range. Throws if the range includes items that are
  372. * not rendered.
  373. */
  374. measureRangeSize(range: ListRange): number;
  375. /** Update the viewport dimensions and re-render. */
  376. checkViewportSize(): void;
  377. /** Measure the viewport size. */
  378. private _measureViewportSize;
  379. /** Queue up change detection to run. */
  380. private _markChangeDetectionNeeded;
  381. /** Run change detection. */
  382. private _doChangeDetection;
  383. /** Calculates the `style.width` and `style.height` for the spacer element. */
  384. private _calculateSpacerSize;
  385. static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollViewport, [null, null, null, { optional: true; }, { optional: true; }, null, null, { optional: true; }]>;
  386. static ɵcmp: i0.ɵɵComponentDeclaration<CdkVirtualScrollViewport, "cdk-virtual-scroll-viewport", never, { "orientation": { "alias": "orientation"; "required": false; }; "appendOnly": { "alias": "appendOnly"; "required": false; }; }, { "scrolledIndexChange": "scrolledIndexChange"; }, never, ["*"], true, never>;
  387. }
  388. /** Time in ms to throttle the resize events by default. */
  389. export declare const DEFAULT_RESIZE_TIME = 20;
  390. /** Time in ms to throttle the scrolling events by default. */
  391. export declare const DEFAULT_SCROLL_TIME = 20;
  392. export declare type _End = {
  393. end?: number;
  394. };
  395. /**
  396. * An extended version of ScrollToOptions that allows expressing scroll offsets relative to the
  397. * top, bottom, left, right, start, or end of the viewport rather than just the top and left.
  398. * Please note: the top and bottom properties are mutually exclusive, as are the left, right,
  399. * start, and end properties.
  400. */
  401. export declare type ExtendedScrollToOptions = _XAxis & _YAxis & ScrollOptions;
  402. /** Virtual scrolling strategy for lists with items of known fixed size. */
  403. export declare class FixedSizeVirtualScrollStrategy implements VirtualScrollStrategy {
  404. private readonly _scrolledIndexChange;
  405. /** @docs-private Implemented as part of VirtualScrollStrategy. */
  406. scrolledIndexChange: Observable<number>;
  407. /** The attached viewport. */
  408. private _viewport;
  409. /** The size of the items in the virtually scrolling list. */
  410. private _itemSize;
  411. /** The minimum amount of buffer rendered beyond the viewport (in pixels). */
  412. private _minBufferPx;
  413. /** The number of buffer items to render beyond the edge of the viewport (in pixels). */
  414. private _maxBufferPx;
  415. /**
  416. * @param itemSize The size of the items in the virtually scrolling list.
  417. * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
  418. * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
  419. */
  420. constructor(itemSize: number, minBufferPx: number, maxBufferPx: number);
  421. /**
  422. * Attaches this scroll strategy to a viewport.
  423. * @param viewport The viewport to attach this strategy to.
  424. */
  425. attach(viewport: CdkVirtualScrollViewport): void;
  426. /** Detaches this scroll strategy from the currently attached viewport. */
  427. detach(): void;
  428. /**
  429. * Update the item size and buffer size.
  430. * @param itemSize The size of the items in the virtually scrolling list.
  431. * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
  432. * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
  433. */
  434. updateItemAndBufferSize(itemSize: number, minBufferPx: number, maxBufferPx: number): void;
  435. /** @docs-private Implemented as part of VirtualScrollStrategy. */
  436. onContentScrolled(): void;
  437. /** @docs-private Implemented as part of VirtualScrollStrategy. */
  438. onDataLengthChanged(): void;
  439. /** @docs-private Implemented as part of VirtualScrollStrategy. */
  440. onContentRendered(): void;
  441. /** @docs-private Implemented as part of VirtualScrollStrategy. */
  442. onRenderedOffsetChanged(): void;
  443. /**
  444. * Scroll to the offset for the given index.
  445. * @param index The index of the element to scroll to.
  446. * @param behavior The ScrollBehavior to use when scrolling.
  447. */
  448. scrollToIndex(index: number, behavior: ScrollBehavior): void;
  449. /** Update the viewport's total content size. */
  450. private _updateTotalContentSize;
  451. /** Update the viewport's rendered range. */
  452. private _updateRenderedRange;
  453. }
  454. /**
  455. * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
  456. * `FixedSizeVirtualScrollStrategy` from the given directive.
  457. * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
  458. * `FixedSizeVirtualScrollStrategy` from.
  459. */
  460. export declare function _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkFixedSizeVirtualScroll): FixedSizeVirtualScrollStrategy;
  461. declare namespace i1 {
  462. export {
  463. _Without,
  464. _XOR,
  465. _Top,
  466. _Bottom,
  467. _Left,
  468. _Right,
  469. _Start,
  470. _End,
  471. _XAxis,
  472. _YAxis,
  473. ExtendedScrollToOptions,
  474. CdkScrollable
  475. }
  476. }
  477. declare namespace i3 {
  478. export {
  479. CdkVirtualScrollViewport
  480. }
  481. }
  482. declare namespace i4 {
  483. export {
  484. _fixedSizeVirtualScrollStrategyFactory,
  485. FixedSizeVirtualScrollStrategy,
  486. CdkFixedSizeVirtualScroll
  487. }
  488. }
  489. declare namespace i5 {
  490. export {
  491. CdkVirtualForOfContext,
  492. CdkVirtualForOf
  493. }
  494. }
  495. declare namespace i6 {
  496. export {
  497. CdkVirtualScrollableWindow
  498. }
  499. }
  500. declare namespace i7 {
  501. export {
  502. CdkVirtualScrollableElement
  503. }
  504. }
  505. export declare type _Left = {
  506. left?: number;
  507. };
  508. export declare type _Right = {
  509. right?: number;
  510. };
  511. /**
  512. * Service contained all registered Scrollable references and emits an event when any one of the
  513. * Scrollable references emit a scrolled event.
  514. */
  515. export declare class ScrollDispatcher implements OnDestroy {
  516. private _ngZone;
  517. private _platform;
  518. /** Used to reference correct document/window */
  519. protected _document: Document;
  520. constructor(_ngZone: NgZone, _platform: Platform, document: any);
  521. /** Subject for notifying that a registered scrollable reference element has been scrolled. */
  522. private readonly _scrolled;
  523. /** Keeps track of the global `scroll` and `resize` subscriptions. */
  524. _globalSubscription: Subscription | null;
  525. /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */
  526. private _scrolledCount;
  527. /**
  528. * Map of all the scrollable references that are registered with the service and their
  529. * scroll event subscriptions.
  530. */
  531. scrollContainers: Map<CdkScrollable, Subscription>;
  532. /**
  533. * Registers a scrollable instance with the service and listens for its scrolled events. When the
  534. * scrollable is scrolled, the service emits the event to its scrolled observable.
  535. * @param scrollable Scrollable instance to be registered.
  536. */
  537. register(scrollable: CdkScrollable): void;
  538. /**
  539. * De-registers a Scrollable reference and unsubscribes from its scroll event observable.
  540. * @param scrollable Scrollable instance to be deregistered.
  541. */
  542. deregister(scrollable: CdkScrollable): void;
  543. /**
  544. * Returns an observable that emits an event whenever any of the registered Scrollable
  545. * references (or window, document, or body) fire a scrolled event. Can provide a time in ms
  546. * to override the default "throttle" time.
  547. *
  548. * **Note:** in order to avoid hitting change detection for every scroll event,
  549. * all of the events emitted from this stream will be run outside the Angular zone.
  550. * If you need to update any data bindings as a result of a scroll event, you have
  551. * to run the callback using `NgZone.run`.
  552. */
  553. scrolled(auditTimeInMs?: number): Observable<CdkScrollable | void>;
  554. ngOnDestroy(): void;
  555. /**
  556. * Returns an observable that emits whenever any of the
  557. * scrollable ancestors of an element are scrolled.
  558. * @param elementOrElementRef Element whose ancestors to listen for.
  559. * @param auditTimeInMs Time to throttle the scroll events.
  560. */
  561. ancestorScrolled(elementOrElementRef: ElementRef | HTMLElement, auditTimeInMs?: number): Observable<CdkScrollable | void>;
  562. /** Returns all registered Scrollables that contain the provided element. */
  563. getAncestorScrollContainers(elementOrElementRef: ElementRef | HTMLElement): CdkScrollable[];
  564. /** Use defaultView of injected document if available or fallback to global window reference */
  565. private _getWindow;
  566. /** Returns true if the element is contained within the provided Scrollable. */
  567. private _scrollableContainsElement;
  568. /** Sets up the global scroll listeners. */
  569. private _addGlobalListener;
  570. /** Cleans up the global scroll listener. */
  571. private _removeGlobalListener;
  572. static ɵfac: i0.ɵɵFactoryDeclaration<ScrollDispatcher, [null, null, { optional: true; }]>;
  573. static ɵprov: i0.ɵɵInjectableDeclaration<ScrollDispatcher>;
  574. }
  575. /**
  576. * @docs-primary-export
  577. */
  578. export declare class ScrollingModule {
  579. static ɵfac: i0.ɵɵFactoryDeclaration<ScrollingModule, never>;
  580. static ɵmod: i0.ɵɵNgModuleDeclaration<ScrollingModule, never, [typeof i2.BidiModule, typeof CdkScrollableModule, typeof i3.CdkVirtualScrollViewport, typeof i4.CdkFixedSizeVirtualScroll, typeof i5.CdkVirtualForOf, typeof i6.CdkVirtualScrollableWindow, typeof i7.CdkVirtualScrollableElement], [typeof i2.BidiModule, typeof CdkScrollableModule, typeof i4.CdkFixedSizeVirtualScroll, typeof i5.CdkVirtualForOf, typeof i3.CdkVirtualScrollViewport, typeof i6.CdkVirtualScrollableWindow, typeof i7.CdkVirtualScrollableElement]>;
  581. static ɵinj: i0.ɵɵInjectorDeclaration<ScrollingModule>;
  582. }
  583. export declare type _Start = {
  584. start?: number;
  585. };
  586. export declare type _Top = {
  587. top?: number;
  588. };
  589. /**
  590. * Simple utility for getting the bounds of the browser viewport.
  591. * @docs-private
  592. */
  593. export declare class ViewportRuler implements OnDestroy {
  594. private _platform;
  595. /** Cached viewport dimensions. */
  596. private _viewportSize;
  597. /** Stream of viewport change events. */
  598. private readonly _change;
  599. /** Event listener that will be used to handle the viewport change events. */
  600. private _changeListener;
  601. /** Used to reference correct document/window */
  602. protected _document: Document;
  603. constructor(_platform: Platform, ngZone: NgZone, document: any);
  604. ngOnDestroy(): void;
  605. /** Returns the viewport's width and height. */
  606. getViewportSize(): Readonly<{
  607. width: number;
  608. height: number;
  609. }>;
  610. /** Gets a ClientRect for the viewport's bounds. */
  611. getViewportRect(): {
  612. top: number;
  613. left: number;
  614. bottom: number;
  615. right: number;
  616. height: number;
  617. width: number;
  618. };
  619. /** Gets the (top, left) scroll position of the viewport. */
  620. getViewportScrollPosition(): ViewportScrollPosition;
  621. /**
  622. * Returns a stream that emits whenever the size of the viewport changes.
  623. * This stream emits outside of the Angular zone.
  624. * @param throttleTime Time in milliseconds to throttle the stream.
  625. */
  626. change(throttleTime?: number): Observable<Event>;
  627. /** Use defaultView of injected document if available or fallback to global window reference */
  628. private _getWindow;
  629. /** Updates the cached viewport size. */
  630. private _updateViewportSize;
  631. static ɵfac: i0.ɵɵFactoryDeclaration<ViewportRuler, [null, null, { optional: true; }]>;
  632. static ɵprov: i0.ɵɵInjectableDeclaration<ViewportRuler>;
  633. }
  634. /** Object that holds the scroll position of the viewport in each direction. */
  635. export declare interface ViewportScrollPosition {
  636. top: number;
  637. left: number;
  638. }
  639. /** The injection token used to specify the virtual scrolling strategy. */
  640. export declare const VIRTUAL_SCROLL_STRATEGY: InjectionToken<VirtualScrollStrategy>;
  641. export declare const VIRTUAL_SCROLLABLE: InjectionToken<CdkVirtualScrollable>;
  642. /** A strategy that dictates which items should be rendered in the viewport. */
  643. export declare interface VirtualScrollStrategy {
  644. /** Emits when the index of the first element visible in the viewport changes. */
  645. scrolledIndexChange: Observable<number>;
  646. /**
  647. * Attaches this scroll strategy to a viewport.
  648. * @param viewport The viewport to attach this strategy to.
  649. */
  650. attach(viewport: CdkVirtualScrollViewport): void;
  651. /** Detaches this scroll strategy from the currently attached viewport. */
  652. detach(): void;
  653. /** Called when the viewport is scrolled (debounced using requestAnimationFrame). */
  654. onContentScrolled(): void;
  655. /** Called when the length of the data changes. */
  656. onDataLengthChanged(): void;
  657. /** Called when the range of items rendered in the DOM has changed. */
  658. onContentRendered(): void;
  659. /** Called when the offset of the rendered items changed. */
  660. onRenderedOffsetChanged(): void;
  661. /**
  662. * Scroll to the offset for the given index.
  663. * @param index The index of the element to scroll to.
  664. * @param behavior The ScrollBehavior to use when scrolling.
  665. */
  666. scrollToIndex(index: number, behavior: ScrollBehavior): void;
  667. }
  668. export declare type _Without<T> = {
  669. [P in keyof T]?: never;
  670. };
  671. export declare type _XAxis = _XOR<_XOR<_Left, _Right>, _XOR<_Start, _End>>;
  672. export declare type _XOR<T, U> = (_Without<T> & U) | (_Without<U> & T);
  673. export declare type _YAxis = _XOR<_Top, _Bottom>;
  674. export { }